Skip to content

Commit 680772f

Browse files
authored
ci: run benchmark comparison on pull requests only, and shorten it (#3140)
* ci: run benchmark comparison on pull requests only, and shorten it The benchmark job checks out github.base_ref as the previous code, but that is only set on pull_request events. On pushes to master both checkouts were the same commit, so the job spent about 20 minutes comparing master with itself (the Sep 30 run compared af07b69 with af07b69). Run it only for pull requests. Benchmarks now run with -benchtime=100ms instead of the default 1s. Echo has 51 benchmarks run 8 times on each side, so the 1s default kept the job at about 20 minutes regardless of the machine. At 100ms one side takes about a minute. Both workflows also get a concurrency group, so a new push to a pull request cancels its superseded runs. Runs on master always finish. Claude-Session: https://claude.ai/code/session_01QKDYQr53zNKkR7nif2CAAq * ci: describe the benchmark comparison as advisory Claude-Session: https://claude.ai/code/session_01QKDYQr53zNKkR7nif2CAAq
1 parent af07b69 commit 680772f

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎.github/workflows/checks.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
permissions:
1313
contents: read # to fetch code (actions/checkout)
1414

15+
# Cancel superseded runs of the same pull request; runs on master always finish.
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
18+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
19+
1520
env:
1621
LATEST_GO_VERSION: "1.27"
1722

‎.github/workflows/echo.yml‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ on:
1212
permissions:
1313
contents: read # to fetch code (actions/checkout)
1414

15+
# Cancel superseded runs of the same pull request; runs on master always finish.
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
18+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
19+
1520
env:
1621
LATEST_GO_VERSION: "1.27"
1722

@@ -56,6 +61,9 @@ jobs:
5661
fail_ci_if_error: false
5762

5863
benchmark:
64+
# Compares the pull request against its base branch. github.base_ref is only set for
65+
# pull_request events, so on other events both checkouts would be the same commit.
66+
if: github.event_name == 'pull_request'
5967
needs: test
6068
name: Benchmark comparison
6169
runs-on: ubuntu-latest
@@ -79,15 +87,17 @@ jobs:
7987
- name: Install Dependencies
8088
run: go install golang.org/x/perf/cmd/benchstat@latest
8189

90+
# -benchtime=100ms instead of the default 1s keeps the job to a few minutes. The
91+
# comparison is advisory: it reports differences but never fails the build.
8292
- name: Run Benchmark (Previous)
8393
run: |
8494
cd previous
85-
go test -run="-" -bench=".*" -count=8 ./... > benchmark.txt
95+
go test -run="-" -bench=".*" -benchtime=100ms -count=8 ./... > benchmark.txt
8696
8797
- name: Run Benchmark (New)
8898
run: |
8999
cd new
90-
go test -run="-" -bench=".*" -count=8 ./... > benchmark.txt
100+
go test -run="-" -bench=".*" -benchtime=100ms -count=8 ./... > benchmark.txt
91101
92102
- name: Run Benchstat
93103
run: |

0 commit comments

Comments
 (0)