diff --git a/src/cli/exec/mod.rs b/src/cli/exec/mod.rs index 4a757f74..a844cc6b 100644 --- a/src/cli/exec/mod.rs +++ b/src/cli/exec/mod.rs @@ -93,6 +93,7 @@ fn build_orchestrator_config( cycle_estimation: args.shared.cycle_estimation, exclude_allocations: args.shared.exclude_allocations, simulation_track_subprocess: args.shared.simulation_track_subprocess, + memory_track_physical: args.shared.experimental.experimental_memory_track_physical, }) } diff --git a/src/cli/experimental.rs b/src/cli/experimental.rs index 74aab817..336093b3 100644 --- a/src/cli/experimental.rs +++ b/src/cli/experimental.rs @@ -17,6 +17,16 @@ pub struct ExperimentalArgs { )] pub experimental_fair_sched: bool, + /// Enable physical (resident) memory tracking in memory mode. + #[arg( + long, + default_value_t = false, + help_heading = "Experimental", + env = "CODSPEED_MEMTRACK_TRACK_PHYSICAL", + value_parser = clap::builder::FalseyValueParser::new() + )] + pub experimental_memory_track_physical: bool, + /// Deprecated: cycle estimation is enabled by default and this flag has no effect. #[arg(long, hide = true, env = "CODSPEED_EXPERIMENTAL_CYCLE_ESTIMATION")] pub experimental_cycle_estimation: bool, @@ -33,6 +43,9 @@ impl ExperimentalArgs { if self.experimental_fair_sched { flags.push("--experimental-fair-sched"); } + if self.experimental_memory_track_physical { + flags.push("--experimental-memory-track-physical"); + } flags } diff --git a/src/cli/run/mod.rs b/src/cli/run/mod.rs index a218155c..414e04f8 100644 --- a/src/cli/run/mod.rs +++ b/src/cli/run/mod.rs @@ -83,6 +83,7 @@ impl RunArgs { experimental_fair_sched: false, experimental_cycle_estimation: false, experimental_exclude_allocations: false, + experimental_memory_track_physical: false, }, }, instruments: vec![], @@ -135,6 +136,7 @@ fn build_orchestrator_config( cycle_estimation: args.shared.cycle_estimation, exclude_allocations: args.shared.exclude_allocations, simulation_track_subprocess: args.shared.simulation_track_subprocess, + memory_track_physical: args.shared.experimental.experimental_memory_track_physical, }) } diff --git a/src/executor/config.rs b/src/executor/config.rs index 07f99c82..39f95851 100644 --- a/src/executor/config.rs +++ b/src/executor/config.rs @@ -98,6 +98,8 @@ pub struct OrchestratorConfig { /// Inherit valgrind's instrumentation state across a traced exec, so the cost of /// subprocesses spawned by a benchmark is measured too. pub simulation_track_subprocess: bool, + /// Enable physical (resident) memory tracking in memory mode. + pub memory_track_physical: bool, } /// Per-execution configuration passed to executors. @@ -138,6 +140,11 @@ pub struct ExecutorConfig { /// Inherit valgrind's instrumentation state across a traced exec, so the cost of /// subprocesses spawned by a benchmark is measured too. pub simulation_track_subprocess: bool, + /// Enable physical (resident) memory tracking in memory mode. + /// + /// Only read by the memory executor, which is Linux-only. + #[cfg_attr(not(target_os = "linux"), allow(dead_code))] + pub memory_track_physical: bool, } #[derive(Debug, Clone, PartialEq)] @@ -210,6 +217,7 @@ impl OrchestratorConfig { cycle_estimation: self.cycle_estimation, exclude_allocations: self.exclude_allocations, simulation_track_subprocess: self.simulation_track_subprocess, + memory_track_physical: self.memory_track_physical, } } } @@ -245,6 +253,7 @@ impl OrchestratorConfig { cycle_estimation: true, exclude_allocations: false, simulation_track_subprocess: false, + memory_track_physical: false, } } } diff --git a/src/executor/memory/executor.rs b/src/executor/memory/executor.rs index b8c9a398..6cbb0f97 100644 --- a/src/executor/memory/executor.rs +++ b/src/executor/memory/executor.rs @@ -63,6 +63,9 @@ impl MemoryExecutor { // Build the memtrack command let mut cmd_builder = CommandBuilder::new(MEMTRACK_COMMAND); + if execution_context.config.memory_track_physical { + cmd_builder.env("CODSPEED_MEMTRACK_TRACK_PHYSICAL", "1"); + } cmd_builder.arg("track"); cmd_builder.arg("--output"); cmd_builder.arg(execution_context.profile_folder.join("results"));