Skip to content

Commit eb3db98

Browse files
feat: use rayon to collect perf walltime data
1 parent cf8e653 commit eb3db98

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ itertools = { workspace = true }
1717
lazy_static = "1.4.0"
1818
log = { workspace = true }
1919
rand = "0.8.5"
20+
rayon = "1.10"
2021
regex = "1.10.2"
2122
semver = "1.0"
2223
reqwest = { version = "0.11.22", features = [

src/executor/wall_time/perf/mod.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use anyhow::Context;
1919
use fifo::PerfFifo;
2020
use libc::pid_t;
2121
use perf_map::ProcessSymbols;
22+
use rayon::prelude::*;
2223
use runner_shared::artifacts::ArtifactExt;
2324
use runner_shared::artifacts::ExecutionTimestamps;
2425
use runner_shared::debug_info::ModuleDebugInfo;
@@ -362,24 +363,22 @@ impl BenchmarkData {
362363
(&self.symbols_by_pid, &self.unwind_data_by_pid)
363364
};
364365

365-
for proc_sym in symbols_by_pid.values() {
366-
proc_sym.save_to(&path).unwrap();
367-
}
366+
let path_ref = path.as_ref();
367+
symbols_by_pid.par_iter().for_each(|(_, proc_sym)| {
368+
proc_sym.save_to(path_ref).unwrap();
369+
});
368370

369371
// Collect debug info for each process by looking up file/line for symbols
370-
let mut debug_info_by_pid = HashMap::<i32, Vec<ModuleDebugInfo>>::new();
371-
for (pid, proc_sym) in symbols_by_pid {
372-
debug_info_by_pid
373-
.entry(*pid)
374-
.or_default()
375-
.extend(ProcessDebugInfo::new(proc_sym).modules());
376-
}
377-
378-
for (pid, modules) in unwind_data_by_pid {
379-
for module in modules {
380-
module.save_to(&path, *pid).unwrap();
381-
}
382-
}
372+
let debug_info_by_pid: HashMap<i32, Vec<ModuleDebugInfo>> = symbols_by_pid
373+
.par_iter()
374+
.map(|(pid, proc_sym)| (*pid, ProcessDebugInfo::new(proc_sym).modules()))
375+
.collect();
376+
377+
unwind_data_by_pid.par_iter().for_each(|(pid, modules)| {
378+
modules.iter().for_each(|module| {
379+
module.save_to(path_ref, *pid).unwrap();
380+
});
381+
});
383382

384383
#[allow(deprecated)]
385384
let metadata = PerfMetadata {

0 commit comments

Comments
 (0)