@@ -26,7 +26,7 @@ use runner_shared::fifo::MarkerType;
2626use runner_shared:: metadata:: PerfMetadata ;
2727use runner_shared:: unwind_data:: UnwindData ;
2828use std:: collections:: HashSet ;
29- use std:: path:: { Path , PathBuf } ;
29+ use std:: path:: Path ;
3030use std:: time:: Duration ;
3131use std:: { cell:: OnceCell , collections:: HashMap , process:: ExitStatus } ;
3232
@@ -41,7 +41,7 @@ pub mod perf_map;
4141pub mod unwind_data;
4242
4343const PERF_METADATA_CURRENT_VERSION : u64 = 1 ;
44- const PERF_DATA_PATH : & str = "/tmp/ perf.pipedata" ;
44+ const PERF_DATA_FILE_NAME : & str = "perf.pipedata" ;
4545
4646pub struct PerfRunner {
4747 benchmark_data : OnceCell < BenchmarkData > ,
@@ -89,6 +89,7 @@ impl PerfRunner {
8989 & self ,
9090 mut cmd_builder : CommandBuilder ,
9191 config : & Config ,
92+ profile_folder : & Path ,
9293 ) -> anyhow:: Result < ExitStatus > {
9394 let perf_fifo = PerfFifo :: new ( ) ?;
9495 let runner_fifo = RunnerFifo :: new ( ) ?;
@@ -144,7 +145,15 @@ impl PerfRunner {
144145 "--" ,
145146 ] ) ;
146147 cmd_builder. wrap_with ( perf_wrapper_builder) ;
147- let raw_command = format ! ( "{} | cat > PERF_DATA_PATH" , & cmd_builder. as_command_line( ) ) ;
148+
149+ // Copy the perf data to the profile folder
150+ let perf_data_file_path = profile_folder. join ( PERF_DATA_FILE_NAME ) ;
151+
152+ let raw_command = format ! (
153+ "{} | cat > {}" ,
154+ & cmd_builder. as_command_line( ) ,
155+ perf_data_file_path. to_string_lossy( )
156+ ) ;
148157 let mut wrapped_builder = CommandBuilder :: new ( "sh" ) ;
149158 wrapped_builder. args ( [ "-c" , & raw_command] ) ;
150159 let cmd = wrap_with_sudo ( wrapped_builder) ?. build ( ) ;
@@ -160,28 +169,9 @@ impl PerfRunner {
160169 run_command_with_log_pipe_and_callback ( cmd, on_process_started) . await
161170 }
162171
163- pub async fn save_files_to ( & self , profile_folder : & PathBuf ) -> anyhow:: Result < ( ) > {
172+ pub async fn save_files_to ( & self , profile_folder : & Path ) -> anyhow:: Result < ( ) > {
164173 let start = std:: time:: Instant :: now ( ) ;
165174
166- // We ran perf with sudo, so we have to change the ownership of the perf.data
167- run_with_sudo (
168- "chown" ,
169- [
170- "-R" ,
171- & format ! (
172- "{}:{}" ,
173- nix:: unistd:: Uid :: current( ) ,
174- nix:: unistd:: Gid :: current( )
175- ) ,
176- PERF_DATA_PATH ,
177- ] ,
178- ) ?;
179-
180- // Copy the perf data to the profile folder
181- let perf_data_dest = profile_folder. join ( "perf.pipedata" ) ;
182- std:: fs:: copy ( PERF_DATA_PATH , & perf_data_dest)
183- . with_context ( || format ! ( "Failed to copy perf data to {perf_data_dest:?}" , ) ) ?;
184-
185175 let bench_data = self
186176 . benchmark_data
187177 . get ( )
0 commit comments