Skip to content

Commit 5bde071

Browse files
authored
Merge pull request #144 from acgetchell/feat/138-release-benchmark-baselines
feat(bench): publish release benchmark baselines
2 parents ad660ba + 9497ca5 commit 5bde071

4 files changed

Lines changed: 127 additions & 7 deletions

File tree

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Benchmarks
22

3-
# Detect performance regressions in exact-arithmetic benchmarks.
3+
# Detect performance regressions.
44
# - Push to main: run benchmarks, save Criterion baseline, upload as artifact.
55
# - PRs: find latest main baseline artifact, download, compare, report.
66
# Regressions are warning-only — this workflow never fails on regression.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Release Benchmarks
2+
3+
# Archive full Criterion benchmark baselines for published releases.
4+
# Release jobs publish durable artifacts, so they intentionally do not restore
5+
# or save dependency caches.
6+
7+
permissions:
8+
contents: write
9+
10+
on:
11+
release:
12+
types:
13+
- published
14+
15+
concurrency:
16+
group: release-benchmarks-${{ github.event.release.tag_name }}
17+
cancel-in-progress: false
18+
19+
env:
20+
CARGO_TERM_COLOR: always
21+
RUST_BACKTRACE: 1
22+
23+
jobs:
24+
release-baseline:
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 60
27+
28+
steps:
29+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30+
with:
31+
ref: ${{ github.event.release.tag_name }}
32+
persist-credentials: false
33+
34+
- name: Install Rust toolchain
35+
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1
36+
with:
37+
cache: false
38+
39+
- name: Save release Criterion baseline
40+
env:
41+
RELEASE_TAG: ${{ github.event.release.tag_name }}
42+
run: |
43+
set -euo pipefail
44+
45+
cargo bench --features bench --bench vs_linalg -- --save-baseline "$RELEASE_TAG"
46+
cargo bench --features bench,exact --bench exact -- --save-baseline "$RELEASE_TAG"
47+
48+
- name: Package release Criterion baseline
49+
id: package-baseline
50+
env:
51+
RELEASE_TAG: ${{ github.event.release.tag_name }}
52+
run: |
53+
set -euo pipefail
54+
55+
asset="la-stack-${RELEASE_TAG}-criterion-baseline.tar.gz"
56+
tar -C target -czf "$asset" criterion
57+
echo "asset=$asset" >> "$GITHUB_OUTPUT"
58+
59+
- name: Upload temporary baseline artifact
60+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
61+
with:
62+
name: bench-baseline-${{ github.event.release.tag_name }}
63+
path: ${{ steps.package-baseline.outputs.asset }}
64+
retention-days: 30
65+
if-no-files-found: error
66+
67+
- name: Attach baseline to GitHub Release
68+
env:
69+
GH_TOKEN: ${{ github.token }}
70+
RELEASE_TAG: ${{ github.event.release.tag_name }}
71+
RELEASE_ASSET: ${{ steps.package-baseline.outputs.asset }}
72+
run: |
73+
set -euo pipefail
74+
75+
gh release upload "$RELEASE_TAG" "$RELEASE_ASSET" --clobber
76+
77+
- name: Release baseline summary
78+
env:
79+
RELEASE_ASSET: ${{ steps.package-baseline.outputs.asset }}
80+
run: |
81+
set -euo pipefail
82+
83+
{
84+
echo "### Release Benchmark Baseline"
85+
echo ""
86+
echo "Uploaded release asset: \`$RELEASE_ASSET\`"
87+
} >> "$GITHUB_STEP_SUMMARY"

docs/BENCHMARKING.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ just bench-latest-vs-last
116116
## Comparing performance across releases
117117

118118
Criterion baselines are saved into `target/criterion/` and persist across
119-
`git checkout` but **not** across `cargo clean`.
119+
`git checkout` but **not** across `cargo clean`. Published releases also attach
120+
a compressed Criterion baseline to the GitHub Release so historical release
121+
baselines can be restored later.
120122

121123
### Latest vs last
122124

@@ -158,6 +160,26 @@ just bench-compare v0.2.0
158160

159161
You can save multiple baselines and compare against any of them.
160162

163+
If the release baseline is already present in `target/criterion/`, skip the
164+
checkout step and compare directly. For example, to compare current code against
165+
the saved `v0.4.2` release baseline:
166+
167+
```bash
168+
just bench-latest # gather latest la-stack measurements
169+
just bench-compare v0.4.2 # compare latest measurements against v0.4.2
170+
```
171+
172+
If the release baseline is not present locally, download and restore the release
173+
asset first:
174+
175+
```bash
176+
gh release download v0.4.2 --pattern "la-stack-v0.4.2-criterion-baseline.tar.gz" # fetch archived release baseline
177+
mkdir -p target # ensure Criterion parent directory exists
178+
tar -C target -xzf la-stack-v0.4.2-criterion-baseline.tar.gz # restore target/criterion baseline data
179+
just bench-latest # gather latest la-stack measurements
180+
just bench-compare v0.4.2 # compare latest measurements against v0.4.2
181+
```
182+
161183
### Output
162184

163185
`just bench-compare` writes `target/bench-reports/performance.md` by
@@ -187,11 +209,14 @@ See `scripts/criterion_dim_plot.py --help` for options.
187209

188210
## Release workflow
189211

190-
At release time, save a baseline so future work can compare against it:
212+
At release time, save a local baseline so future work can compare against it:
191213

192214
```bash
193215
just bench-save-baseline $TAG
194216
just bench-save-last
195217
```
196218

219+
When the GitHub Release is published, `.github/workflows/release-benchmarks.yml`
220+
saves a full release baseline and attaches
221+
`la-stack-$TAG-criterion-baseline.tar.gz` to the release as the durable archive.
197222
See `docs/RELEASING.md` step 5 for where this fits in the release process.

docs/RELEASING.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,18 @@ just bench-save-baseline $TAG
111111
just bench-save-last
112112
```
113113

114-
These baselines can be compared against in future optimization work. The
115-
default local report command, `just bench-compare`, compares latest
116-
measurements against `last` and writes `target/bench-reports/performance.md`;
117-
it does not update README benchmark tables or committed release artifacts.
114+
These baselines can be compared against in future optimization work on the
115+
release branch. The default local report command, `just bench-compare`, compares
116+
latest measurements against `last` and writes
117+
`target/bench-reports/performance.md`; it does not update README benchmark
118+
tables or committed release artifacts.
119+
120+
After the GitHub Release is published, the `Release Benchmarks` workflow checks
121+
out the release tag, saves a full Criterion baseline, and attaches
122+
`la-stack-$TAG-criterion-baseline.tar.gz` to the release. That release asset is
123+
the durable archive for historical baseline comparisons; the workflow also
124+
uploads a short-lived Actions artifact for debugging the run.
125+
118126
See `docs/BENCHMARKING.md` for the full comparison workflow.
119127

120128
6. Validate the release branch

0 commit comments

Comments
 (0)