Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Print the number of expected cores
Signed-off-by: Alexandru Gheorghe <[email protected]>
  • Loading branch information
alexggh committed Sep 3, 2024
commit db943bc3294e5ac1107f7e95b2502f4c63f60540
5 changes: 4 additions & 1 deletion substrate/client/sysinfo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ pub struct HwBench {
/// BLAKE2b-256 hash.
#[serde(serialize_with = "serialize_throughput")]
pub parallel_cpu_hashrate_score: Throughput,
/// The number of expected cores used for computing the parallel CPU speed.
pub parallel_cpu_cores: usize,
/// Memory bandwidth in MB/s, calculated by measuring the throughput of `memcpy`.
#[serde(serialize_with = "serialize_throughput")]
pub memory_memcpy_score: Throughput,
Expand Down Expand Up @@ -138,9 +140,10 @@ pub fn print_sysinfo(sysinfo: &sc_telemetry::SysInfo) {
/// Prints out the results of the hardware benchmarks in the logs.
pub fn print_hwbench(hwbench: &HwBench) {
log::info!(
"🏁 CPU single core score: {}, parallelism score: {}",
"🏁 CPU single core score: {}, parallelism score: {} with expected cores: {}",
hwbench.cpu_hashrate_score,
hwbench.parallel_cpu_hashrate_score,
hwbench.parallel_cpu_cores,
);
log::info!("🏁 Memory score: {}", hwbench.memory_memcpy_score);

Expand Down
10 changes: 6 additions & 4 deletions substrate/client/sysinfo/src/sysinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,22 +664,23 @@ pub fn benchmark_sr25519_verify(limit: ExecutionLimit) -> Throughput {
/// boolean to specify if the node is an authority.
pub fn gather_hwbench(scratch_directory: Option<&Path>, requirements: &Requirements) -> HwBench {
let cpu_hashrate_score = benchmark_cpu(DEFAULT_CPU_EXECUTION_LIMIT);
let parallel_cpu_hashrate_score = requirements
let (parallel_cpu_hashrate_score, parallel_cpu_cores) = requirements
.0
.iter()
.filter_map(|req| {
if let Metric::Blake2256Parallel { num_cores } = req.metric {
Some(benchmark_cpu_parallelism(DEFAULT_CPU_EXECUTION_LIMIT, num_cores))
Some((benchmark_cpu_parallelism(DEFAULT_CPU_EXECUTION_LIMIT, num_cores), num_cores))
} else {
None
}
})
.next()
.unwrap_or(cpu_hashrate_score);
.unwrap_or((cpu_hashrate_score, 1));
#[allow(unused_mut)]
let mut hwbench = HwBench {
cpu_hashrate_score,
parallel_cpu_hashrate_score,
parallel_cpu_cores,
memory_memcpy_score: benchmark_memory(DEFAULT_MEMORY_EXECUTION_LIMIT),
disk_sequential_write_score: None,
disk_random_write_score: None,
Expand Down Expand Up @@ -857,13 +858,14 @@ mod tests {
let hwbench = HwBench {
cpu_hashrate_score: Throughput::from_gibs(1.32),
parallel_cpu_hashrate_score: Throughput::from_gibs(1.32),
parallel_cpu_cores: 4,
memory_memcpy_score: Throughput::from_kibs(9342.432),
disk_sequential_write_score: Some(Throughput::from_kibs(4332.12)),
disk_random_write_score: None,
};

let serialized = serde_json::to_string(&hwbench).unwrap();
// Throughput from all of the benchmarks should be converted to MiBs.
assert_eq!(serialized, "{\"cpu_hashrate_score\":1351,\"parallel_cpu_hashrate_score\":1351,\"memory_memcpy_score\":9,\"disk_sequential_write_score\":4}");
assert_eq!(serialized, "{\"cpu_hashrate_score\":1351,\"parallel_cpu_hashrate_score\":1351,\"parallel_cpu_cores\":4,\"memory_memcpy_score\":9,\"disk_sequential_write_score\":4}");
}
}