Repository navigation
id(ci): non-blocking benchmark regression reporting vs committed baselines (#1513) #1589
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| #!/usr/bin/env bash | ||
| # id-bench-compare.sh — diff pkgs/id benchmark medians against the | ||
| # committed F11.8 baselines and print a Markdown regression report | ||
| # (slice 3 of #539, issue #1513). | ||
| # | ||
| # Usage: id-bench-compare.sh <bench-output-file> [baseline-file] | ||
| # | ||
| # Both inputs use the harness's own line format (world_bench.rs): | ||
| # bench <name> unit=<unit> median=<value> min=<value> reps=<n> | ||
| # baseline.txt is literally a captured harness run plus comments, so | ||
| # one parser serves both sides. | ||
| # | ||
| # A benchmark is flagged when its current median is more than | ||
| # BENCH_REGRESSION_THRESHOLD_PCT percent (default 20) above baseline. | ||
| # The report goes to stdout; the caller appends it to the GitHub job | ||
| # summary. This script ALWAYS exits 0 — slice 3 is non-blocking by | ||
| # design: the report informs, it never gates a PR. | ||
| set -euo pipefail | ||
|
|
||
| threshold="${BENCH_REGRESSION_THRESHOLD_PCT:-20}" | ||
|
|
||
| if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then | ||
| echo "usage: id-bench-compare.sh <bench-output-file> [baseline-file]" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| current_file="$1" | ||
| baseline_file="${2:-pkgs/id/benches/baseline.txt}" | ||
|
|
||
| if [ ! -f "$current_file" ]; then | ||
| echo "## Benchmark regression report" | ||
| echo | ||
| echo "⚠️ Benchmark output file \`$current_file\` not found — the bench run produced no results to compare." | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [ ! -f "$baseline_file" ]; then | ||
| echo "## Benchmark regression report" | ||
| echo | ||
| echo "⚠️ Baseline file \`$baseline_file\` not found — nothing to compare against." | ||
| exit 0 | ||
| fi | ||
|
|
||
| awk -v threshold="$threshold" ' | ||
| function parse(file, median, unit, order, line, i, f, kv) { | ||
| while ((getline line < file) > 0) { | ||
| if (line !~ /^bench /) continue | ||
| split(line, f, /[ \t]+/) | ||
| name = f[2] | ||
| for (i = 3; i in f; i++) { | ||
| split(f[i], kv, "=") | ||
| if (kv[1] == "median") median[name] = kv[2] + 0 | ||
| if (kv[1] == "unit") unit[name] = kv[2] | ||
| } | ||
| if (!(name in seen)) { seen[name] = 1; order[++n] = name } | ||
| } | ||
| close(file) | ||
| } | ||
| BEGIN { | ||
| n = 0 | ||
| parse(ARGV[1], base_median, base_unit, base_order) | ||
| base_n = n | ||
| n = 0 | ||
| parse(ARGV[2], cur_median, cur_unit, cur_order) | ||
|
|
||
| print "## Benchmark regression report (vs committed baselines)" | ||
| print "" | ||
| printf "Threshold: a benchmark is flagged when its median is more than %s%% above baseline. Baselines were taken on the reference machine in `pkgs/id/benches/BASELINES.md`; shared CI runners differ, so treat flags as a prompt to investigate, not a verdict.\n", threshold | ||
| print "" | ||
| print "| benchmark | unit | baseline median | current median | change | status |" | ||
| print "| --- | --- | ---: | ---: | ---: | --- |" | ||
| regressions = 0 | ||
| for (i = 1; i <= base_n; i++) { | ||
| name = base_order[i] | ||
| if (name in cur_median) { | ||
| pct = (cur_median[name] - base_median[name]) / base_median[name] * 100 | ||
| if (pct > threshold) { | ||
| status = "⚠️ regression" | ||
| regressions++ | ||
| reg_list[++reg_n] = sprintf("%s (+%.1f%%)", name, pct) | ||
| } else { | ||
| status = "ok" | ||
| } | ||
| printf "| %s | %s | %.3f | %.3f | %+.1f%% | %s |\n", name, base_unit[name], base_median[name], cur_median[name], pct, status | ||
| } else { | ||
| printf "| %s | %s | %.3f | — | — | not run |\n", name, base_unit[name], base_median[name] | ||
| } | ||
| } | ||
| for (i = 1; i <= n; i++) { | ||
| name = cur_order[i] | ||
| if (!(name in base_median)) { | ||
| printf "| %s | %s | — | %.3f | — | no baseline |\n", name, cur_unit[name], cur_median[name] | ||
| } | ||
| } | ||
| print "" | ||
| if (regressions > 0) { | ||
| printf "⚠️ **%d benchmark(s) regressed more than %s%%:** ", regressions, threshold | ||
| for (i = 1; i <= reg_n; i++) printf "%s%s", reg_list[i], (i < reg_n ? ", " : "") | ||
| print "" | ||
| } else { | ||
| printf "✅ No benchmark regressed more than %s%% against the committed baselines.\n", threshold | ||
| } | ||
| } | ||
| ' "$baseline_file" "$current_file" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Benchmark regression reporting for pkgs/id — F11.8 slice 3 (#1513). | ||
| # | ||
| # Runs the four slice-1 benchmarks (world_bench) and diffs their medians | ||
| # against the committed slice-2 baselines in pkgs/id/benches/baseline.txt, | ||
| # using .github/scripts/id-bench-compare.sh. The report lands in the job | ||
| # summary and as a run artifact. | ||
| # | ||
| # NON-BLOCKING BY DESIGN: this workflow is separate from the required | ||
| # "nix flake check" gate in id-check.yml, the bench step is | ||
| # continue-on-error, and the compare script always exits 0. A regression | ||
| # flag informs the PR — it never fails a required check. Baselines were | ||
| # taken on the fleet laptop (see pkgs/id/benches/BASELINES.md); shared | ||
| # CI runners are a different machine class, so flags are a prompt to | ||
| # investigate, not a verdict. | ||
|
|
||
| name: id bench | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "pkgs/id/**" | ||
| - ".github/workflows/id-bench.yml" | ||
| - ".github/scripts/id-bench-compare.sh" | ||
| pull_request: | ||
| paths: | ||
| - "pkgs/id/**" | ||
| - ".github/workflows/id-bench.yml" | ||
| - ".github/scripts/id-bench-compare.sh" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| # Same concurrency shape as id-check.yml: push-to-main runs are keyed by | ||
| # run_id so every merged tree gets its own completed run; PR runs share | ||
| # a per-ref group so a new push supersedes the stale run. | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.run_id || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| bench: | ||
| name: benchmark regression report | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
|
|
||
| - uses: DeterminateSystems/nix-installer-action@3138316df39ed29be04236d7ffc686fa525866aa # v23 | ||
| with: | ||
| extra-conf: | | ||
| accept-flake-config = true | ||
|
|
||
| # Same store cache as the PR gate, so the bench build starts warm | ||
| # (#288). | ||
| - uses: DeterminateSystems/magic-nix-cache-action@84c0677f58dcedf3b91f8223ce36a9ea5b3c84b7 # v15 | ||
|
|
||
| # Full-size workloads, exactly as the baselines were taken | ||
| # (BASELINES.md): --quick numbers are smoke sizes and are never | ||
| # comparable to the committed baselines. | ||
| - name: Run benchmarks | ||
| id: bench | ||
| continue-on-error: true | ||
| working-directory: pkgs/id | ||
| run: | | ||
| nix develop --command just bench 2>&1 | tee "$GITHUB_WORKSPACE/bench-output.txt" | ||
|
|
||
| - name: Compare against committed baselines | ||
| if: always() | ||
| run: | | ||
| if [ "${{ steps.bench.outcome }}" != "success" ]; then | ||
| { | ||
| echo "## Benchmark regression report" | ||
| echo | ||
| echo "⚠️ The benchmark run did not complete (step outcome: ${{ steps.bench.outcome }}), so there are no results to compare. This report is non-blocking; see the run log." | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| exit 0 | ||
| fi | ||
| .github/scripts/id-bench-compare.sh bench-output.txt pkgs/id/benches/baseline.txt | tee bench-report.md >> "$GITHUB_STEP_SUMMARY" | ||
|
|
||
| - name: Upload benchmark output | ||
| if: always() | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: bench-output | ||
| path: | | ||
| bench-output.txt | ||
| bench-report.md | ||
| if-no-files-found: ignore | ||
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
Oops, something went wrong.
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.
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.
If Nix setup, compilation, or the benchmark harness fails, this pipeline still succeeds whenever
teesucceeds. The workflow leaves the shell unspecified, which GitHub documents asbash -e {0}, withoutpipefail. Consequently,steps.bench.outcomeremainssuccess, bypassing the failure-report branch in the comparison step and potentially reporting “No benchmark regressed” from empty or incomplete results. Specifyshell: bashor enablepipefailso failures reach the existing warning branch;continue-on-erroralready preserves the intended non-blocking behavior.Useful? React with 👍 / 👎.