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

Commit

Permalink
Integrate benchmark-overhead command (#5137)
Browse files Browse the repository at this point in the history
* Integrate benchmark-overhead command

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

* Beauty fix test

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

* Spellcheck on

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

* Remove constants:: module

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

* Update block+extrinsic weights

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

* Revert "Update block+extrinsic weights"

This reverts commit d77bf97.

* Revert "Remove constants:: module"

This reverts commit 2d3bcd0.

* Review fixes

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

* Review fixes

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

* Review fixes

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

* Review fixes

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

* CI

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

Co-authored-by: parity-processbot <>
  • Loading branch information
ggwpez authored Apr 1, 2022
1 parent a1ab369 commit dfaac46
Show file tree
Hide file tree
Showing 11 changed files with 426 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ pub enum Subcommand {
)]
BenchmarkBlock(frame_benchmarking_cli::BlockCmd),

/// Sub command for benchmarking the per-block and per-extrinsic execution overhead.
#[clap(
name = "benchmark-overhead",
about = "Benchmark the per-block and per-extrinsic execution overhead."
)]
BenchmarkOverhead(frame_benchmarking_cli::OverheadCmd),

/// Sub command for benchmarking the storage speed.
#[clap(name = "benchmark-storage", about = "Benchmark storage speed.")]
BenchmarkStorage(frame_benchmarking_cli::StorageCmd),
Expand Down
99 changes: 97 additions & 2 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ use crate::cli::{Cli, Subcommand};
use futures::future::TryFutureExt;
use log::info;
use sc_cli::{Role, RuntimeVersion, SubstrateCli};
use service::{self, IdentifyVariant};
use service::{self, HeaderBackend, IdentifyVariant};
use sp_core::crypto::Ss58AddressFormatRegistry;
use std::net::ToSocketAddrs;

pub use crate::error::Error;
pub use crate::{error::Error, service::BlockId};
pub use polkadot_performance_test::PerfCheckError;

impl std::convert::From<String> for Error {
Expand Down Expand Up @@ -534,6 +534,101 @@ pub fn run() -> Result<()> {
#[cfg(not(feature = "polkadot-native"))]
unreachable!("No runtime feature (polkadot, kusama, westend, rococo) is enabled")
},
Some(Subcommand::BenchmarkOverhead(cmd)) => {
use polkadot_client::benchmark_inherent_data;

let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
set_default_ss58_version(chain_spec);
ensure_dev(chain_spec).map_err(Error::Other)?;

#[cfg(feature = "rococo-native")]
if chain_spec.is_rococo() || chain_spec.is_wococo() || chain_spec.is_versi() {
return Ok(runner.async_run(|mut config| {
let (client, _, _, task_manager) = service::new_chain_ops(&mut config, None)?;

let header = client.header(BlockId::Number(0_u32.into())).unwrap().unwrap();
let inherent_data = benchmark_inherent_data(header)
.map_err(|e| format!("generating inherent data: {:?}", e))?;

if let polkadot_client::Client::Rococo(pd) = &*client {
Ok((
cmd.run(config, pd.clone(), inherent_data, client)
.map_err(Error::SubstrateCli),
task_manager,
))
} else {
unreachable!("Checked above; qed")
}
})?)
}

#[cfg(feature = "kusama-native")]
if chain_spec.is_kusama() {
return Ok(runner.async_run(|mut config| {
let (client, _, _, task_manager) = service::new_chain_ops(&mut config, None)?;

let header = client.header(BlockId::Number(0_u32.into())).unwrap().unwrap();
let inherent_data = benchmark_inherent_data(header)
.map_err(|e| format!("generating inherent data: {:?}", e))?;

if let polkadot_client::Client::Kusama(pd) = &*client {
Ok((
cmd.run(config, pd.clone(), inherent_data, client)
.map_err(Error::SubstrateCli),
task_manager,
))
} else {
unreachable!("Checked above; qed")
}
})?)
}

#[cfg(feature = "westend-native")]
if chain_spec.is_westend() {
return Ok(runner.async_run(|mut config| {
let (client, _, _, task_manager) = service::new_chain_ops(&mut config, None)?;

let header = client.header(BlockId::Number(0_u32.into())).unwrap().unwrap();
let inherent_data = benchmark_inherent_data(header)
.map_err(|e| format!("generating inherent data: {:?}", e))?;

if let polkadot_client::Client::Westend(pd) = &*client {
Ok((
cmd.run(config, pd.clone(), inherent_data, client)
.map_err(Error::SubstrateCli),
task_manager,
))
} else {
unreachable!("Checked above; qed")
}
})?)
}

#[cfg(feature = "polkadot-native")]
{
return Ok(runner.async_run(|mut config| {
let (client, _, _, task_manager) = service::new_chain_ops(&mut config, None)?;

let header = client.header(BlockId::Number(0_u32.into())).unwrap().unwrap();
let inherent_data = benchmark_inherent_data(header)
.map_err(|e| format!("generating inherent data: {:?}", e))?;

if let polkadot_client::Client::Polkadot(pd) = &*client {
Ok((
cmd.run(config, pd.clone(), inherent_data, client)
.map_err(Error::SubstrateCli),
task_manager,
))
} else {
unreachable!("Checked above; qed")
}
})?)
}

#[cfg(not(feature = "polkadot-native"))]
unreachable!("No runtime feature (polkadot, kusama, westend, rococo) is enabled")
},
Some(Subcommand::BenchmarkStorage(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
Expand Down
10 changes: 10 additions & 0 deletions node/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ edition = "2021"

[dependencies]
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-system = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master" }

sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-storage = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-authority-discovery = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand All @@ -37,7 +44,10 @@ kusama-runtime = { path = "../../runtime/kusama", optional = true }
westend-runtime = { path = "../../runtime/westend", optional = true }
rococo-runtime = { path = "../../runtime/rococo", optional = true }

polkadot-core-primitives = { path = "../../core-primitives" }
polkadot-primitives = { path = "../../primitives" }
polkadot-node-core-parachains-inherent = { path = "../core/parachains-inherent" }
polkadot-runtime-common = { path = "../../runtime/common" }

[features]
default = ["polkadot"]
Expand Down
Loading

0 comments on commit dfaac46

Please sign in to comment.