Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,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
Expand Down
10 changes: 10 additions & 0 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ pub struct RunCmd {
/// commonly `127.0.0.1:4040`.
#[clap(long)]
pub pyroscope_server: Option<String>,

/// 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 disable_hardware_benchmarks: bool,
}

#[allow(missing_docs)]
Expand Down
10 changes: 10 additions & 0 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ where
};

runner.run_node_until_exit(move |config| async move {
let hwbench = if !cli.run.disable_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 {
Expand All @@ -293,6 +302,7 @@ where
None,
false,
overseer_gen,
hwbench,
)
.map(|full| full.task_manager)
.map_err(Into::into),
Expand Down
1 change: 1 addition & 0 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
19 changes: 19 additions & 0 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ pub fn new_full<RuntimeApi, ExecutorDispatch, OverseerGenerator>(
program_path: Option<std::path::PathBuf>,
overseer_enable_anyways: bool,
overseer_gen: OverseerGenerator,
hwbench: Option<sc_sysinfo::HwBench>,
) -> Result<NewFull<Arc<FullClient<RuntimeApi, ExecutorDispatch>>>, Error>
where
RuntimeApi: ConstructRuntimeApi<Block, FullClient<RuntimeApi, ExecutorDispatch>>
Expand Down Expand Up @@ -919,6 +920,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();
Expand Down Expand Up @@ -1288,6 +1302,7 @@ pub fn build_full(
telemetry_worker_handle: Option<TelemetryWorkerHandle>,
overseer_enable_anyways: bool,
overseer_gen: impl OverseerGen,
hwbench: Option<sc_sysinfo::HwBench>,
) -> Result<NewFull<Client>, Error> {
#[cfg(feature = "rococo-native")]
if config.chain_spec.is_rococo() ||
Expand All @@ -1304,6 +1319,7 @@ pub fn build_full(
None,
overseer_enable_anyways,
overseer_gen,
hwbench,
)
.map(|full| full.with_client(Client::Rococo))
}
Expand All @@ -1320,6 +1336,7 @@ pub fn build_full(
None,
overseer_enable_anyways,
overseer_gen,
hwbench,
)
.map(|full| full.with_client(Client::Kusama))
}
Expand All @@ -1336,6 +1353,7 @@ pub fn build_full(
None,
overseer_enable_anyways,
overseer_gen,
hwbench,
)
.map(|full| full.with_client(Client::Westend))
}
Expand All @@ -1352,6 +1370,7 @@ pub fn build_full(
None,
overseer_enable_anyways,
overseer_gen,
hwbench,
)
.map(|full| full.with_client(Client::Polkadot))
}
Expand Down
2 changes: 2 additions & 0 deletions tests/purge_chain_works.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ async fn purge_chain_rocksdb_works() {
.arg(tmpdir.path())
.arg("--port")
.arg("33034")
.arg("--disable-hardware-benchmarks")
.spawn()
.unwrap();

Expand Down Expand Up @@ -78,6 +79,7 @@ async fn purge_chain_paritydb_works() {
.arg(tmpdir.path())
.arg("--database")
.arg("paritydb-experimental")
.arg("--disable-hardware-benchmarks")
.spawn()
.unwrap();

Expand Down
1 change: 1 addition & 0 deletions tests/running_the_node_and_interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("--disable-hardware-benchmarks")
.spawn()
.unwrap();

Expand Down