Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
benches: disable caching per default (#12232)
Browse files Browse the repository at this point in the history
* Disable cache for storage benches

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Disable caching per default

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update utils/frame/benchmarking-cli/src/storage/cmd.rs

Co-authored-by: Bastian Köcher <info@kchr.de>

* Add --enable-trie-cache to 'storage' command

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Bastian Köcher <info@kchr.de>
  • Loading branch information
2 people authored and altonen committed Sep 14, 2022
1 parent ccf061c commit e731ad0
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
14 changes: 14 additions & 0 deletions utils/frame/benchmarking-cli/src/block/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ pub struct BlockCmd {
#[allow(missing_docs)]
#[clap(flatten)]
pub params: BenchmarkParams,

/// Enable the Trie cache.
///
/// This should only be used for performance analysis and not for final results.
#[clap(long)]
pub enable_trie_cache: bool,
}

impl BlockCmd {
Expand Down Expand Up @@ -98,4 +104,12 @@ impl CliConfiguration for BlockCmd {
fn import_params(&self) -> Option<&ImportParams> {
Some(&self.import_params)
}

fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
if self.enable_trie_cache {
Ok(self.import_params().map(|x| x.trie_cache_maximum_size()).unwrap_or_default())
} else {
Ok(None)
}
}
}
14 changes: 14 additions & 0 deletions utils/frame/benchmarking-cli/src/extrinsic/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ pub struct ExtrinsicParams {
/// Extrinsic to benchmark.
#[clap(long, value_name = "EXTRINSIC", required_unless_present = "list")]
pub extrinsic: Option<String>,

/// Enable the Trie cache.
///
/// This should only be used for performance analysis and not for final results.
#[clap(long)]
pub enable_trie_cache: bool,
}

impl ExtrinsicCmd {
Expand Down Expand Up @@ -132,4 +138,12 @@ impl CliConfiguration for ExtrinsicCmd {
fn import_params(&self) -> Option<&ImportParams> {
Some(&self.import_params)
}

fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
if self.params.enable_trie_cache {
Ok(self.import_params().map(|x| x.trie_cache_maximum_size()).unwrap_or_default())
} else {
Ok(None)
}
}
}
14 changes: 14 additions & 0 deletions utils/frame/benchmarking-cli/src/overhead/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ pub struct OverheadParams {
/// Good for adding LICENSE headers.
#[clap(long, value_name = "PATH")]
pub header: Option<PathBuf>,

/// Enable the Trie cache.
///
/// This should only be used for performance analysis and not for final results.
#[clap(long)]
pub enable_trie_cache: bool,
}

/// Type of a benchmark.
Expand Down Expand Up @@ -156,4 +162,12 @@ impl CliConfiguration for OverheadCmd {
fn import_params(&self) -> Option<&ImportParams> {
Some(&self.import_params)
}

fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
if self.params.enable_trie_cache {
Ok(self.import_params().map(|x| x.trie_cache_maximum_size()).unwrap_or_default())
} else {
Ok(None)
}
}
}
14 changes: 10 additions & 4 deletions utils/frame/benchmarking-cli/src/storage/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,15 @@ pub struct StorageParams {
/// Trie cache size in bytes.
///
/// Providing `0` will disable the cache.
#[clap(long, default_value = "1024")]
#[clap(long, value_name = "Bytes", default_value = "67108864")]
pub trie_cache_size: usize,

/// Enable the Trie cache.
///
/// This should only be used for performance analysis and not for final results.
#[clap(long)]
pub enable_trie_cache: bool,

/// Include child trees in benchmark.
#[clap(long)]
pub include_child_trees: bool,
Expand Down Expand Up @@ -220,10 +226,10 @@ impl CliConfiguration for StorageCmd {
}

fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
if self.params.trie_cache_size == 0 {
Ok(None)
} else {
if self.params.enable_trie_cache && self.params.trie_cache_size > 0 {
Ok(Some(self.params.trie_cache_size))
} else {
Ok(None)
}
}
}

0 comments on commit e731ad0

Please sign in to comment.