Make wasm runtime cache size configurable (#10177)

* Make wasm runtime cache size configurable

* apply review comments

* remove VersionedRuntimeValue

* fix compilation

* VersionedRuntime: replace clone by Arc

* fmt

* fix warnings

* fix tests compilation

* fmt
This commit is contained in:
Éloïs
2021-12-09 16:10:16 +01:00
committed by GitHub
parent 6ce90f583c
commit 3acd335a8d
30 changed files with 139 additions and 79 deletions
@@ -238,6 +238,10 @@ pub struct RunCmd {
#[structopt(long)]
pub max_runtime_instances: Option<usize>,
/// Maximum number of different runtimes that can be cached.
#[structopt(long, default_value = "2")]
pub runtime_cache_size: u8,
/// Run a temporary node.
///
/// A temporary directory will be created to store the configuration and will be deleted
@@ -453,6 +457,10 @@ impl CliConfiguration for RunCmd {
Ok(self.max_runtime_instances.map(|x| x.min(256)))
}
fn runtime_cache_size(&self) -> Result<u8> {
Ok(self.runtime_cache_size)
}
fn base_path(&self) -> Result<Option<BasePath>> {
Ok(if self.tmp {
Some(BasePath::new_temp_dir()?)
+9
View File
@@ -452,6 +452,13 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
Ok(Default::default())
}
/// Get maximum different runtimes in cache
///
/// By default this is `2`.
fn runtime_cache_size(&self) -> Result<u8> {
Ok(2)
}
/// Activate or not the automatic announcing of blocks after import
///
/// By default this is `false`.
@@ -482,6 +489,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
let is_validator = role.is_authority();
let (keystore_remote, keystore) = self.keystore_config(&config_dir)?;
let telemetry_endpoints = self.telemetry_endpoints(&chain_spec)?;
let runtime_cache_size = self.runtime_cache_size()?;
let unsafe_pruning = self.import_params().map(|p| p.unsafe_pruning).unwrap_or(false);
@@ -534,6 +542,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
role,
base_path: Some(base_path),
informant_output_format: Default::default(),
runtime_cache_size,
})
}