Skip to content

Commit 8236ced

Browse files
committed
feat: emit perf data in pipe mode
1 parent 6aebb17 commit 8236ced

File tree

1 file changed

+9
-5
lines changed
  • src/run/runner/wall_time/perf

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub mod perf_map;
4141
pub mod unwind_data;
4242

4343
const PERF_METADATA_CURRENT_VERSION: u64 = 1;
44-
const PERF_DATA_PATH: &str = "/tmp/perf.data";
44+
const PERF_DATA_PATH: &str = "/tmp/perf.pipedata";
4545

4646
pub struct PerfRunner {
4747
benchmark_data: OnceCell<BenchmarkData>,
@@ -139,12 +139,16 @@ impl PerfRunner {
139139
perf_fifo.ctl_fifo_path.to_string_lossy(),
140140
perf_fifo.ack_fifo_path.to_string_lossy()
141141
),
142-
&format!("--output={PERF_DATA_PATH}"),
142+
"-o",
143+
"-", // forces pipe mode
143144
"--",
144145
]);
145146
cmd_builder.wrap_with(perf_wrapper_builder);
146-
let cmd = wrap_with_sudo(cmd_builder)?.build();
147-
debug!("cmd: {cmd:?}");
147+
let raw_command = format!("{} | cat > PERF_DATA_PATH", &cmd_builder.as_command_line());
148+
let mut wrapped_builder = CommandBuilder::new("sh");
149+
wrapped_builder.args(["-c", &raw_command]);
150+
let cmd = wrap_with_sudo(wrapped_builder)?.build();
151+
println!("cmd: {cmd:?}");
148152

149153
let on_process_started = async |_| -> anyhow::Result<()> {
150154
let data = Self::handle_fifo(runner_fifo, perf_fifo).await?;
@@ -174,7 +178,7 @@ impl PerfRunner {
174178
)?;
175179

176180
// Copy the perf data to the profile folder
177-
let perf_data_dest = profile_folder.join("perf.data");
181+
let perf_data_dest = profile_folder.join("perf.pipedata");
178182
std::fs::copy(PERF_DATA_PATH, &perf_data_dest)
179183
.with_context(|| format!("Failed to copy perf data to {perf_data_dest:?}",))?;
180184

0 commit comments

Comments
 (0)