@@ -2,9 +2,11 @@ use super::perf::PerfRunner;
22use crate :: prelude:: * ;
33use crate :: run:: instruments:: mongo_tracer:: MongoTracer ;
44use crate :: run:: runner:: executor:: Executor ;
5+ use crate :: run:: runner:: helpers:: env:: get_base_injected_env;
56use crate :: run:: runner:: helpers:: get_bench_command:: get_bench_command;
67use crate :: run:: runner:: helpers:: run_command_with_log_pipe:: run_command_with_log_pipe;
78use crate :: run:: runner:: { ExecutorName , RunData } ;
9+ use crate :: run:: RunnerMode ;
810use crate :: run:: { check_system:: SystemInfo , config:: Config } ;
911use async_trait:: async_trait;
1012use std:: fs:: canonicalize;
@@ -27,6 +29,18 @@ impl WallTimeExecutor {
2729 perf : use_perf. then ( PerfRunner :: new) ,
2830 }
2931 }
32+
33+ fn walltime_bench_cmd ( config : & Config , run_data : & RunData ) -> Result < String > {
34+ let bench_cmd = get_bench_command ( config) ?;
35+
36+ let setenv = get_base_injected_env ( RunnerMode :: Walltime , & run_data. profile_folder )
37+ . into_iter ( )
38+ . map ( |( env, value) | format ! ( "--setenv={env}={value}" ) )
39+ . join ( " " ) ;
40+ let uid = nix:: unistd:: Uid :: current ( ) . as_raw ( ) ;
41+ let gid = nix:: unistd:: Gid :: current ( ) . as_raw ( ) ;
42+ Ok ( format ! ( "sudo systemd-run --scope --slice=codspeed.slice --same-dir --uid={uid} --gid={gid} {setenv} -- {bench_cmd}" ) )
43+ }
3044}
3145
3246#[ async_trait( ?Send ) ]
@@ -50,18 +64,16 @@ impl Executor for WallTimeExecutor {
5064 run_data : & RunData ,
5165 _mongo_tracer : & Option < MongoTracer > ,
5266 ) -> Result < ( ) > {
53- // IMPORTANT: Don't use `sh` here! We will use this pid to send signals to the
54- // spawned child process which won't work if we use a different shell.
55- let mut cmd = Command :: new ( "bash" ) ;
67+ let mut cmd = Command :: new ( "sh" ) ;
5668
5769 if let Some ( cwd) = & config. working_directory {
5870 let abs_cwd = canonicalize ( cwd) ?;
5971 cmd. current_dir ( abs_cwd) ;
6072 }
6173
62- let bench_cmd = get_bench_command ( config) ?;
74+ let bench_cmd = Self :: walltime_bench_cmd ( config, run_data ) ?;
6375 let status = if let Some ( perf) = & self . perf {
64- perf. run ( cmd, & bench_cmd, run_data ) . await
76+ perf. run ( cmd, & bench_cmd) . await
6577 } else {
6678 cmd. args ( [ "-c" , & bench_cmd] ) ;
6779 debug ! ( "cmd: {:?}" , cmd) ;
0 commit comments