diff --git a/src/run/runner/wall_time/perf/mod.rs b/src/run/runner/wall_time/perf/mod.rs index e0db17e1..5210cd2d 100644 --- a/src/run/runner/wall_time/perf/mod.rs +++ b/src/run/runner/wall_time/perf/mod.rs @@ -125,7 +125,7 @@ impl PerfRunner { "sh", "-c", &format!( - "perf record {quiet_flag} --user-callchains --freq=999 --switch-output --control=fifo:{},{} --delay=-1 -g --call-graph={cg_mode} --output={} -- {bench_cmd}", + "perf record {quiet_flag} --timestamp -k CLOCK_MONOTONIC --user-callchains --freq=999 --switch-output --control=fifo:{},{} --delay=-1 -g --call-graph={cg_mode} --output={} -- {bench_cmd}", perf_fifo.ctl_fifo_path.to_string_lossy(), perf_fifo.ack_fifo_path.to_string_lossy(), perf_file.path().to_string_lossy(), @@ -167,9 +167,11 @@ impl PerfRunner { .unwrap_or(false) }) .sorted_by_key(|path| path.file_name().unwrap().to_string_lossy().to_string()) - // The first perf.data will only contain metadata that is not relevant to the benchmarks. We - // capture the symbols and unwind data separately. + // We split the perf.data in SetExecutedBenchmark which will also split the last + // entry, which will add an extra perf.data file that is empty. We can just skip it. + .rev() .skip(1) + .rev() .map(|src_path| { let profile_folder = profile_folder.clone(); tokio::task::spawn(async move { @@ -330,19 +332,7 @@ impl PerfRunner { FifoCommand::CurrentBenchmark { pid, uri } => { bench_order_by_pid.entry(pid).or_default().push(uri); - #[cfg(target_os = "linux")] - if !symbols_by_pid.contains_key(&pid) && !unwind_data_by_pid.contains_key(&pid) - { - Self::process_memory_mappings( - pid, - &mut symbols_by_pid, - &mut unwind_data_by_pid, - )?; - } - - runner_fifo.send_cmd(FifoCommand::Ack).await?; - } - FifoCommand::StartBenchmark => { + // Split the perf.data file let perf_pid = perf_pid.get_or_init(|| { let output = std::process::Command::new("sh") .arg("-c") @@ -355,10 +345,21 @@ impl PerfRunner { .parse::() .expect("Failed to parse perf pid") }); - - // Split the perf.data file run_with_sudo(&["kill", "-USR2", &perf_pid.to_string()])?; + #[cfg(target_os = "linux")] + if !symbols_by_pid.contains_key(&pid) && !unwind_data_by_pid.contains_key(&pid) + { + Self::process_memory_mappings( + pid, + &mut symbols_by_pid, + &mut unwind_data_by_pid, + )?; + } + + runner_fifo.send_cmd(FifoCommand::Ack).await?; + } + FifoCommand::StartBenchmark => { perf_fifo.start_events().await?; runner_fifo.send_cmd(FifoCommand::Ack).await?; }