Skip to content

Commit b66f530

Browse files
committed
chore: wip [skip ci]
1 parent 2c7507f commit b66f530

2 files changed

Lines changed: 14 additions & 18 deletions

File tree

src/run/runner/wall_time/perf/mod.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl PerfRunner {
125125
"sh",
126126
"-c",
127127
&format!(
128-
"perf record {quiet_flag} --user-callchains --freq=999 --switch-output --control=fifo:{},{} --delay=-1 -g --call-graph={cg_mode} --output={} -- {bench_cmd}",
128+
"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}",
129129
perf_fifo.ctl_fifo_path.to_string_lossy(),
130130
perf_fifo.ack_fifo_path.to_string_lossy(),
131131
perf_file.path().to_string_lossy(),
@@ -305,10 +305,11 @@ impl PerfRunner {
305305
let mut bench_order_by_pid = HashMap::<u32, Vec<String>>::new();
306306
let mut symbols_by_pid = HashMap::<u32, ProcessSymbols>::new();
307307
let mut unwind_data_by_pid = HashMap::<u32, Vec<UnwindData>>::new();
308+
let mut markers_by_pid = HashMap::<u32, Vec<MarkerType>>::new();
309+
308310
let mut integration = None;
309311
let mut perf_ping_timeout = 5;
310312

311-
let perf_pid = OnceCell::new();
312313
loop {
313314
let perf_ping =
314315
tokio::time::timeout(Duration::from_secs(perf_ping_timeout), perf_fifo.ping())
@@ -343,22 +344,6 @@ impl PerfRunner {
343344
runner_fifo.send_cmd(FifoCommand::Ack).await?;
344345
}
345346
FifoCommand::StartBenchmark => {
346-
let perf_pid = perf_pid.get_or_init(|| {
347-
let output = std::process::Command::new("sh")
348-
.arg("-c")
349-
.arg("pidof -s perf")
350-
.output()
351-
.expect("Failed to run pidof command");
352-
353-
String::from_utf8_lossy(&output.stdout)
354-
.trim()
355-
.parse::<u32>()
356-
.expect("Failed to parse perf pid")
357-
});
358-
359-
// Split the perf.data file
360-
run_with_sudo(&["kill", "-USR2", &perf_pid.to_string()])?;
361-
362347
perf_fifo.start_events().await?;
363348
runner_fifo.send_cmd(FifoCommand::Ack).await?;
364349
}
@@ -377,6 +362,10 @@ impl PerfRunner {
377362
integration = Some((name, version));
378363
runner_fifo.send_cmd(FifoCommand::Ack).await?;
379364
}
365+
FifoCommand::AddMarker { pid, marker } => {
366+
markers_by_pid.entry(pid).or_default().push(marker);
367+
runner_fifo.send_cmd(FifoCommand::Ack).await?;
368+
}
380369
FifoCommand::Ack => unreachable!(),
381370
FifoCommand::Err => unreachable!(),
382371
}

src/run/runner/wall_time/perf/shared.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
pub const RUNNER_CTL_FIFO: &str = "/tmp/runner.ctl.fifo";
44
pub const RUNNER_ACK_FIFO: &str = "/tmp/runner.ack.fifo";
55

6+
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq)]
7+
pub enum MarkerType {
8+
BenchmarkStart(u64),
9+
BenchmarkEnd(u64),
10+
}
11+
612
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq)]
713
pub enum Command {
814
CurrentBenchmark { pid: u32, uri: String },
@@ -12,4 +18,5 @@ pub enum Command {
1218
PingPerf,
1319
SetIntegration { name: String, version: String },
1420
Err,
21+
AddMarker { pid: u32, marker: MarkerType },
1522
}

0 commit comments

Comments
 (0)