Skip to content

feat(walltime): add --walltime-sampling-rate option - #637

Open
not-matthias wants to merge 1 commit into
mainfrom
feat/walltime-sampling-rate
Open

not-matthias wants to merge 1 commit into
mainfrom
feat/walltime-sampling-rate

Conversation

@not-matthias

Copy link
Copy Markdown
Member

TLDR: The walltime profilers sample at a fixed 997 Hz. Short functions get too few samples to judge their share or change. This adds --walltime-sampling-rate so a run can sample more often.

  • New --walltime-sampling-rate <HZ> / CODSPEED_WALLTIME_SAMPLING_RATE on run and exec, forwarded to both walltime profiler backends.
  • Default stays 997 Hz; 0 is rejected.
  • Higher rates add profiling overhead, so this is meant for reading flame graphs, not for the measured runs you compare.

Example

$ codspeed run --help
      --walltime-sampling-rate <HZ>
          Walltime profiler samples per second. Higher rates give more samples for short functions, at the cost of more profiling overhead
          [env: CODSPEED_WALLTIME_SAMPLING_RATE=]
          [default: 997]

$ codspeed run --walltime-sampling-rate 0 true
error: invalid value '0' for '--walltime-sampling-rate <HZ>': 0 is not in 1..=4294967295

Perf and samply sampled at a hardcoded 997 Hz, so short functions get too few samples to read their share or change.

Expose the rate as --walltime-sampling-rate / CODSPEED_WALLTIME_SAMPLING_RATE on run and exec, defaulting to 997 Hz, and forward it to both profilers.
@codspeed

codspeed Bot commented Nov 26, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 9 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 53 untouched benchmarks
⏩ 6 skipped benchmarks1


Comparing feat/walltime-sampling-rate (0d0f33d) with main (ff27652)

Open in CodSpeed

Footnotes

  1. 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@not-matthias
not-matthias marked this pull request as ready for review November 27, 2026 10:09
@greptile-apps

greptile-apps Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5 · The PR appears safe to merge, with a non-blocking request for tests of the new option.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects walltime profiles created by `run` and `exec`.

The PR appears safe to merge, with a non-blocking request for tests of the new option.

FindingsFix All in Claude CodeFindings

  1. P2 Sampling rate lacks tests ▶
Fix with agent prompt
### Issue 1
src/cli/shared.rs:250-257
The new option has no tests beyond updated default fixtures. Add tests for the 997 default, a custom flag value, the environment value, rejection of zero, and forwarding a non-default rate into `ExecutorConfig`. This is non-blocking, but without these tests a future change could silently restore 997 while the CLI still accepts the user's rate.

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!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds --walltime-sampling-rate and CODSPEED_WALLTIME_SAMPLING_RATE to run and exec.

  • Callers can choose how often walltime profiles take samples.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["run / exec flag or environment"] --> B["OrchestratorConfig"]
  B --> C["ExecutorConfig"]
  C --> D["perf --freq"]
  C --> E["Samply --rate"]
Loading

Reviews (1) · Last reviewed commit: "feat(walltime): add --walltime-sampling-..." · Reviewed by Greptile

Comment thread src/cli/shared.rs Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant