CI: comment when a benchmark exceeds the 1 ms iteration budget - #9177
Open
joseph-isaacs wants to merge 1 commit into
Open
CI: comment when a benchmark exceeds the 1 ms iteration budget#9177joseph-isaacs wants to merge 1 commit into
joseph-isaacs wants to merge 1 commit into
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
joseph-isaacs
marked this pull request as ready for review
August 4, 2026 15:35
joseph-isaacs
force-pushed
the
claude/bench-1ms-target-docs
branch
from
August 4, 2026 15:37
3192635 to
4fdf68a
Compare
joseph-isaacs
force-pushed
the
claude/branch-benchmark-ci-l7j32h
branch
from
August 4, 2026 15:37
767d80c to
73a5e5e
Compare
The benchmarking guide asks that a single benchmark iteration stay under 1 ms, but nothing enforced it, so new benchmarks landed at 23.8 ms and 123.4 ms and were caught only by a maintainer reading CodSpeed's table by hand. CodSpeed already measures per-iteration time and publishes it in its sticky PR comment. Read that comment rather than measuring anything: an `issue_comment` job parses CodSpeed's report when it is posted or edited, and comments listing the benchmarks over budget. Nothing is rebuilt and nothing is re-run. The trade is scope, not accuracy, and the rendered comment says so: only benchmarks CodSpeed reports as new or changed are listed, and CodSpeed truncates its own table at 20 rows. Benchmarks this PR made faster are not flagged for being over budget. Report only, never a failing check. The all-clear text updates an existing complaint but never opens a new comment, so a PR that is within budget stays quiet. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FZJAp4wVgwTVhLyErCWFZn
joseph-isaacs
force-pushed
the
claude/branch-benchmark-ci-l7j32h
branch
2 times, most recently
from
August 4, 2026 16:20
4c16010 to
f4d6cf4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
The 1 ms per-iteration budget documented in #9176 had nothing enforcing it, so benchmarks landed at 23.8 ms and 123.4 ms and were caught only by a maintainer reading CodSpeed's table by hand and commenting "This benchmark has a too long runtime" (#9136).
The obvious implementation — rebuild the benchmarks in walltime mode and re-run them to get wall-clock numbers — costs a second 8-shard build-and-run matrix. It isn't needed: CodSpeed already measures per-iteration time and publishes it in its sticky PR comment. So this reads that comment instead. Nothing is rebuilt, nothing is re-run.
What changes are included in this PR?
.github/workflows/bench-budget.yml— one job, onissue_comment(createdandedited, since CodSpeed edits its comment in place as runs land). Gated on the comment author beingcodspeed-hq[bot]and the body carrying CodSpeed's marker: anyone can post text containing that marker, so pinning the author is what makes the parsed table trustworthy.scripts/check-bench-budget.py— parses the "Performance Changes" table: status emoji, mode, the percent-encodeduriquery parameter from each benchmark link, and theHEADper-iteration time. Handles1,182.5 µs(thousands separator), both micro-sign variants,N/A, and the| ... |truncation row.scripts/tests/test_check_bench_budget.py— 27 tests. Fixtures are trimmed copies of the real CodSpeed comments from #9136 and #9060, so the parser is tested against markup CodSpeed actually posts.ci.yml— abench-budget-scriptjob running those tests. The workflow itself lives outside PR CI, so a parser bug would otherwise surface as a wrong comment on someone else's PR rather than as a red check.docs/developer-guide/benchmarking.md— documents the check under the rule added in #9176.On #9136 this would have rendered, in place of the manual comment:
vortex-geo/…::contains::constant_x_polygons_overlappingvortex-geo/…::contains::column_x_column_polygonsvortex-array/benches/like.rs::like_per_row_distinct_patternsDeliberate choices worth reviewing
--fail-on-violationexists but is unused.--include-improvedoverrides).pull-requests: writetoken, so it must run this repository's script rather than a version a fork could edit.Testing
Benchmark budget script).ruff check/ruff formatclean;yamllint --strict -c .yamllint.yaml .github/clean;git diff --checkclean.pr-numberandcreate-if-not-existsare real inputs onthollander/actions-comment-pull-requestat the SHA this repo already pins.Important
This cannot be exercised end-to-end on its own PR.
issue_commentandworkflow_dispatchworkflows only ever run the copy of the workflow on the default branch, so neither entry point exists until this merges. CodSpeed will post its report here and nothing will react to it — that is expected, not a failure.That is why the
workflow_dispatchentry point exists. After merge, dispatch it withpr-number: 9136to replay it against a real report and confirm the comment it produces. If it misbehaves, it comments on pull requests and nothing else — it fails no checks and blocks no merges, so the blast radius of a bad parse is a wrong comment.What APIs are changed? Are there any user-facing changes?
No Rust, no public API. CI and tooling only. The user-facing effect is a new PR comment when a new or changed benchmark exceeds 1 ms per iteration.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FZJAp4wVgwTVhLyErCWFZn