Skip to content
Closed
Changes from all 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
37 changes: 19 additions & 18 deletions src/run/runner/wall_time/perf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand All @@ -355,10 +345,21 @@ impl PerfRunner {
.parse::<u32>()
.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?;
}
Expand Down