Skip to content

Commit

Permalink
part-bench: cool down for 4s between runs
Browse files Browse the repository at this point in the history
part-bench pins the rayon threads to CPU cores, so that runs at lower
thread counts are not affected by how memory is laid out.  On strong
scaling runs, this can cause overheating since the first cores are
working the most, while the later ones start fresh.
  • Loading branch information
hhirtz committed Jun 13, 2022
1 parent b6b1c43 commit a136e53
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tools/src/bin/part-bench/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use mesh_io::weight;
use std::env;
use std::fs;
use std::io;
use std::thread::sleep;
use std::time::Duration;

const USAGE: &str = "Usage: part-bench [options]";

Expand Down Expand Up @@ -135,11 +137,16 @@ fn main_d<const D: usize>(
let max_threads = rayon::current_num_threads();
let mut g = c.benchmark_group(benchmark_name);
let mut thread_count = 1;
while thread_count <= max_threads {
loop {
let pool = build_pool(thread_count);
let benchmark_name = format!("threads={thread_count}");
g.bench_function(&benchmark_name, |b| pool.install(|| b.iter(&mut benchmark)));
thread_count *= 2;
if max_threads < thread_count {
break;
}
println!("Waiting 4s for CPUs to cool down...");
sleep(Duration::from_secs(4));
}
} else {
c.bench_function(&benchmark_name, |b| b.iter(&mut benchmark));
Expand Down

0 comments on commit a136e53

Please sign in to comment.