Skip to content

Benchmark each PR against its base commit and chart main on elfuse-bench #503

Open

Description

@xalestar

#493 compares the Benchmark leg against tests/bench-baseline.json, a static baseline promoted by hand. It goes stale after the next merge that changes performance. Its elfuse-aarch64 column dates from 2026-07-16, before the suite ran on the CI runner, and CI medians now differ from it by up to 25x (lat_proc fork 116 ms in the file, 4.7 ms on CI). This issue proposes measuring each pull request when it is ready for review, and again on request, against the main it would merge into, and each merge to main that can change a benchmark against the main it landed on, both sides built in the same job, and charting the merged results on elfuse-bench, close to the model rv32emu uses with rv32emu-bench.

Terms used below: Tier 1 is the lmbench metrics (lmbench.*), Tier 2 the application metrics (applications.*), Tier 3 the OCI workloads (oci.*). A round is one run of tests/bench-suite.sh against one build. A pair is one base round and one head round that run back to back.

Why a static baseline is not enough on the CI runner

Six Benchmark-leg runs over about 19 hours (#493 runs 42489084731, 42494478039, 42503585558, 42510136410 and main runs 42570321741, 42570490049). Five ran on the self-hosted runner macmini-ci and one, 42510136410, on macmini-m4-hvf-2. The two are runners on one Mac, so all six runs measured the same machine. "Between runs" is the coefficient of variation (CV) of the six run medians of a metric; "inside a run" is the median, over the six runs, of each run's CV across its samples.

Metrics Between runs Inside a run
lat_syscall null/read/write/stat/open, lat_proc fork, lat_fs, ripgrep, zstd, startup, oci.jvm 0.5% to 4.0% 0.0% to 3.4%
lat_proc exec, git status, python startup 10.8% to 51.9% 2.7% to 3.1%
make, oci.python, oci.node, oci.c_compile 1.5% to 24.0% 8.3% to 16.3%

The second row comes from one run, 42503585558 (6f20b3a). Against the median of the other five runs, lat_proc exec was 2.6x slower, git status 45% faster and python startup 25% faster. The shift was not steady inside that run either: its lat_proc exec samples range from 22.5 ms to 86.3 ms (CV 46.6%), where the other runs stay within 22.7 ms to 25.2 ms.

The third row varies inside a run. One run's make samples range from 1.51 s to 2.36 s (42510136410), and one run's oci.python samples from 1.11 s to 2.10 s (42503585558). oci.python also varies between runs without the 6f20b3a run (medians 1.12 s to 2.00 s).

A fixed reference gets the 6f20b3a run wrong in either form. The static baseline marked lat_proc exec (0.56x), git status (0.13x) and python startup (0.16x) all as improved, because the file is slower than CI by up to 25x, so the 2.6x exec slowdown did not show (job 128803797699). A baseline taken from recent main medians would have reported exec as a regression and the other two as improvements, with no code change behind any of them.

How the proposal deals with each:

Problem How it is handled Status
The baseline goes stale after the next merge that changes performance The main before each merge is rebuilt and measured in the same job, so nothing is stored by design; in place since #540
The elfuse-aarch64 column predates the CI runner and differs from it by up to 25x Both sides are measured on the CI runner in the same job by design; in place since #540
One run (6f20b3a) moved several metrics at once, some slower and some faster Base and head alternate in one job and the verdict uses their ratio, so a shift that hits both rounds of a pair cancels three local A/A runs in #540 put every median ratio between 0.96x and 1.06x; no A/A run on CI yet
Some metrics jump between two values inside one run Median of the pair ratios; make gets no verdict, and lat_fs gets none until #498 is fixed. The oci.* metrics run on the head build only, so they never get one one CI run so far, 44836576102, with no change under src/: make read 0.933x and every other median ratio was between 0.966x and 1.034x

Proposal

Event What runs Result
Pull request that touches a path in the next row, when it is opened as ready for review or a draft is marked ready for review; and any pull request each time the bench label is added (PR 3) Build the pull request's merge commit (refs/pull/N/merge) and that commit's first parent, the same paired run for Tier 1 and Tier 2, without Tier 3 Advisory comment on the pull request, posted by bench-report.yml; nothing published
Push to main that touches src/**, mk/**, Makefile, tests/bench-*, tests/lib/**, tests/fetch-fixtures.sh, scripts/bench-*, scripts/elfuse-oci.py or .github/workflows/benchmark.yml Build github.event.before and the pushed commit, Tier 1 and Tier 2 for both in alternating rounds, then Tier 3 for the pushed commit. A push whose github.event.before the clone lacks, as after a force push, is not measured Advisory comment on the merged pull request; one point per metric appended to elfuse-bench, shown on GitHub Pages (PR 4)
workflow_dispatch with base and head commits, with aa (one commit on both sides), or with pr (a pull request number) The same paired run for those two commits, or for the pull request's current merge ref against its first parent, without Tier 3 Job summary and artifact; with pr, the pull request's comment is updated; nothing published
schedule, nightly (PR 3) The same paired run with the main tip on both sides (A/A), without Tier 3 Job summary and artifact; nothing published
schedule, weekly (PR 3) The same paired run for the main tip against the main of 4 weeks earlier, without Tier 3 Job summary and artifact; nothing published
Any other push to main, and every later push to a pull request Nothing
       ┌───────────────────┐   ┌────────────────────┐   ┌──────────────────────┐
       │   pull request    │   │    push to main    │   │  workflow_dispatch   │
       │ (opened, ready or │   │ (bench paths only) │   │ (base, head, aa, pr) │
       │  `bench` label)   │   │                    │   │     or schedule      │
       └───────────────────┘   └────────────────────┘   └──────────────────────┘
                 └─────────────────────┐ │ ┌───────────────────────┘
                                       │ │ │
                           ┌───────────▾─▾─▾────────────┐
                           │ benchmark.yml, self-hosted │
                           │     build base + head      │
                           │     stage sysroot once     │
                           │     6 pairs, Tier 1+2      │
                           │ Tier 3 on head (push only) │
                           └────────────────────────────┘
                                         │
                          ┌──────────────▾──────────────┐
                          │  bench-compare.py --paired  │
                          │ median ratio + 95% interval │
                          └─────────────────────────────┘
            ┌──────────────────────────┘ │ └───────────────────────────┐
            │                            │                             │
┌───────────▾───────────┐   ┌────────────▾────────────┐   ┌────────────▾────────────┐
│   on pull request:    │   │        on push:         │   │ on push or pr dispatch: │
│   bench-report.yml    │   │       publish job       │   │       comment job       │
│ PR comment (advisory) │   │ github-action-benchmark │   │  PR comment (advisory)  │
└───────────────────────┘   └─────────────────────────┘   └─────────────────────────┘
                                         │
                           ┌─────────────▾──────────────┐
                           │ token push to elfuse-bench │
                           │    data.js + index.html    │
                           └────────────────────────────┘
                                         │
                                  ┌──────▾───────┐
                                  │ GitHub Pages │
                                  │ trend charts │
                                  └──────────────┘

Design choices:

  • Measure each pull request once, and every merge. rv32emu compares every pull request push that passes its path filter, on GitHub-hosted ubuntu-24.04 runners, so pull requests do not wait for each other. elfuse benchmarks on one self-hosted Mac under an exclusive host lock, and a path filter on pull request pushes saves little: 106 of the 120 merges to main since 2026-08-01 touched a path on the list above. A pull request is therefore measured once, triggered by the pull_request types opened and ready_for_review with drafts skipped, which warns the author early; later pushes to it are not measured. Review can change the code after that run, so adding the bench label measures the pull request again as it stands then (the labeled type; removing and adding the label repeats it). A labeled run skips the path filter, and only users with triage access can add a label. Until the label lands in PR 3, workflow_dispatch with pr measures a pull request again: its current merge ref against its first parent, after which the run updates the pull request's comment (#540 review). A report whose pull request has moved on to a new commit is posted with the commit it measured, and a report never replaces one whose merge ref was taken later. workflow_dispatch stays for comparing any two commits. The merge run then measures exactly the code that landed: every pull request lands as a merge commit, so github.event.before is the main it landed on. A direct push of several commits is measured as one change for the same reason. Neither run is a required check, so a merge never waits for a benchmark, also when several pull requests merge within minutes. A regression that the first run missed is reported after the merge, on the merged pull request, and is fixed by a revert or a follow-up. The pull request run executes fork code on the self-hosted host, as the Build workflow already does for every pull request push today; only users with write access can start workflow_dispatch.
  • A pull request run compares the merge commit with its first parent. base.sha is the tip of main that GitHub records for the pull request, and the head can be behind it: the heads of Order the syscall histogram handshake with seq_cst #508 and Take the FUSE file slot before the session lock #509 are each 9 commits behind their base.sha. Head against base.sha would then also measure those 9 commits, reversed. refs/pull/N/merge is the head merged into main and its first parent is that main, so the two builds differ by the pull request alone. A pull request with a merge conflict has no merge commit and gets no run.
  • Alternate the two builds instead of running them together. Concurrent elfuse sessions under load are what raised the lat_fs times out under elfuse in the CI Benchmark leg #498 stall rate, and two VMs on one host disturb each other's numbers. scripts/bench-paired.sh runs the rounds. Each round runs tests/bench-suite.sh once from the head tree with ELFUSE= set to one build, BENCH_ITERATIONS=1 and BENCH_WARMUP=0, so both sides use the same suite and fixtures. After one discarded round per side, the order inside a pair flips from pair to pair: base, head, then head, base, and so on, so each build runs first in 3 of the 6 pairs. With base always first, anything that makes the second round of a pair faster or slower (a warm page cache, the host heating up) would move every ratio the same way. The A/A runs show whether such an effect exists. make bench-ci sets ELFUSE itself (mk/tests.mk), so benchmark.yml builds bench-timeit and calls the script directly with the settings bench-ci passes today (BENCH_BIN_DIR=build, BENCH_STRICT=1). The case-sensitive bench sysroot (an hdiutil sparse image holding a copy of the rootfs, about 7 s) is staged once per job and reused by every round of both builds, instead of once per round, which saves about 1.6 min. tests/bench-suite.sh -s stages it and writes its mount point and image path to a file, which scripts/bench-paired.sh takes through BENCH_PAIRED_STAGE. benchmark.yml builds both sides and stages the sysroot under the shared host lock, before it takes the exclusive one, so the corpus preparation holds no other leg back (#540 review). The Tier 2 workloads run in a work directory inside the sysroot and write there, so each round attaches the staged image with its own shadow file (hdiutil attach -shadow) and discards that file afterwards. The image itself is never written, and every round starts from the same staged copy. Benchmark each change against its base in CI #540 checked this on a case-sensitive sparse image: a file written and one deleted in one attach were back to the staged state in the next, the image's checksum did not change, and an attach plus detach took about 0.5 s.
  • Median of the pair ratios, not their mean. For each metric, the median of the head/base ratios of the pairs, with a 95% confidence interval from order statistics (the k-th smallest and k-th largest ratio, k the largest order whose binomial coverage stays at 95% or more), which needs at least 6 pairs. A run takes exactly 6 pairs: with 6 to 8 pairs k is 1, so the interval runs from the smallest to the largest ratio either way, and k = 2 first holds at 9 pairs, so pairs 7 and 8 would add about 2.5 min without changing the interval rule. A metric is faster or slower only when the interval excludes 1 and the change exceeds a threshold, otherwise "no significant change". The median keeps a few pairs that land on different values from swinging the result. make, which jumps inside a run, is shown in the comment without a verdict. The lat_fs metrics are shown without a verdict too until lat_fs times out under elfuse in the CI Benchmark leg #498 is fixed. paired_verdict reports "lost on head" when one round has a base value and no head value, and a round loses a value when both attempts of its sample time out. At the 25% to 50% timeout rate, and if attempts time out independently, a lat_fs metric would read "lost on head" in 30% to 71% of runs with no code change. paired_verdict checks "lost on head" before the no-verdict list, so Benchmark each change against its base in CI #540 puts the lat_fs check ahead of it, as long as at least one pair is left: 1 to 5 pairs read "too few pairs", and a head that loses a lat_fs metric in every round the base measured still reads "lost on head", because that is not the timeout noise (#540 review). Tier 3 runs on the head build only, so the oci.* metrics reach the dashboard and get no verdict. Only merge runs feed the dashboard, so a pull request or workflow_dispatch run skips Tier 3, which saves about 4.1 min. A metric with no value on either side is "no result" until lat_fs times out under elfuse in the CI Benchmark leg #498 is fixed.
  • One point per merge on the dashboard. The head rounds of the pair are the dashboard sample for Tier 1 and Tier 2, so the chart costs no extra rounds. The median of the base rounds is stored as a second series, so a host shift like the 6f20b3a run shows as both lines moving together. The job can land on either runner, macmini-ci or macmini-m4-hvf-2, but both run on one Mac, so a change of runner is not a change of machine, and no runner label is needed to pin the job. The one macmini-m4-hvf-2 run among the six above is within 3% of the macmini-ci median on every metric except make and oci.python (the largest gaps are oci.jvm -2.7% and lat_proc fork +2.6%).
  • Every merge is measured. The concurrency group is keyed by commit and never cancels, so two quick merges queue on the host lock instead of replacing each other.
  • Thresholds from A/A runs, one per group of metrics. The aa input of workflow_dispatch measures one build on both sides, and a nightly schedule run does the same for the main tip, so the thresholds follow a change of the runners (a macOS update, a different Mac) and every night adds to the count of rows that read slower or faster with no change. One threshold from the largest |ratio - 1| across all metrics would be set by the least steady metric: between runs the lat_syscall group varies by 0.5% to 4.0% and the lat_proc exec, git status and python startup group by 10.8% to 51.9%, so a 10% lat_syscall regression would pass. The metrics are therefore split into a steady group and the rest, from the A/A data, and each group's threshold is the largest per-run |ratio - 1| across that group's metrics in such runs on the CI runners, not one metric's spread and not taken from another project. Each metric's interval is a separate 95% statement, so with m metrics an A/A run has up to about a 1 - 0.95^m chance (64% at m = 20) that some interval excludes 1 (Compare two builds over paired bench rounds #504 review). At the 6 pairs a run takes, the coverage is 96.9%, which gives 47%. The threshold is the first gate against that. Since Benchmark each change against its base in CI #540, bench-report.yml reads the threshold from the repository variable BENCH_REGRESSION_THRESHOLD, which stays unset until the A/A runs on main set it.
  • A verdict is confirmed before it is listed. When a metric reads slower or faster, the job measures 6 more pairs of that metric alone, and the comment lists the verdict only when the second set agrees. An interval that excludes 1 by chance has a probability of about 3.1% per set, so about 0.1% for both sets if the two sets are independent, which brings the 47% above to about 2% at m = 20. Two sets taken minutes apart on one Mac can share drift, the independence caveat from the Compare two builds over paired bench rounds #504 review, so the nightly A/A runs measure the real rate. The Compare two builds over paired bench rounds #504 review also suggested requiring a verdict to hold across several metrics, and the A/A data decides between the two. The schema 3 report has to carry the second set, because bench-report.py recomputes every verdict from the report. This needs a tests/bench-suite.sh option that runs a subset of the metrics.
  • Detection is tested, not only false alarms. A/A runs show how often an unchanged build is flagged, not whether a real regression is caught. workflow_dispatch runs of main against a throwaway branch with a deliberate slowdown on the syscall path (+5%, +10%, +20%) record which sizes read slower.
  • A weekly run against the main of 4 weeks earlier. A merge run compares one merge, so ten merges of +2% each all pass and add up to +22%. The chart would show that, but with the host noise that pairing removes. A weekly schedule run compares the main tip with git rev-list -1 --before='4 weeks ago' main in the same paired run.
  • Path filter without a third-party action. A git diff --name-only "$BEFORE" "$GITHUB_SHA" step decides whether the comparison runs, so no changed-files action is needed. workflow_dispatch skips the filter.
  • Its own workflow. The leg moves from the build.yml matrix to benchmark.yml. A push to main runs in this repository, so its comment job can hold pull-requests: write and find the merged pull request with GET /repos/{owner}/{repo}/commits/{sha}/pulls. A pull request run from a fork gets a read-only token, so bench-report.yml stays and posts that comment through workflow_run, watching benchmark.yml instead of Build. A direct push with no pull request gets a dashboard point and no comment.
  • Pin the dashboard action. benchmark-action/github-action-benchmark is third-party, so it is pinned to a commit SHA, and only the publish job gets the token.

Cost

From the log of main run 42570490049 (job 129048946564): Tier 1 took about 10.6 min, about 4 min of it four #498 timeouts; Tier 2 about 1.1 min; Tier 3 about 4.1 min. The exclusive host lock was held for 15.7 min.

One round of Tier 1 and Tier 2 at one sample is then about 38 s: about 33 s of Tier 1 and 5 s of Tier 2. The sysroot is staged once per job, about 7 s. Six pairs and one discarded round per side are 14 rounds, about 9 min. A pull request run stops there; a merge run adds Tier 3 on the head build, about 4.1 min, so one measured merge holds the exclusive lock for an estimated 13 min. Each #498 timeout adds about 1 min (25% to 50% of lat_fs attempts in CI) until #538 fixes it.

The first run of benchmark.yml on main, run 44836576102 (job 136634428046, 3876e08 against 281f0ce), is the only one measured so far. From its log timestamps: the exclusive host lock was held for 16.6 min. The 14 rounds took 12.9 min, about 40 s for a round without a timeout, and three of them hit a #498 timeout; Tier 3 took 3.7 min. Staging the sysroot took 7 s, under the shared lock. No pair was rerun: the largest calibration spread was 1.5%, under the 6% cut.

Runs Lock time
Before #540: Benchmark leg on every Build run of a pull request 187 runs from 2026-10-11 to 2026-11-10, about 6 per day; nine recent legs that ran to completion took 14 to 17 min about 1.5 h per day
This proposal: pull requests, once each 23 opened from 2026-10-18 to 2026-11-16, under 1 per day; fewer pass the path filter at most about 7 min per day
This proposal: merges that pass the path filter 106 of 120 merges since 2026-08-01, about 1 per day about 13 min per day (16.6 min in the first run)
This proposal: nightly A/A run 1 per day about 9 min per day
This proposal: weekly run against the main of 4 weeks earlier 1 per week about 9 min per week

A workflow_dispatch run or a bench label run adds about 9 min when someone starts one. A confirmation measures only the flagged metrics, so it adds less than 12 full rounds would.

Pull requests

  1. bench-compare.py --paired with the verdict above, taking the threshold as a parameter, and a paired table in bench-report.py, with cases in the existing check-bench-report self-tests. Done in Compare two builds over paired bench rounds #504, merged 2026-11-16.
  2. benchmark.yml and scripts/bench-paired.sh. Done in Benchmark each change against its base in CI #540, merged 2026-11-20. Triggered by pull requests opened as ready or marked ready for review, by pushes to main and by workflow_dispatch (base, head, aa, and pr, which measures a pull request's current merge ref and updates its comment); path filter, with scripts/elfuse-oci.py added because Tier 3 runs through it; base worktree at github.event.before, and no run when the clone lacks it, as after a force push (for a pull request run, refs/pull/N/merge as head and its first parent as base); both builds and the staged sysroot made under the shared host lock, and the exclusive lock held for the rounds and Tier 3 only; one staged sysroot reused by every round through a per-round shadow file (tests/bench-suite.sh -s, BENCH_PAIRED_STAGE); 6 pairs (BENCH_PAIRS, 6 to 32) with the order flipped from pair to pair; lat_fs without a verdict while a pair is left, until lat_fs times out under elfuse in the CI Benchmark leg #498 is fixed; a calibration loop (tests/bench-calib.c) before and after each round that reruns a pair whose readings spread by more than 6% (BENCH_CALIB_SPREAD, half of Apple Silicon P-core frequency drop, P/E-core switching add noise to CI benchmarks #534's step), until a 900 s deadline (BENCH_RERUN_DEADLINE); Tier 3 on the head build of a push run; a per-commit concurrency group; and a comment job on the merged pull request. The leg is removed from the build.yml matrix, and bench-report.yml watches benchmark.yml for the pull request runs. No threshold is set yet, so no metric reads slower or faster: the job summary shows the ratios and intervals, and a comment is posted only when a head value is lost or a push run did not complete; a pr dispatch always updates its pull request's comment. Not run on CI yet: a pull request run through bench-report.yml, a workflow_dispatch run (pr or aa), the force-push path, a calibration rerun, and a posted comment.
  3. Once A/A runs on main have data (workflow_dispatch with aa can start them now that Benchmark each change against its base in CI #540 has landed): the bench label trigger, the nightly A/A and the weekly schedule runs, the two group thresholds, and the confirmation of a slower or faster verdict with 6 more pairs of that metric (with a tests/bench-suite.sh option that runs a subset of the metrics). The runs against a deliberately slowed branch are started by hand through workflow_dispatch.
  4. A publish job for main pushes: flatten the head rounds with a Python script (scripts/bench-dashboard.py, so its self-test runs in make check) and store them in elfuse-bench with customSmallerIsBetter, with the median of the base rounds as a second series. lat_syscall null is served at EL1 without a VM exit, so it gets its own series apart from read/write. Before it can run, elfuse-bench needs a data branch with GitHub Pages serving it, and elfuse needs a repository secret with push access to elfuse-bench.
  5. docs/benchmark.md, holding the qemu and OrbStack reference columns, and the elfuse-aarch64 column removed from tests/bench-baseline.json. The static compare mode of bench-compare.py and bench-promote.py go with it: make bench keeps writing build/bench-results.json, and comparing two local builds uses --paired on alternating rounds of each, at least 6 per side for a verdict and with --threshold set.

Related: #534 measured that each P-core of the CI Mac runs about 12% slower once 3 or more are busy. Since #540, tests/bench-calib.c times a short single-threaded loop before and after each round, and a pair whose four readings spread by more than 6% is measured again.

Activity

  1. added
    enhancement
    on Nov 9, 2026
  2. changed the title [-]Compare benchmark PRs against their base commit[/-] [+]Benchmark each PR against its base commit and chart main on elfuse-bench[/+] on Nov 9, 2026
  3. xalestar commented on Nov 11, 2026

    @xalestar
    CollaboratorAuthor

    From #504 review (#504 (comment)): each paired verdict is a separate 95% interval, so across the dozens of metrics in one run a steady metric can still read slower or faster by chance (about 3% per metric at 6 pairs). #504 documents a lone verdict as advisory. Whether the comment step should require a verdict to hold across several metrics before it posts is left to the A/A runs here, which will show how many such rows a run without any change produces.

    #504 also changed two points of the plan above: the interval is now the exact order-statistic interval of the median instead of a bootstrap, and a verdict needs at least 6 pairs instead of 5, the first count where a 95% interval of the median exists.

  4. 103 remaining items

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

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions