Repository navigation
feat(cli): add walltime unwinding mode and stack sample size options #586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -228,14 +228,38 @@ pub struct ProfilerRunArgs { | |
| pub enable_perf: Option<bool>, | ||
|
|
||
| #[command(flatten)] | ||
| pub perf: PerfRunArgs, | ||
| pub walltime: WalltimeRunArgs, | ||
| } | ||
|
|
||
| #[derive(Args, Debug, Clone)] | ||
| pub struct PerfRunArgs { | ||
| /// The unwinding mode that should be used with perf to collect the call stack. | ||
| #[arg(long, env = "CODSPEED_PERF_UNWINDING_MODE")] | ||
| pub struct WalltimeRunArgs { | ||
| /// The unwinding mode that the walltime profiler should use to collect the call stack. | ||
| #[arg(long, env = "CODSPEED_WALLTIME_UNWINDING_MODE")] | ||
| pub walltime_unwinding_mode: Option<UnwindingMode>, | ||
|
|
||
| /// Deprecated alias for --walltime-unwinding-mode / CODSPEED_WALLTIME_UNWINDING_MODE. | ||
| #[arg(long, env = "CODSPEED_PERF_UNWINDING_MODE", hide = true)] | ||
| pub perf_unwinding_mode: Option<UnwindingMode>, | ||
|
|
||
| /// Size in bytes of the user stack copied with each sample for DWARF unwinding. | ||
| /// Larger values produce deeper call stacks but bigger profiles. | ||
| #[arg(long, env = "CODSPEED_WALLTIME_STACK_SAMPLE_SIZE")] | ||
| pub walltime_stack_sample_size: Option<u32>, | ||
| } | ||
|
|
||
| impl WalltimeRunArgs { | ||
| /// Resolves the effective unwinding mode, honoring the deprecated | ||
| /// `--perf-unwinding-mode` / `CODSPEED_PERF_UNWINDING_MODE` flag with a warning. | ||
| /// The new flag takes precedence when both are set. | ||
| pub fn resolve_unwinding_mode(&self) -> Option<UnwindingMode> { | ||
| let Some(legacy) = self.perf_unwinding_mode else { | ||
| return self.walltime_unwinding_mode; | ||
| }; | ||
| log::warn!( | ||
| "CODSPEED_PERF_UNWINDING_MODE / --perf-unwinding-mode is deprecated; use CODSPEED_WALLTIME_UNWINDING_MODE / --walltime-unwinding-mode instead." | ||
| ); | ||
| Some(self.walltime_unwinding_mode.unwrap_or(legacy)) | ||
|
Comment on lines
+254
to
+261
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new precedence and stack-size overrides have no tests. Add focused cases for the old option alone, both options together, flag/environment combinations, and an explicit size overriding both the default and Python's inferred size. These are the main promises of this change; tests would catch later edits that silently send the wrong value to the profiler. Prompt To Fix With AIThis is a comment left during a code review.
Path: src/cli/shared.rs
Line: 254-261
Comment:
**Option rules lack tests**
The new precedence and stack-size overrides have no tests. Add focused cases for the old option alone, both options together, flag/environment combinations, and an explicit size overriding both the default and Python's inferred size. These are the main promises of this change; tests would catch later edits that silently send the wrong value to the profiler.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| } | ||
| } | ||
|
|
||
| impl ProfilerRunArgs { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
codspeed runandcodspeed execcallresolve_unwinding_mode()while building the config, beforeOrchestrator::new()installs the logger. This drops the warning, so users of--perf-unwinding-modeorCODSPEED_PERF_UNWINDING_MODEnever learn about the replacement. Emit it after logger setup or use the existing startup-warning approach.Prompt To Fix With AI