From 9f62198f02df190afd37446d9ddd04effbeb8abd Mon Sep 17 00:00:00 2001 From: not-matthias Date: Fri, 26 Jun 2026 17:42:22 +0200 Subject: [PATCH] feat: add experimental --exclude-allocations setting Add an experimental `--exclude-allocations` flag (env `CODSPEED_EXCLUDE_ALLOCATIONS`) that signals the backend to exclude memory allocation time from simulation results. The value is surfaced as `runner.excludeAllocations` in the upload metadata so the backend can gate comparability and history on it: runs with different values are not comparable. The field is additive, so the metadata version stays at 10 and older payloads remain compatible. COD-3016 --- src/cli/exec/mod.rs | 1 + src/cli/experimental.rs | 16 ++++++++++++++++ src/cli/run/mod.rs | 2 ++ src/executor/config.rs | 6 ++++++ src/run_environment/provider.rs | 1 + src/upload/interfaces.rs | 7 +++++++ src/upload/upload_metadata.rs | 2 ++ 7 files changed, 35 insertions(+) diff --git a/src/cli/exec/mod.rs b/src/cli/exec/mod.rs index f006bddf..c626b97f 100644 --- a/src/cli/exec/mod.rs +++ b/src/cli/exec/mod.rs @@ -90,6 +90,7 @@ fn build_orchestrator_config( extra_env: HashMap::new(), fair_sched: args.shared.experimental.experimental_fair_sched, cycle_estimation: args.shared.experimental.cycle_estimation, + exclude_allocations: args.shared.experimental.exclude_allocations, }) } diff --git a/src/cli/experimental.rs b/src/cli/experimental.rs index a89d0e29..ab021580 100644 --- a/src/cli/experimental.rs +++ b/src/cli/experimental.rs @@ -25,6 +25,19 @@ pub struct ExperimentalArgs { env = "CODSPEED_CYCLE_ESTIMATION" )] pub cycle_estimation: bool, + + /// Exclude memory allocation time from simulation results. + /// + /// Signals the backend to parse and subtract allocator time when interpreting + /// the run. Runs with different values are not comparable, so the value is part + /// of the run's measurement configuration. + #[arg( + long, + default_value_t = false, + help_heading = "Experimental", + env = "CODSPEED_EXCLUDE_ALLOCATIONS" + )] + pub exclude_allocations: bool, } impl ExperimentalArgs { @@ -37,6 +50,9 @@ impl ExperimentalArgs { if self.cycle_estimation { flags.push("--cycle-estimation"); } + if self.exclude_allocations { + flags.push("--exclude-allocations"); + } flags } diff --git a/src/cli/run/mod.rs b/src/cli/run/mod.rs index 6c9d5ebf..8edc2116 100644 --- a/src/cli/run/mod.rs +++ b/src/cli/run/mod.rs @@ -79,6 +79,7 @@ impl RunArgs { experimental: ExperimentalArgs { experimental_fair_sched: false, cycle_estimation: false, + exclude_allocations: false, }, }, instruments: vec![], @@ -129,6 +130,7 @@ fn build_orchestrator_config( extra_env: HashMap::new(), fair_sched: args.shared.experimental.experimental_fair_sched, cycle_estimation: args.shared.experimental.cycle_estimation, + exclude_allocations: args.shared.experimental.exclude_allocations, }) } diff --git a/src/executor/config.rs b/src/executor/config.rs index 3fcdfb6a..cb7e014b 100644 --- a/src/executor/config.rs +++ b/src/executor/config.rs @@ -93,6 +93,8 @@ pub struct OrchestratorConfig { pub fair_sched: bool, /// Enable valgrind's --cycle-estimation option. pub cycle_estimation: bool, + /// Signal the backend to exclude memory allocation time from simulation results. + pub exclude_allocations: bool, } /// Per-execution configuration passed to executors. @@ -128,6 +130,8 @@ pub struct ExecutorConfig { pub fair_sched: bool, /// Enable valgrind's --cycle-estimation option. pub cycle_estimation: bool, + /// Signal the backend to exclude memory allocation time from simulation results. + pub exclude_allocations: bool, } #[derive(Debug, Clone, PartialEq)] @@ -198,6 +202,7 @@ impl OrchestratorConfig { enable_introspection, fair_sched: self.fair_sched, cycle_estimation: self.cycle_estimation, + exclude_allocations: self.exclude_allocations, } } } @@ -231,6 +236,7 @@ impl OrchestratorConfig { extra_env: HashMap::new(), fair_sched: false, cycle_estimation: false, + exclude_allocations: false, } } } diff --git a/src/run_environment/provider.rs b/src/run_environment/provider.rs index b71f0e3a..317ac217 100644 --- a/src/run_environment/provider.rs +++ b/src/run_environment/provider.rs @@ -140,6 +140,7 @@ pub trait RunEnvironmentProvider { version: crate::VERSION.into(), instruments: config.instruments.get_active_instrument_names(), executor: executor_name, + exclude_allocations: config.exclude_allocations, system_info: system_info.clone(), }, run_environment: self.get_run_environment(), diff --git a/src/upload/interfaces.rs b/src/upload/interfaces.rs index e07c4525..3b874af3 100644 --- a/src/upload/interfaces.rs +++ b/src/upload/interfaces.rs @@ -31,6 +31,13 @@ pub struct Runner { pub version: String, pub instruments: Vec, pub executor: ExecutorName, + /// Whether memory allocation time is excluded from results. Part of the run's + /// measurement configuration: runs with different values are not comparable. + /// + /// Skipped when `false` so the default payload stays byte-identical to runs + /// without this feature, keeping the metadata hash and version unchanged. + #[serde(skip_serializing_if = "std::ops::Not::not")] + pub exclude_allocations: bool, #[serde(flatten)] pub system_info: SystemInfo, } diff --git a/src/upload/upload_metadata.rs b/src/upload/upload_metadata.rs index fd64758e..81bdd9b7 100644 --- a/src/upload/upload_metadata.rs +++ b/src/upload/upload_metadata.rs @@ -37,6 +37,7 @@ mod tests { version: "2.1.0".into(), instruments: vec![InstrumentName::MongoDB], executor: ExecutorName::Valgrind, + exclude_allocations: false, system_info: SystemInfo::test(), }, run_environment: RunEnvironment::GithubActions, @@ -95,6 +96,7 @@ mod tests { version: "4.11.1".into(), instruments: vec![], executor: ExecutorName::Valgrind, + exclude_allocations: false, system_info: SystemInfo { os: crate::system::SupportedOs::Linux( crate::system::LinuxDistribution::Other {