Browse documentation

PR micro-benchmarks run one file at a time, interleaved, with a measured noise floor

Date: 2026-12-02 Area: ci, tooling, benchmarking Related: refines ADR 0076

Context

The PR "Benchmark Results" comment marked about half of all benchmarks 🟢 or 🔴 on changes that cannot move them. No-op #2543, which changed only CI, got 132 improved and 130 regressed of 455. Whole files moved together: csv.js ran at 0.61x, typed-arrays.js at 1.93x. From 27 November to 2 December the comment marked a median 56–59% of benchmarks per PR; from 4 to 25 November it marked 16–27%.

GocciaBenchmarkRunner ran files on parallel threads, as many as the processors (four on ubuntu-latest, which is two AMD EPYC cores with two SMT threads each). Only one file's thread at a time holds the JIT (JitOwned). A file's speed so depended on which files ran beside it and whether it held the JIT, which changed from run to run. The comment's ranges were the slowest and fastest of seven back-to-back rounds inside one run, a median 0.5% apart, and main ran in full before the PR. Ranges that narrow called most of the run-to-run movement a change.

A probe on ubuntu-latest measured #2543's two builds. The comparison as it ran marked 272 and 239 benchmarks in two runs, and 267 with GOCCIA_JIT=0 on both sides: running files side by side was the larger cause, the JIT ownership the smaller. With each file in a process of its own, one at a time, the two builds alternating over runs, the median-to-median ratios of the 455 benchmarks lay between 0.976 and 1.015 (5th to 95th percentile), against 0.55 and 1.83 before.

Decision

  • GocciaBenchmarkRunner runs one file at a time unless --jobs asks for more, so every file holds the JIT and none shares the processors. ci.yml's smoke lane, whose timings nothing reads, passes --jobs=4.
  • pr.yml measures with scripts/benchmark-ab.js, the method of the AWFY driver: per file, the main and PR runners alternate over five runs (main first, then the PR first, and so on), each a process of its own on a fresh copy of the binary, at 50 ms calibration and one round. A benchmark's figure is its median run, its range the slowest and fastest run.
  • scripts/benchmark-compare.js marks a change only when every PR run sits outside every main run and the medians differ by more than the benchmark's noise floor: the wider of the two builds' run-to-run ranges, measured on it in that PR run. Anything else reads ~ with its floor. The comment states the median floor.

On the probe's data, five runs a side marked 0 of 455 benchmarks on the no-op change (three with range overlap alone, 21 with three runs a side). Slowing every PR run by a set fraction, the rule marked 33% of benchmarks at 3%, 62% at 5%, 88% at 10% and 97% at 20%.

On real PR runs: a tests-only change (#2547, never merged) got 455 unchanged. A slowdown injected into String.prototype.repeat and trim (#2548, never merged) marked both strings.js benchmarks that call them 🔴 at −86% and −95%; a smaller one marked trim operations at −4.0% (floor 3.6%) and left string repeat at −0.6%, under 1% of its time.

A mark is a consistent difference between the two builds, not always a difference in work. #2546, which changes no engine code, got 24 marks of 1% to 13%, and the two injected slowdowns 14 and 37 marks elsewhere (up to 17%), each with five tight runs a side: changing any unit moves where the linker places engine code, which changes its speed (#1917). Fresh copies sample page placement, not the linker's layout, and hosted runners cannot count instructions to tell placement from work, so the comment says so and points to Judging a change by work and placement.

Consequences

  • The benchmark job takes about 17 minutes instead of 9, about eight more runner-minutes per PR run on a standard runner. It still ends before the AWFY report, so a PR's CI takes no longer.
  • Each run has 2 minutes. After 25 minutes main runs no more and the PR build runs each remaining file once, so its failures still fail the job; the comment marks rows main could not measure in time apart from new ones.
  • A local GocciaBenchmarkRunner benchmarks takes the sum of its files' times. --jobs=N keeps the old speed, with timings that move between runs.
  • A benchmark with a wide run-to-run spread needs a larger change to be marked; its floor is printed beside its delta.
  • The comparison stays advisory and comment-only.