(
execution_context: &ExecutionContext,
)
| 42 | |
| 43 | impl MemoryExecutor { |
| 44 | fn build_memtrack_command( |
| 45 | execution_context: &ExecutionContext, |
| 46 | ) -> Result<(MemtrackIpcServer, CommandBuilder, NamedTempFile)> { |
| 47 | let mut extra_env = get_base_injected_env( |
| 48 | RunnerMode::Memory, |
| 49 | &execution_context.profile_folder, |
| 50 | &execution_context.config, |
| 51 | ); |
| 52 | |
| 53 | extra_env.insert( |
| 54 | "PATH".into(), |
| 55 | build_path_env(execution_context.config.enable_introspection)?, |
| 56 | ); |
| 57 | |
| 58 | // Setup memtrack IPC server |
| 59 | let (ipc_server, server_name) = ipc::IpcOneShotServer::new()?; |
| 60 | |
| 61 | // A file-capability binary runs in glibc secure-execution mode, which strips |
| 62 | // LD_* variables. The forwarded environment has to be re-sourced below that |
| 63 | // boundary, inside the benchmark, to survive. |
| 64 | let bench_command = get_bench_command(&execution_context.config)?; |
| 65 | let (bench_command, env_file) = prefix_command_with_env(&bench_command, &extra_env)?; |
| 66 | |
| 67 | let mut cmd_builder = InternalCommands::Memtrack(MemtrackArgs { args: vec![] }) |
| 68 | .command_builder_for(memtrack_path()?); |
| 69 | if execution_context.config.memory_track_physical { |
| 70 | cmd_builder.env("CODSPEED_MEMTRACK_TRACK_PHYSICAL", "1"); |
| 71 | } |
| 72 | cmd_builder.arg("track"); |
| 73 | cmd_builder.arg("--output"); |
| 74 | cmd_builder.arg(execution_context.profile_folder.join("results")); |
| 75 | cmd_builder.arg("--ipc-server"); |
| 76 | cmd_builder.arg(server_name); |
| 77 | cmd_builder.arg(bench_command); |
| 78 | if execution_context.config.memory_capture_stack { |
| 79 | cmd_builder.env("CODSPEED_MEMTRACK_CAPTURE_STACKS", "1"); |
| 80 | } |
| 81 | |
| 82 | // Set working directory if specified |
| 83 | if let Some(cwd) = &execution_context.config.working_directory { |
| 84 | let abs_cwd = canonicalize(cwd)?; |
| 85 | cmd_builder.current_dir(abs_cwd); |
| 86 | } |
| 87 | |
| 88 | Ok((ipc_server, cmd_builder, env_file)) |
| 89 | } |
| 90 | |
| 91 | /// Ensure memtrack can load its eBPF programs: either run as root, hold the |
| 92 | /// required file capabilities, or be handed a delegated BPF token. Tries a |
nothing calls this directly
no test coverage detected