diff --git a/Cargo.lock b/Cargo.lock index 664c7c90a72a..3c27877f67dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6422,6 +6422,7 @@ dependencies = [ "pyroscope", "sc-cli", "sc-service", + "sc-sysinfo", "sc-tracing", "sp-core", "sp-trie", @@ -7557,6 +7558,7 @@ dependencies = [ "sc-offchain", "sc-service", "sc-sync-state-rpc", + "sc-sysinfo", "sc-telemetry", "sc-transaction-pool", "serde", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 4d613b9874a0..ce8b1ec33688 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -32,6 +32,7 @@ sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", o sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } polkadot-node-metrics = { path = "../node/metrics" } sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true } +sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" } # this crate is used only to enable `trie-memory-tracker` feature # see https://github.com/paritytech/substrate/pull/6745 diff --git a/cli/src/cli.rs b/cli/src/cli.rs index e761ccd39310..cc449bd844ae 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -128,6 +128,16 @@ pub struct RunCmd { /// commonly `127.0.0.1:4040`. #[clap(long)] pub pyroscope_server: Option, + + /// Disable automatic hardware benchmarks. + /// + /// By default these benchmarks are automatically ran at startup and measure + /// the CPU speed, the memory bandwidth and the disk speed. + /// + /// The results are then printed out in the logs, and also sent as part of + /// telemetry, if telemetry is enabled. + #[clap(long)] + pub no_hardware_benchmarks: bool, } #[allow(missing_docs)] diff --git a/cli/src/command.rs b/cli/src/command.rs index 26a253d77af9..ad248db4eb50 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -302,6 +302,15 @@ where }; runner.run_node_until_exit(move |config| async move { + let hwbench = if !cli.run.no_hardware_benchmarks { + config.database.path().map(|database_path| { + let _ = std::fs::create_dir_all(&database_path); + sc_sysinfo::gather_hwbench(Some(database_path)) + }) + } else { + None + }; + let role = config.role.clone(); match role { @@ -315,6 +324,7 @@ where None, false, overseer_gen, + hwbench, ) .map(|full| full.task_manager) .map_err(Into::into), diff --git a/node/service/Cargo.toml b/node/service/Cargo.toml index bc997bc111af..76fcd8fcd789 100644 --- a/node/service/Cargo.toml +++ b/node/service/Cargo.toml @@ -25,6 +25,7 @@ sc-sync-state-rpc = { git = "https://github.com/paritytech/substrate", branch = sc-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-basic-authorship = { git = "https://github.com/paritytech/substrate", branch = "master" } sc-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" } +sc-sysinfo = { git = "https://github.com/paritytech/substrate", branch = "master" } service = { package = "sc-service", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } telemetry = { package = "sc-telemetry", git = "https://github.com/paritytech/substrate", branch = "master" } diff --git a/node/service/src/lib.rs b/node/service/src/lib.rs index 8059ff5230ab..abd106ef63ce 100644 --- a/node/service/src/lib.rs +++ b/node/service/src/lib.rs @@ -681,6 +681,7 @@ pub fn new_full( program_path: Option, overseer_enable_anyways: bool, overseer_gen: OverseerGenerator, + hwbench: Option, ) -> Result>>, Error> where RuntimeApi: ConstructRuntimeApi> @@ -920,6 +921,19 @@ where telemetry: telemetry.as_mut(), })?; + if let Some(hwbench) = hwbench { + sc_sysinfo::print_hwbench(&hwbench); + + if let Some(ref mut telemetry) = telemetry { + let telemetry_handle = telemetry.handle(); + task_manager.spawn_handle().spawn( + "telemetry_hwbench", + None, + sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench), + ); + } + } + let (block_import, link_half, babe_link, beefy_links) = import_setup; let overseer_client = client.clone(); @@ -1290,6 +1304,7 @@ pub fn build_full( telemetry_worker_handle: Option, overseer_enable_anyways: bool, overseer_gen: impl OverseerGen, + hwbench: Option, ) -> Result, Error> { #[cfg(feature = "rococo-native")] if config.chain_spec.is_rococo() || @@ -1306,6 +1321,7 @@ pub fn build_full( None, overseer_enable_anyways, overseer_gen, + hwbench, ) .map(|full| full.with_client(Client::Rococo)) } @@ -1322,6 +1338,7 @@ pub fn build_full( None, overseer_enable_anyways, overseer_gen, + hwbench, ) .map(|full| full.with_client(Client::Kusama)) } @@ -1338,6 +1355,7 @@ pub fn build_full( None, overseer_enable_anyways, overseer_gen, + hwbench, ) .map(|full| full.with_client(Client::Westend)) } @@ -1354,6 +1372,7 @@ pub fn build_full( None, overseer_enable_anyways, overseer_gen, + hwbench, ) .map(|full| full.with_client(Client::Polkadot)) } diff --git a/node/test/service/src/lib.rs b/node/test/service/src/lib.rs index 8cf75a75f62c..4ac3d765c82b 100644 --- a/node/test/service/src/lib.rs +++ b/node/test/service/src/lib.rs @@ -97,6 +97,7 @@ pub fn new_full( worker_program_path, false, polkadot_service::RealOverseerGen, + None, ) } diff --git a/parachain/test-parachains/adder/collator/src/main.rs b/parachain/test-parachains/adder/collator/src/main.rs index 57e4dea689e3..2b3e468d9b42 100644 --- a/parachain/test-parachains/adder/collator/src/main.rs +++ b/parachain/test-parachains/adder/collator/src/main.rs @@ -70,6 +70,7 @@ fn main() -> Result<()> { None, false, polkadot_service::RealOverseerGen, + None, ) .map_err(|e| e.to_string())?; let mut overseer_handle = full_node diff --git a/parachain/test-parachains/undying/collator/src/main.rs b/parachain/test-parachains/undying/collator/src/main.rs index d5abecdd93a4..5bacf927e4fb 100644 --- a/parachain/test-parachains/undying/collator/src/main.rs +++ b/parachain/test-parachains/undying/collator/src/main.rs @@ -70,6 +70,7 @@ fn main() -> Result<()> { None, false, polkadot_service::RealOverseerGen, + None, ) .map_err(|e| e.to_string())?; let mut overseer_handle = full_node diff --git a/tests/purge_chain_works.rs b/tests/purge_chain_works.rs index d0a12c1b6e1c..3e72a2e68e62 100644 --- a/tests/purge_chain_works.rs +++ b/tests/purge_chain_works.rs @@ -35,6 +35,7 @@ async fn purge_chain_rocksdb_works() { .arg(tmpdir.path()) .arg("--port") .arg("33034") + .arg("--no-hardware-benchmarks") .spawn() .unwrap(); @@ -78,6 +79,7 @@ async fn purge_chain_paritydb_works() { .arg(tmpdir.path()) .arg("--database") .arg("paritydb-experimental") + .arg("--no-hardware-benchmarks") .spawn() .unwrap(); diff --git a/tests/running_the_node_and_interrupt.rs b/tests/running_the_node_and_interrupt.rs index a27f13fcba56..f55e4e4c9eac 100644 --- a/tests/running_the_node_and_interrupt.rs +++ b/tests/running_the_node_and_interrupt.rs @@ -37,6 +37,7 @@ async fn running_the_node_works_and_can_be_interrupted() { let mut cmd = Command::new(cargo_bin("polkadot")) .args(&["--dev", "-d"]) .arg(tmpdir.path()) + .arg("--no-hardware-benchmarks") .spawn() .unwrap();