Skip to content

Commit 7348d3e

Browse files
committed
feat(walltime): rename CODSPEED_PERF_ENABLED to CODSPEED_PROFILER_ENABLED
Introduce --enable-profiler / CODSPEED_PROFILER_ENABLED as the canonical flag now that walltime profiling is profiler-agnostic. The legacy --enable-perf / CODSPEED_PERF_ENABLED is kept as a hidden alias and emits a deprecation warning when used, so existing configurations keep working.
1 parent 1b3b544 commit 7348d3e

7 files changed

Lines changed: 44 additions & 22 deletions

File tree

src/cli/exec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn build_orchestrator_config(
7878
modes,
7979
instruments: Instruments { mongodb: None }, // exec doesn't support MongoDB
8080
perf_unwinding_mode: args.shared.perf_run_args.perf_unwinding_mode,
81-
enable_perf: args.shared.perf_run_args.enable_perf,
81+
enable_profiler: args.shared.perf_run_args.resolve_enable_profiler(),
8282
simulation_tool: args.shared.simulation_tool.unwrap_or_default(),
8383
profile_folder: args.shared.profile_folder,
8484
skip_upload: args.shared.skip_upload,

src/cli/run/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ impl RunArgs {
7070
show_full_output: false,
7171
base: None,
7272
perf_run_args: PerfRunArgs {
73-
enable_perf: false,
73+
enable_profiler: false,
74+
enable_perf: None,
7475
perf_unwinding_mode: None,
7576
},
7677
experimental: ExperimentalArgs {
@@ -112,7 +113,7 @@ fn build_orchestrator_config(
112113
modes,
113114
instruments,
114115
perf_unwinding_mode: args.shared.perf_run_args.perf_unwinding_mode,
115-
enable_perf: args.shared.perf_run_args.enable_perf,
116+
enable_profiler: args.shared.perf_run_args.resolve_enable_profiler(),
116117
simulation_tool: args.shared.simulation_tool.unwrap_or_default(),
117118
profile_folder: args.shared.profile_folder,
118119
skip_upload: args.shared.skip_upload,

src/cli/shared.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,34 @@ pub enum UnwindingMode {
152152

153153
#[derive(Args, Debug, Clone)]
154154
pub struct PerfRunArgs {
155-
/// Enable the linux perf profiler to collect granular performance data.
155+
/// Enable a profiler to collect granular performance data.
156156
/// This is only supported on Linux.
157-
#[arg(long, env = "CODSPEED_PERF_ENABLED", default_value_t = true)]
158-
pub enable_perf: bool,
157+
#[arg(long, env = "CODSPEED_PROFILER_ENABLED", default_value_t = true)]
158+
pub enable_profiler: bool,
159+
160+
/// Deprecated alias for --enable-profiler / CODSPEED_PROFILER_ENABLED.
161+
#[arg(long, env = "CODSPEED_PERF_ENABLED", hide = true)]
162+
pub enable_perf: Option<bool>,
159163

160164
/// The unwinding mode that should be used with perf to collect the call stack.
161165
#[arg(long, env = "CODSPEED_PERF_UNWINDING_MODE")]
162166
pub perf_unwinding_mode: Option<UnwindingMode>,
163167
}
164168

169+
impl PerfRunArgs {
170+
/// Resolves the effective `enable_profiler` value, honoring the deprecated
171+
/// `--enable-perf` / `CODSPEED_PERF_ENABLED` flag with a warning.
172+
pub fn resolve_enable_profiler(&self) -> bool {
173+
let Some(legacy) = self.enable_perf else {
174+
return self.enable_profiler;
175+
};
176+
log::warn!(
177+
"CODSPEED_PERF_ENABLED / --enable-perf is deprecated; use CODSPEED_PROFILER_ENABLED / --enable-profiler instead."
178+
);
179+
legacy
180+
}
181+
}
182+
165183
/// Parser for go-runner version that validates semver format
166184
fn parse_version(s: &str) -> Result<semver::Version, String> {
167185
semver::Version::parse(s).map_err(|e| format!("Invalid semantic version: {e}"))

src/executor/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub struct OrchestratorConfig {
5959

6060
pub modes: Vec<RunnerMode>,
6161
pub instruments: Instruments,
62-
pub enable_perf: bool,
62+
pub enable_profiler: bool,
6363
/// Stack unwinding mode for perf (if enabled)
6464
pub perf_unwinding_mode: Option<UnwindingMode>,
6565

@@ -96,7 +96,7 @@ pub struct ExecutorConfig {
9696
pub command: String,
9797

9898
pub instruments: Instruments,
99-
pub enable_perf: bool,
99+
pub enable_profiler: bool,
100100
/// Stack unwinding mode for perf (if enabled)
101101
pub perf_unwinding_mode: Option<UnwindingMode>,
102102

@@ -181,7 +181,7 @@ impl OrchestratorConfig {
181181
working_directory: self.working_directory.clone(),
182182
command,
183183
instruments: self.instruments.clone(),
184-
enable_perf: self.enable_perf,
184+
enable_profiler: self.enable_profiler,
185185
perf_unwinding_mode: self.perf_unwinding_mode,
186186
simulation_tool: self.simulation_tool,
187187
skip_run: self.skip_run,
@@ -217,7 +217,7 @@ impl OrchestratorConfig {
217217
modes: vec![RunnerMode::Simulation],
218218
instruments: Instruments::test(),
219219
perf_unwinding_mode: None,
220-
enable_perf: false,
220+
enable_profiler: false,
221221
simulation_tool: SimulationTool::default(),
222222
profile_folder: None,
223223
skip_upload: false,

src/executor/tests.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,21 +239,24 @@ mod walltime {
239239
(permit, WallTimeExecutor::new())
240240
}
241241

242-
fn walltime_config(command: &str, enable_perf: bool) -> ExecutorConfig {
242+
fn walltime_config(command: &str, enable_profiler: bool) -> ExecutorConfig {
243243
ExecutorConfig {
244244
command: command.to_string(),
245-
enable_perf,
245+
enable_profiler,
246246
..ExecutorConfig::test()
247247
}
248248
}
249249

250250
#[apply(test_cases)]
251251
#[rstest::rstest]
252252
#[test_log::test(tokio::test)]
253-
async fn test_walltime_executor(#[case] cmd: &str, #[values(false, true)] enable_perf: bool) {
253+
async fn test_walltime_executor(
254+
#[case] cmd: &str,
255+
#[values(false, true)] enable_profiler: bool,
256+
) {
254257
let (_permit, mut executor) = get_walltime_executor().await;
255258

256-
let config = walltime_config(cmd, enable_perf);
259+
let config = walltime_config(cmd, enable_profiler);
257260
// Unset GITHUB_ACTIONS to force LocalProvider which supports repository_override
258261
temp_env::async_with_vars(&[("GITHUB_ACTIONS", None::<&str>)], async {
259262
let (execution_context, _temp_dir) = create_test_setup(config).await;
@@ -267,7 +270,7 @@ mod walltime {
267270
#[test_log::test(tokio::test)]
268271
async fn test_walltime_executor_with_env(
269272
#[case] env_case: (&str, &str),
270-
#[values(false, true)] enable_perf: bool,
273+
#[values(false, true)] enable_profiler: bool,
271274
) {
272275
let (_permit, mut executor) = get_walltime_executor().await;
273276

@@ -276,7 +279,7 @@ mod walltime {
276279
&[(env_var, Some(env_value)), ("GITHUB_ACTIONS", None)],
277280
async {
278281
let cmd = env_var_validation_script(env_var, env_value);
279-
let config = walltime_config(&cmd, enable_perf);
282+
let config = walltime_config(&cmd, enable_profiler);
280283
let (execution_context, _temp_dir) = create_test_setup(config).await;
281284
executor.run(&execution_context, &None).await.unwrap();
282285
},
@@ -287,7 +290,7 @@ mod walltime {
287290
// Ensure that the working directory is used correctly
288291
#[rstest::rstest]
289292
#[test_log::test(tokio::test)]
290-
async fn test_walltime_executor_in_working_dir(#[values(false, true)] enable_perf: bool) {
293+
async fn test_walltime_executor_in_working_dir(#[values(false, true)] enable_profiler: bool) {
291294
let (_permit, mut executor) = get_walltime_executor().await;
292295

293296
let cmd = r#"
@@ -297,7 +300,7 @@ if [ "$(basename "$(pwd)")" != "within_sub_directory" ]; then
297300
fi
298301
"#;
299302

300-
let mut config = walltime_config(cmd, enable_perf);
303+
let mut config = walltime_config(cmd, enable_profiler);
301304

302305
let dir = TempDir::new().unwrap();
303306
config.working_directory = Some(
@@ -319,10 +322,10 @@ fi
319322
// Ensure that commands that fail actually fail
320323
#[rstest::rstest]
321324
#[test_log::test(tokio::test)]
322-
async fn test_walltime_executor_fails(#[values(false, true)] enable_perf: bool) {
325+
async fn test_walltime_executor_fails(#[values(false, true)] enable_profiler: bool) {
323326
let (_permit, mut executor) = get_walltime_executor().await;
324327

325-
let config = walltime_config("exit 1", enable_perf);
328+
let config = walltime_config("exit 1", enable_profiler);
326329
// Unset GITHUB_ACTIONS to force LocalProvider which supports repository_override
327330
temp_env::async_with_vars(&[("GITHUB_ACTIONS", None::<&str>)], async {
328331
let (execution_context, _temp_dir) = create_test_setup(config).await;

src/executor/wall_time/executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl Executor for WallTimeExecutor {
159159
WallTimeExecutor::walltime_bench_cmd(&execution_context.config, execution_context)?;
160160

161161
let status = match self.profiler.as_mut() {
162-
Some(profiler) if execution_context.config.enable_perf => {
162+
Some(profiler) if execution_context.config.enable_profiler => {
163163
run_with_profiler(
164164
profiler.as_mut(),
165165
cmd_builder,

src/executor/wall_time/profiler/perf/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl Profiler for PerfProfiler {
237237
bench_data.save_to(profile_folder, perf_file_path).await
238238
{
239239
warn!(
240-
"Perf is enabled, but failed to detect benchmarks. If you wish to disable this warning, set CODSPEED_PERF_ENABLED=false"
240+
"Perf is enabled, but failed to detect benchmarks. If you wish to disable this warning, set CODSPEED_PROFILER_ENABLED=false"
241241
);
242242
return Ok(());
243243
}

0 commit comments

Comments
 (0)