Skip to content

Add benchstat regression gate to CI bench job#41813

Merged
pelikhan merged 3 commits into
mainfrom
copilot/deep-report-add-benchstat-regression-gate
Jun 27, 2026
Merged

Add benchstat regression gate to CI bench job#41813
pelikhan merged 3 commits into
mainfrom
copilot/deep-report-add-benchstat-regression-gate

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

The bench job in cgo.yml ran make bench and saved results as an artifact but never compared against a baseline — a 2× slowdown would merge silently.

Changes

  • actions: read permission — required to read artifacts from previous runs via gh api
  • Install benchstatgolang.org/x/perf/cmd/benchstat@latest using the existing Go toolchain
  • Download previous baseline — fetches the most recent benchmark-results artifact filtered to main-branch runs; sets has_baseline output; skips gracefully on first run or download failure
  • Regression check step — compares baseline/bench_results.txt vs bench_results.txt, writes the benchstat diff to the Job Summary, and fails with exit 1 if any benchmark regresses >10%
  • timeout-minutes: 20 — bumped from 15 to accommodate the new steps

Key implementation notes:

  • Uses awk for float threshold comparison (no bc dependency)
  • Regex handles both integer and decimal percentages (+15% / +15.23%)
  • benchstat convention: + = slower (regression), - = faster (improvement)
  • The bench job already gates on github.ref == 'refs/heads/main', so any downloaded artifact is inherently from a main run; the jq filter select((.workflow_run.head_branch // "main") == "main") adds an extra safeguard with a safe default

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add benchstat regression gate to CI bench job Add benchstat regression gate to CI bench job Jun 26, 2026
Copilot AI requested a review from pelikhan June 26, 2026 23:58
@pelikhan pelikhan marked this pull request as ready for review June 27, 2026 00:04
Copilot AI review requested due to automatic review settings June 27, 2026 00:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a regression gate to the bench job in .github/workflows/cgo.yml so benchmark results are compared against a previous baseline using benchstat, failing the job when regressions exceed a threshold.

Changes:

  • Add actions: read permission and install benchstat in the bench job.
  • Download the most recent benchmark-results artifact as a baseline and conditionally run a regression check.
  • Increase bench job timeout to accommodate the new steps.
Show a summary per file
File Description
.github/workflows/cgo.yml Adds baseline artifact download + benchstat comparison to gate >10% benchmark regressions on main, and increases job timeout.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 3
  • Review effort level: Low

Comment thread .github/workflows/cgo.yml Outdated
Comment on lines +975 to +977
artifact_id=$(gh api \
"repos/$GITHUB_REPOSITORY/actions/artifacts?name=benchmark-results&per_page=10" \
--jq '[.artifacts[] | select((.workflow_run.head_branch // "main") == "main")] | .[0].id // empty' 2>/dev/null)
Comment thread .github/workflows/cgo.yml Outdated
Comment on lines +1009 to +1010
benchstat_out=$(benchstat baseline/bench_results.txt bench_results.txt 2>&1)
echo "$benchstat_out"
Comment thread .github/workflows/cgo.yml Outdated
Comment on lines +963 to +964
- name: Install benchstat
run: go install golang.org/x/perf/cmd/benchstat@latest
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill to complete this PR and confirm the benchstat regression gate changes are ready for maintainer review.

Generated by 👨‍🍳 PR Sous Chef · 141.5 AIC · ⌖ 1.11 AIC · ⊞ 17.1K ·

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Category chore
Risk 🟡 Medium
Priority Medium (score 47/100)
Action 👀 batch_review

Score breakdown: Impact 25 · Urgency 10 · Quality 12

Adds benchstat regression gate to CI bench job (+76/-1, 1 file). Ready, MERGEABLE, 2 reviews. Prevents silent perf regressions. Medium risk: modifies bench job gate logic (10% threshold via awk). Batch with other CI tooling changes for coordinated review.

Generated by 🔧 PR Triage Agent · 87.6 AIC · ⌖ 14.9 AIC · ⊞ 5.4K ·

@pelikhan pelikhan merged commit 4c5f79c into main Jun 27, 2026
25 checks passed
@pelikhan pelikhan deleted the copilot/deep-report-add-benchstat-regression-gate branch June 27, 2026 02:27
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.81.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants