mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
Add LRU cache to database (#837)
* Add LRU caches to store * Improvements to LRU caches * Take state by value in `Store::put_state` * Store blocks by value, configurable cache sizes * Use a StateBatch to efficiently store skip states * Fix store tests * Add CloneConfig test, remove unused metrics * Use Mutexes instead of RwLocks for LRU caches
This commit is contained in:
@@ -199,6 +199,20 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
|
||||
DO NOT DECREASE AFTER INITIALIZATION. [default: 2048 (mainnet) or 64 (minimal)]")
|
||||
.takes_value(true)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("block-cache-size")
|
||||
.long("block-cache-size")
|
||||
.value_name("SIZE")
|
||||
.help("Specifies how many blocks the database should cache in memory [default: 5]")
|
||||
.takes_value(true)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("state-cache-size")
|
||||
.long("state-cache-size")
|
||||
.value_name("SIZE")
|
||||
.help("Specifies how many states the database should cache in memory [default: 5]")
|
||||
.takes_value(true)
|
||||
)
|
||||
/*
|
||||
* The "testnet" sub-command.
|
||||
*
|
||||
|
||||
@@ -252,7 +252,7 @@ pub fn get_configs<E: EthSpec>(
|
||||
};
|
||||
|
||||
if let Some(freezer_dir) = cli_args.value_of("freezer-dir") {
|
||||
client_config.store.freezer_db_path = Some(PathBuf::from(freezer_dir));
|
||||
client_config.freezer_db_path = Some(PathBuf::from(freezer_dir));
|
||||
}
|
||||
|
||||
if let Some(slots_per_restore_point) = cli_args.value_of("slots-per-restore-point") {
|
||||
@@ -266,6 +266,18 @@ pub fn get_configs<E: EthSpec>(
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(block_cache_size) = cli_args.value_of("block-cache-size") {
|
||||
client_config.store.block_cache_size = block_cache_size
|
||||
.parse()
|
||||
.map_err(|_| "block-cache-size is not a valid integer".to_string())?;
|
||||
}
|
||||
|
||||
if let Some(state_cache_size) = cli_args.value_of("state-cache-size") {
|
||||
client_config.store.state_cache_size = state_cache_size
|
||||
.parse()
|
||||
.map_err(|_| "block-cache-size is not a valid integer".to_string())?;
|
||||
}
|
||||
|
||||
if eth2_config.spec_constants != client_config.spec_constants {
|
||||
crit!(log, "Specification constants do not match.";
|
||||
"client_config" => client_config.spec_constants.to_string(),
|
||||
|
||||
@@ -90,11 +90,7 @@ impl<E: EthSpec> ProductionBeaconNode<E> {
|
||||
Ok(ClientBuilder::new(context.eth_spec_instance.clone())
|
||||
.runtime_context(context)
|
||||
.chain_spec(spec)
|
||||
.disk_store(
|
||||
&db_path,
|
||||
&freezer_db_path_res?,
|
||||
store_config.slots_per_restore_point,
|
||||
)?
|
||||
.disk_store(&db_path, &freezer_db_path_res?, store_config)?
|
||||
.background_migrator()?)
|
||||
})
|
||||
.and_then(move |builder| {
|
||||
|
||||
Reference in New Issue
Block a user