-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (95 loc) · 3.88 KB
/
bench.yml
File metadata and controls
105 lines (95 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# Criterion benchmarks + regression gate.
#
# Phase-B1b (PHASE-A-2 bench plan §3). Bench targets live under each
# crate's `benches/` directory (see `[[bench]]` stanzas in the affected
# Cargo.toml files); this workflow is the on-demand runner + baseline
# publisher.
#
# Current mode: BASELINE COLLECTION (v0.1.0).
# `fail-on-alert: false`, alerts are surfaced as PR comments only.
# This is a 1-week bake window while we accumulate a drift signature
# on the GitHub-hosted runner. See `docs/RELEASE.md` for the flip
# checklist that hard-enables the gate once the baseline has settled.
#
# Future mode (post-flip):
# `fail-on-alert: true` blocks merges on >10% regressions.
# Consider moving to a self-hosted Linux runner (CPU-pinned,
# governor=performance, SMT off) per PHASE-A-2 §5, GitHub-hosted
# runners exhibit 15-40% noise on the shared hypervisor and will
# false-positive a 10% gate until that happens.
name: bench
on:
push:
branches: [main]
pull_request:
types: [labeled, synchronize, reopened]
permissions:
# `benchmark-action/github-action-benchmark` commits to `gh-pages`
# and posts PR comments. `contents: write` covers both.
contents: write
pull-requests: write
deployments: write
jobs:
bench:
# On PRs, only run when the `benchmark` label is present, keeps
# vanilla PRs fast and avoids burning runner minutes on doc-only
# changes. Push-to-main always runs to keep the gh-pages baseline
# current.
if: >-
github.event_name == 'push'
|| (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'benchmark'))
# TODO(post-v0.1.0): flip to `[self-hosted, linux, bench]` once
# we stand up the CPU-pinned runner. Until then, GH-hosted is
# acceptable because the gate is off (see `fail-on-alert` below).
runs-on: ubuntu-22.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.95"
- uses: Swatinem/rust-cache@v2
with:
shared-key: bench-cache
- name: Run criterion benches
# `--output-format bencher` is the libtest-compatible output
# that `github-action-benchmark` expects when `tool: cargo`.
# `tee` keeps the same stream visible in the job log so we
# don't lose debug detail when the action re-parses.
run: |
cargo bench --workspace --benches -- --output-format bencher | tee output.txt
- name: Upload bench output artifact
uses: actions/upload-artifact@v7
with:
name: bench-output
path: output.txt
retention-days: 30
- name: Check bench output non-empty
id: check_bench
run: |
if [ -s output.txt ]; then
echo "has_output=true" >> "$GITHUB_OUTPUT"
else
echo "has_output=false" >> "$GITHUB_OUTPUT"
echo "::warning::No benchmark output produced; skipping baseline compare."
fi
- name: Store + compare against baseline
if: steps.check_bench.outputs.has_output == 'true'
uses: benchmark-action/github-action-benchmark@v1
with:
tool: cargo
output-file-path: output.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
# Baseline push happens only on push-to-main; PR runs are
# compare-only and never rewrite gh-pages history.
auto-push: ${{ github.event_name == 'push' }}
gh-pages-branch: gh-pages
benchmark-data-dir-path: bench
# 1.10x = 10% slower than baseline triggers a warning.
alert-threshold: "110%"
# v0.1.0 posture: WARN only, don't block merges. Flip to
# `true` after the 1-week baseline bake (see `docs/RELEASE.md`).
fail-on-alert: false
comment-on-alert: true
summary-always: true