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

Commit 9df9448

Browse files
ggwpezbkchr
andauthored
benches: disable caching per default (#12232)
* 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>
1 parent c1103fd commit 9df9448

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

utils/frame/benchmarking-cli/src/block/cmd.rs

+14
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ pub struct BlockCmd {
6767
#[allow(missing_docs)]
6868
#[clap(flatten)]
6969
pub params: BenchmarkParams,
70+
71+
/// Enable the Trie cache.
72+
///
73+
/// This should only be used for performance analysis and not for final results.
74+
#[clap(long)]
75+
pub enable_trie_cache: bool,
7076
}
7177

7278
impl BlockCmd {
@@ -98,4 +104,12 @@ impl CliConfiguration for BlockCmd {
98104
fn import_params(&self) -> Option<&ImportParams> {
99105
Some(&self.import_params)
100106
}
107+
108+
fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
109+
if self.enable_trie_cache {
110+
Ok(self.import_params().map(|x| x.trie_cache_maximum_size()).unwrap_or_default())
111+
} else {
112+
Ok(None)
113+
}
114+
}
101115
}

utils/frame/benchmarking-cli/src/extrinsic/cmd.rs

+14
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ pub struct ExtrinsicParams {
7272
/// Extrinsic to benchmark.
7373
#[clap(long, value_name = "EXTRINSIC", required_unless_present = "list")]
7474
pub extrinsic: Option<String>,
75+
76+
/// Enable the Trie cache.
77+
///
78+
/// This should only be used for performance analysis and not for final results.
79+
#[clap(long)]
80+
pub enable_trie_cache: bool,
7581
}
7682

7783
impl ExtrinsicCmd {
@@ -132,4 +138,12 @@ impl CliConfiguration for ExtrinsicCmd {
132138
fn import_params(&self) -> Option<&ImportParams> {
133139
Some(&self.import_params)
134140
}
141+
142+
fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
143+
if self.params.enable_trie_cache {
144+
Ok(self.import_params().map(|x| x.trie_cache_maximum_size()).unwrap_or_default())
145+
} else {
146+
Ok(None)
147+
}
148+
}
135149
}

utils/frame/benchmarking-cli/src/overhead/cmd.rs

+14
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ pub struct OverheadParams {
7575
/// Good for adding LICENSE headers.
7676
#[clap(long, value_name = "PATH")]
7777
pub header: Option<PathBuf>,
78+
79+
/// Enable the Trie cache.
80+
///
81+
/// This should only be used for performance analysis and not for final results.
82+
#[clap(long)]
83+
pub enable_trie_cache: bool,
7884
}
7985

8086
/// Type of a benchmark.
@@ -156,4 +162,12 @@ impl CliConfiguration for OverheadCmd {
156162
fn import_params(&self) -> Option<&ImportParams> {
157163
Some(&self.import_params)
158164
}
165+
166+
fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
167+
if self.params.enable_trie_cache {
168+
Ok(self.import_params().map(|x| x.trie_cache_maximum_size()).unwrap_or_default())
169+
} else {
170+
Ok(None)
171+
}
172+
}
159173
}

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

+10-4
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,15 @@ pub struct StorageParams {
105105
/// Trie cache size in bytes.
106106
///
107107
/// Providing `0` will disable the cache.
108-
#[clap(long, default_value = "1024")]
108+
#[clap(long, value_name = "Bytes", default_value = "67108864")]
109109
pub trie_cache_size: usize,
110110

111+
/// Enable the Trie cache.
112+
///
113+
/// This should only be used for performance analysis and not for final results.
114+
#[clap(long)]
115+
pub enable_trie_cache: bool,
116+
111117
/// Include child trees in benchmark.
112118
#[clap(long)]
113119
pub include_child_trees: bool,
@@ -220,10 +226,10 @@ impl CliConfiguration for StorageCmd {
220226
}
221227

222228
fn trie_cache_maximum_size(&self) -> Result<Option<usize>> {
223-
if self.params.trie_cache_size == 0 {
224-
Ok(None)
225-
} else {
229+
if self.params.enable_trie_cache && self.params.trie_cache_size > 0 {
226230
Ok(Some(self.params.trie_cache_size))
231+
} else {
232+
Ok(None)
227233
}
228234
}
229235
}

0 commit comments

Comments
 (0)