Skip to content

Commit 170795a

Browse files
committed
feat: run benchmark with systemd (for optional cpu isolation)
1 parent 9eb9fc8 commit 170795a

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object = "0.36.7"
5252
linux-perf-data = "0.11.0"
5353
debugid = "0.8.0"
5454
memmap2 = "0.9.5"
55-
nix = { version = "0.29.0", features = ["fs"] }
55+
nix = { version = "0.29.0", features = ["fs", "user"] }
5656
futures = "0.3.31"
5757

5858
[target.'cfg(target_os = "linux")'.dependencies]

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,16 @@ impl PerfRunner {
9696
};
9797
debug!("Using call graph mode: {}", cg_mode);
9898

99+
let user = nix::unistd::User::from_uid(nix::unistd::Uid::current())?.unwrap();
99100
cmd.args([
100101
"-c",
101102
&format!(
102-
"perf record --user-callchains --freq=999 --switch-output --control=fifo:{},{} --delay=-1 -g --call-graph={cg_mode} --output={} -- {bench_cmd}",
103+
"perf record --user-callchains --freq=999 --switch-output --control=fifo:{},{} --delay=-1 -g --call-graph={cg_mode} --output={} -- \
104+
sudo systemd-run --scope --slice=codspeed.slice --same-dir -- runuser -u {} -- {bench_cmd}",
103105
perf_fifo.ctl_fifo_path.to_string_lossy(),
104106
perf_fifo.ack_fifo_path.to_string_lossy(),
105-
perf_file.path().to_string_lossy()
107+
perf_file.path().to_string_lossy(),
108+
user.name
106109
),
107110
]);
108111
debug!("cmd: {:?}", cmd);

0 commit comments

Comments
 (0)