Repository navigation
90 lines (85 loc) · 4.63 KB
/
Copy pathbench.yml
File metadata and controls
90 lines (85 loc) · 4.63 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
name: Benchmarks
# The instruction-count gate: every bench target, run on the pull request's
# base and then on its head in the same job, on the same machine. Instruction
# counts are deterministic, so a fine limit holds without flaking. The
# comparison goes to the job summary, and the head's counts to the
# `rust.bench.json` artifact.
#
# The targets are listed in one place, `TARGETS` in
# .github/scripts/bench-report.py (`bench-report.py --targets` prints them):
# the runtime's (runtime/core/benches/runtime.rs) and the C ABI's
# (runtime/ffi/bench/benches/ffi.rs). Every one is gated alike, against the
# same limit and ledger, and its benchmark ids are qualified by the target's
# name (`ffi/...`), except the runtime's, which are the shared definitions'.
# The base runs the targets its own script lists, so a target the head drops
# is noticed like any benchmark it stops running; a target the base doesn't
# have yet (the pull request that adds it) is recorded only, as is everything
# when the base has no benches at all. The job summary also pairs each C ABI
# call with the same work on the core directly: the crossing cost, which
# informs and isn't gated on its own.
#
# Accepting a regression: a benchmark that grows past the limit fails, unless
# the pull request appends an `[[accepted]]` entry for it to the ledger,
# runtime/core/benches/accepted-regressions.toml (one for every target),
# naming the benchmark, the
# most it may grow, and why. Likewise a benchmark the base had and the head
# doesn't run fails, unless the pull request appends a `[[removed]]` entry;
# one with `renamed_to` is compared under its new id against its old count,
# so a rename is gated like anything else. A new benchmark has nothing to
# regress from, and is recorded only. Entries are part of the diff, so
# they're reviewed and stay in history; they count only in the pull request
# that adds them (`pr` must be its number), cover only what they name, and
# must be used. The job summary lists them with their counts, and each is
# annotated on the diff. Nothing is accepted by a label, a setting or a
# default. See CONTRIBUTING.md.
#
# The gate itself is the org's reusable bench workflow (`bench` below), run in
# the CI bench image. `bench-command: cargo +stable bench` makes base and head
# build with the image's stable toolchain whatever rust-toolchain.toml says
# (a pull request's base may still pin another one, and a different compiler
# moves counts by far more than the limit), and keeps the file's clippy and
# rustfmt from being fetched. The image's iai-callgrind-runner must match the
# `iai-callgrind` dev-dependency of every bench target
# (runtime/core/Cargo.toml, runtime/ffi/bench/Cargo.toml).
#
# Plain `pull_request`, not `pull_request_target`: a fork's pull request runs
# with a read-only token and no secrets, and the acceptance it can carry is
# its own diff, which a maintainer reviews before merging.
#
# Publishing: on every push to `main`, the `publish` job benches the new head's
# targets alone (nothing to gate) and commits its `rust.bench.json` to the `reports`
# branch, which the docs fetch from; see the shared publish-report action (ComlineProject/observatory).
# Only that job can write, and only from `main`: a manual run from another
# branch builds the report and does a dry run of the publish.
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
bench:
name: bench
# contents: write is for the publish job alone (never on a pull request);
# the gate job asks for contents: read.
permissions:
contents: write
uses: ComlineProject/.github/.github/workflows/bench.yml@807dd25bcbf848275f5f2bc5dcdd15070dcc321b # 2026-11-12
with:
image: ghcr.io/comlineproject/ci-bench@sha256:235555448c3c6027960cd95c0b2974014484e0c4f2808f064eb4cb3df91cebc0
bench-command: cargo +stable bench
ledger: runtime/core/benches/accepted-regressions.toml
report-path: runtime/conformance/reports/rust.bench.json
# A benchmark fails when its instruction count grows by more than this
# many percent, unless the ledger accepts it (see the top). Measured when
# the gate was set up: the same commit, run twice, differs by 0
# instructions on every benchmark, and with one codegen unit
# (`[profile.bench]` in Cargo.toml) a change to one function leaves the
# others' counts alone. 1% is above that, and catches a few instructions
# on the smallest benchmarks.
limit-percent: '1'
publish: true