Skip to content

ci: fail a PR if any test gets more than 1.5x slower than master - #4028

Merged
rom1504 merged 1 commit into
masterfrom
test-duration-regression
Aug 30, 2026
Merged

ci: fail a PR if any test gets more than 1.5x slower than master#4028
rom1504 merged 1 commit into
masterfrom
test-duration-regression

Conversation

@u9g

@u9g u9g commented Aug 30, 2026

Copy link
Copy Markdown
Member

What

Recent PRs (#3977, #3984, #3999, #3990, ...) cut a lot of fixed sleeps out of the external tests. Nothing stops them creeping back in, and a fixed wall-clock budget doesn't work here since runtime is dominated by server startup and varies per version. So: compare per-test durations against master's last run and fail on a 1.5x regression.

How

  • test/common/durationsReporter.js: the spec reporter, plus a { "<test title>": ms } file of passing tests written to $DURATIONS. mocha_test now uses it; log output is unchanged.
  • test/common/compareDurations.js <baselineDir> <currentDir>: for each test present in both runs, fail if it took more than 1.5x its baseline and at least 5s longer (so sub-second tests can't fail on jitter). Prints a baseline -> now table per version. Tests without a baseline are skipped.
  • ci.yml: restore the last master baseline for the version group from actions/cache (durations-<job-index>-*), run the comparison after the tests, and on pushes to master save the run as the new baseline. Rebaselining is automatic, no committed files.

Only tests that passed count, and with --retries 3 mocha records the passing attempt's duration, so a flaky retry doesn't register as a slowdown.

Verification

Locally against the internal tests: 632 durations recorded with the spec output intact; the compare script exits 1 when a test goes 1s -> 20s, 0 when identical, and skips cleanly with no baseline. The first CI run on master seeds the cache; PRs before that just print "no baseline yet".

@u9g
u9g force-pushed the test-duration-regression branch from e6f8adf to 921003b Compare August 30, 2026 15:25
@u9g u9g changed the title ci: fail a PR if any test gets more than 2x slower than master ci: fail a PR if any test gets more than 1.5x slower than master Aug 30, 2026
The spec reporter now also writes a JSON of per-test durations (DURATIONS=...).
CI restores the last master run's durations for the version group from
actions/cache, and test/compareDurations.js fails the job if a test that
passed in both runs took more than 1.5x its baseline (ignoring jumps under 5s,
which are server/network jitter). Every push to master saves a fresh baseline,
so the numbers track the tests as they change.
@u9g
u9g force-pushed the test-duration-regression branch from 921003b to 555505c Compare August 30, 2026 15:27
@rom1504

rom1504 commented Aug 30, 2026

Copy link
Copy Markdown
Member

I like it but I think it might fail. Let's try it out and adapt if anything doesn't work

@rom1504
rom1504 merged commit f603758 into master Aug 30, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants