-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix small issues on benchmark overhead command #11893
Changes from all commits
b7012bc
1e644c4
2abb7f1
e1b36e8
0ed3392
5defeff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,12 +23,12 @@ use sc_cli::{CliConfiguration, ImportParams, Result, SharedParams}; | |
| use sc_client_api::Backend as ClientBackend; | ||
| use sc_service::Configuration; | ||
| use sp_api::{ApiExt, ProvideRuntimeApi}; | ||
| use sp_runtime::{traits::Block as BlockT, OpaqueExtrinsic}; | ||
| use sp_runtime::{traits::{ Block as BlockT, Header as HeaderT}, OpaqueExtrinsic}; | ||
|
|
||
| use clap::{Args, Parser}; | ||
| use log::info; | ||
| use serde::Serialize; | ||
| use std::{fmt::Debug, sync::Arc}; | ||
| use std::{fmt::Debug, sync::Arc, path::PathBuf}; | ||
|
|
||
| use crate::{ | ||
| overhead::{ | ||
|
|
@@ -52,6 +52,10 @@ pub struct OverheadCmd { | |
| #[allow(missing_docs)] | ||
| #[clap(flatten)] | ||
| pub params: OverheadParams, | ||
|
|
||
| /// Add a header file to your outputted benchmarks. | ||
| #[clap(long)] | ||
| pub header: Option<PathBuf>, | ||
| } | ||
|
|
||
| /// Configures the benchmark, the post-processing and weight generation. | ||
|
|
@@ -96,21 +100,28 @@ impl OverheadCmd { | |
| BA: ClientBackend<Block>, | ||
| C: BlockBuilderProvider<BA, Block, C> + ProvideRuntimeApi<Block>, | ||
| C::Api: ApiExt<Block, StateBackend = BA::State> + BlockBuilderApi<Block>, | ||
| <<<Block as BlockT>::Header as HeaderT>::Number as std::str::FromStr>::Err: std::fmt::Debug, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dont see where this is needed, maybe stale code? |
||
| { | ||
| if let Some(header_file) = &self.header { | ||
| if !header_file.is_file() { | ||
| return Err("Header file is invalid!".into()) | ||
| }; | ||
| } | ||
|
|
||
| let bench = Benchmark::new(client, self.params.bench.clone(), inherent_data, ext_builder); | ||
|
|
||
| // per-block execution overhead | ||
| { | ||
| let stats = bench.bench(BenchmarkType::Block)?; | ||
| info!("Per-block execution overhead [ns]:\n{:?}", stats); | ||
| let template = TemplateData::new(BenchmarkType::Block, &cfg, &self.params, &stats)?; | ||
| let template = TemplateData::new(BenchmarkType::Block, &cfg, &self, &stats)?; | ||
| template.write(&self.params.weight.weight_path)?; | ||
| } | ||
| // per-extrinsic execution overhead | ||
| { | ||
| let stats = bench.bench(BenchmarkType::Extrinsic)?; | ||
| info!("Per-extrinsic execution overhead [ns]:\n{:?}", stats); | ||
| let template = TemplateData::new(BenchmarkType::Extrinsic, &cfg, &self.params, &stats)?; | ||
| let template = TemplateData::new(BenchmarkType::Extrinsic, &cfg, &self, &stats)?; | ||
| template.write(&self.params.weight.weight_path)?; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| {{header}} | ||
| // This file is part of Substrate. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line 2 to 17 can now be removed as they are already in the root file |
||
|
|
||
| // Copyright (C) 2022 Parity Technologies (UK) Ltd. | ||
|
|
@@ -23,6 +24,7 @@ | |
| //! WARMUPS: `{{params.bench.warmup}}`, REPEAT: `{{params.bench.repeat}}` | ||
| //! WEIGHT-PATH: `{{params.weight.weight_path}}` | ||
| //! WEIGHT-METRIC: `{{params.weight.weight_metric}}`, WEIGHT-MUL: `{{params.weight.weight_mul}}`, WEIGHT-ADD: `{{params.weight.weight_add}}` | ||
| //! WASM-EXECUTION-METHOD: `{{execution_strategy}}` | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just noticed that this always prints something, even when |
||
|
|
||
| // Executed Command: | ||
| {{#each args as |arg|}} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,10 @@ pub struct WeightParams { | |
| /// Is applied after `weight_mul`. | ||
| #[clap(long = "add", default_value = "0")] | ||
| pub weight_add: u64, | ||
|
|
||
| /// The block weight key | ||
| #[clap(long = "key", default_value = "26aa394eea5630e07c48ae0c9558cef734abf5cb34d6244378cddbf18e849d96")] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This key is needed here. |
||
| pub block_weight_key: String, | ||
| } | ||
|
|
||
| /// Calculates the final weight by multiplying the selected metric with | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason not to put it into the
OverheadParams?I think its cleaner to only pass around the
OverheadParamsinstead of the wholeOverheadCmd.