From 385a23d9bc13168f9304201fc1a025f6dfc19803 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 9 Sep 2022 19:34:11 +0200 Subject: [PATCH 1/4] Disable cache for storage benches Signed-off-by: Oliver Tale-Yazdi --- utils/frame/benchmarking-cli/src/storage/cmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/frame/benchmarking-cli/src/storage/cmd.rs b/utils/frame/benchmarking-cli/src/storage/cmd.rs index d28ac4102152f..5e36dee23ec8e 100644 --- a/utils/frame/benchmarking-cli/src/storage/cmd.rs +++ b/utils/frame/benchmarking-cli/src/storage/cmd.rs @@ -105,7 +105,7 @@ pub struct StorageParams { /// Trie cache size in bytes. /// /// Providing `0` will disable the cache. - #[clap(long, default_value = "1024")] + #[clap(long, default_value = "0")] pub trie_cache_size: usize, /// Include child trees in benchmark. From 0d27f49fcc229a869105e67e8eaa32bb64995462 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Fri, 9 Sep 2022 19:34:25 +0200 Subject: [PATCH 2/4] Disable caching per default Signed-off-by: Oliver Tale-Yazdi --- utils/frame/benchmarking-cli/src/block/cmd.rs | 14 ++++++++++++++ utils/frame/benchmarking-cli/src/extrinsic/cmd.rs | 14 ++++++++++++++ utils/frame/benchmarking-cli/src/overhead/cmd.rs | 14 ++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/utils/frame/benchmarking-cli/src/block/cmd.rs b/utils/frame/benchmarking-cli/src/block/cmd.rs index e4e1716b1c5ac..14cbb1b438686 100644 --- a/utils/frame/benchmarking-cli/src/block/cmd.rs +++ b/utils/frame/benchmarking-cli/src/block/cmd.rs @@ -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 { @@ -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> { + if self.enable_trie_cache { + Ok(self.import_params().map(|x| x.trie_cache_maximum_size()).unwrap_or_default()) + } else { + Ok(None) + } + } } diff --git a/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs b/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs index 2c94a6be50255..339d6126bcd09 100644 --- a/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs +++ b/utils/frame/benchmarking-cli/src/extrinsic/cmd.rs @@ -72,6 +72,12 @@ pub struct ExtrinsicParams { /// Extrinsic to benchmark. #[clap(long, value_name = "EXTRINSIC", required_unless_present = "list")] pub extrinsic: Option, + + /// 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 { @@ -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> { + if self.params.enable_trie_cache { + Ok(self.import_params().map(|x| x.trie_cache_maximum_size()).unwrap_or_default()) + } else { + Ok(None) + } + } } diff --git a/utils/frame/benchmarking-cli/src/overhead/cmd.rs b/utils/frame/benchmarking-cli/src/overhead/cmd.rs index 1c6753b4a20ea..93b0e7c472647 100644 --- a/utils/frame/benchmarking-cli/src/overhead/cmd.rs +++ b/utils/frame/benchmarking-cli/src/overhead/cmd.rs @@ -75,6 +75,12 @@ pub struct OverheadParams { /// Good for adding LICENSE headers. #[clap(long, value_name = "PATH")] pub header: Option, + + /// 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. @@ -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> { + if self.params.enable_trie_cache { + Ok(self.import_params().map(|x| x.trie_cache_maximum_size()).unwrap_or_default()) + } else { + Ok(None) + } + } } From f85a82ec72b11abdbac868ebba09e414671d3f37 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 12 Sep 2022 12:09:50 +0200 Subject: [PATCH 3/4] Update utils/frame/benchmarking-cli/src/storage/cmd.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bastian Köcher --- utils/frame/benchmarking-cli/src/storage/cmd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/frame/benchmarking-cli/src/storage/cmd.rs b/utils/frame/benchmarking-cli/src/storage/cmd.rs index 5e36dee23ec8e..d28ac4102152f 100644 --- a/utils/frame/benchmarking-cli/src/storage/cmd.rs +++ b/utils/frame/benchmarking-cli/src/storage/cmd.rs @@ -105,7 +105,7 @@ pub struct StorageParams { /// Trie cache size in bytes. /// /// Providing `0` will disable the cache. - #[clap(long, default_value = "0")] + #[clap(long, default_value = "1024")] pub trie_cache_size: usize, /// Include child trees in benchmark. From 1653c2269e7f4f94dfbffc1b9be5a4efb95bacee Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 12 Sep 2022 12:55:36 +0200 Subject: [PATCH 4/4] Add --enable-trie-cache to 'storage' command Signed-off-by: Oliver Tale-Yazdi --- utils/frame/benchmarking-cli/src/storage/cmd.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/utils/frame/benchmarking-cli/src/storage/cmd.rs b/utils/frame/benchmarking-cli/src/storage/cmd.rs index d28ac4102152f..1d91e8f0b0517 100644 --- a/utils/frame/benchmarking-cli/src/storage/cmd.rs +++ b/utils/frame/benchmarking-cli/src/storage/cmd.rs @@ -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, @@ -220,10 +226,10 @@ impl CliConfiguration for StorageCmd { } fn trie_cache_maximum_size(&self) -> Result> { - 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) } } }