Skip to content

Pre-publish benchmark gate fails non-deterministically on unrelated PRs #2436

Open

Description

@carlos-alm

Hit while landing #2434. The gate failed that PR twice on the same commit with two different metrics, and I could not reproduce either locally.

The non-determinism

Commit a2f4c0a4, two runs of the identical job:

run failing metric number
1 Full build 4844 → 6119 (+26%, threshold 25%)
2 (re-run) 1-file rebuild 193 → 392 (+103%, threshold 50%)

A gate that fails on a different metric each time it runs the same commit is not measuring the commit.

It is not the PR under test

Benchmarked three trees on one machine, same command CI uses (benchmark.ts --version dev --dist, native addon built from source in each tree), 6 runs each, the last 3 interleaved round-robin to control for thermal drift:

tree full build (median) 1-file rebuild (median)
#2434 head 2082 ms 121 ms
#2434 base (#2411 e79f8aac) 2260 ms 123.5 ms
main 2306 ms 131.5 ms

The PR under test is the fastest of the three on both metrics, while indexing 801 files to main's 798. Local run-to-run spread is roughly ±30%, which is larger than any difference between the trees — so locally these are indistinguishable, and certainly not a regression.

CI's own numbers say the same thing: the base branch already measured +23% before any of #2434's commits, and the +2-point move that first tripped the gate came from a commit touching only rebuildFile's bail-out paths and a test file — code a full build never executes.

The baseline is drifting release over release

generated/benchmarks/INCREMENTAL-BENCHMARKS.md, native oneFileRebuildMs:

release recorded
3.10.0 66
3.11.0 64
3.11.1 80
3.11.2 83
3.12.0 115
3.13.0 108
3.15.0 117
3.16.0 192

Nearly 3x across six releases, with the largest single jump into the current baseline. The gate only ever compares dev against the newest recorded release, so each release re-anchors to whatever the last one happened to measure, and long-run drift is never surfaced — only the delta since the most recent anchor.

Locally, dev measures ~121 ms against that 192 ms baseline — i.e. faster than the recorded number. On CI it measures 392 ms. So the CI environment, not the code, accounts for the doubling. .github/workflows/ci.yml still carries CODEGRAPH_FAST_SKIP_DIAG: "1" with the comment "pinpoint the cause of the ~2s incremental-rebuild regression observed in CI but not locally (#1066)" — #1066 is closed, but the CI-vs-local discrepancy it describes looks alive.

Why this matters

The gate is needs-blocking on every PR. With the base already reading +23% against a 25% threshold, any PR inherits ~2 points of headroom against a runner whose noise floor is at least that — so PRs fail arbitrarily, and the natural response (re-run until green) trains everyone to ignore the gate.

Suggested directions

  • Record benchmarks on a dedicated/consistent runner, or normalise against a same-run calibration workload rather than a number recorded weeks ago on different hardware.
  • Report medians of N runs rather than a single measurement.
  • Track drift against a fixed anchor release in addition to the rolling one, so multi-release creep is visible.
  • Separately: investigate why 1-file rebuild is ~3x slower in CI than locally, since that gap is what makes the threshold meaningless.

Activity

  1. carlos-alm commented on Aug 10, 2026

    @carlos-alm
    ContributorAuthor

    Another data point, and a sharper one than the original report.

    Three runs of the gate across two commits whose only difference is a merge of main that changes no content (verified: the merged tree is byte-identical to the pre-merge tree):

    run commit full build 1-file rebuild
    1 a2f4c0a4 6119 (+26%) — fail not reached
    2 a2f4c0a4 (re-run) not reported 392 (+103%) — fail
    3 242ce5a2 6101 (+26%) — fail 243 (+26%) — warn

    The 1-file rebuild measured 392 ms and then 243 ms on identical code — a 61% swing between two runs. That single pair is enough to show the metric cannot support a 15% warn / 50% fail threshold: its own reproducibility is worse than the thresholds it gates on.

    The full-build number is more stable (~6100), but it is stable for the base branch too — 5952 and 6011 on e79f8aac before any of the PR's commits. The ~130 ms spread between base and head is 2% of a 6-second measurement, well inside what the 1-file swing shows this runner is capable of.

    Net: the gate has now failed the same PR three times, on two different metrics, none of which reproduce locally (where the PR under test is the fastest of head/base/main on both). The practical effect is that a correct change cannot get a green tick, and the only available responses are to re-roll until lucky or to merge past a red check — both of which erode the gate's value more than turning it advisory would.

  2. carlos-alm commented on Aug 17, 2026

    @carlos-alm
    ContributorAuthor

    Reopening — this got auto-closed by PR #2551's merge, which was unintentional. GitHub's issue-closing keyword matcher is a literal regex (resolves?\s*#N, etc.) with no understanding of negation, so my PR body's sentence "This does not fully resolve #2436" still matched the auto-close pattern on "resolve #2436" despite the "does not" right before it.

    #2551 only fixed one confirmed, mechanical contributor (Full build's missing warmup, mirrored from the pattern already used for the other two metrics) — it explicitly does not address the deeper, confirmed root cause: cross-invocation (CI-runner-to-runner) variance that no in-process median can smooth out, which is what actually makes the gate flaky. That's tracked in #2550, with #2549 covering a related but distinct gap in a different benchmark script. This issue should stay open until one of those lands, or until the gate's non-determinism is otherwise resolved.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions