Public: anyone can read this; the crew can change it.

Flaky test: 500 entries: GET /changelog answers in under 50 ms (median of 3 warm runs) #15381

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

test/changelog-timing.test.ts now counts work instead of CPU time, so machine load can no longer make it fail. It is a test-only change; no application code is touched. What it measures: both tests (500 entries, and 500 entries in two chapters) take one warm GET /changelog through pageWork from test/helpers/work.ts.

Notes

shipped production is serving it deploy 496afdb

opened this

test/changelog-timing.test.ts now counts work instead of CPU time, so machine load can no longer make it fail. It is a test-only change; no application code is touched.

  • What it measures: both tests (500 entries, and 500 entries in two chapters) take one warm GET /changelog through pageWork from test/helpers/work.ts. They assert at most 40 SQL statements and at most 8 git spawns, checked with expectWork.
  • Why those bounds: I measured 26 to 28 statements and 3 to 4 git spawns. Both counts stay flat as entries grow, so an N+1 over the 500 entries would exceed them on every run.
  • Clock use: the elapsed time is printed for a person to read and is never asserted. This follows the "Speed is counted in work, never in a clock" principle and the rawBudgets rule in scripts/flake.ts.
  • Test names: the titles no longer say "under 50 ms". They now read "answers in constant work".
  • What I left out: there is no wall-clock check at all any more. The 50 ms promise now rests on the work counts and the printed time.
  • Checks run: bun test test/changelog-timing.test.ts test/flake.test.ts passes (38 tests), and bun scripts/gate.ts --fix and bun x tsc --noEmit ran. The gate rewrapped comments in one file, which is committed.
  • How to try it: run bun test test/changelog-timing.test.ts.

Closes #15380

commented

test/changelog-timing.test.ts now counts work instead of CPU time, so machine load can no longer make it fail. It is a test-only change; no application code is touched.

  • What it measures: both tests (500 entries, and 500 entries in two chapters) take one warm GET /changelog through pageWork from test/helpers/work.ts. They assert at most 40 SQL statements and at most 8 git spawns, checked with expectWork.
  • Why those bounds: I measured 26 to 28 statements and 3 to 4 git spawns. Both counts stay flat as entries grow, so an N+1 over the 500 entries would exceed them on every run.
  • Clock use: the elapsed time is printed for a person to read and is never asserted. This follows the "Speed is counted in work, never in a clock" principle and the rawBudgets rule in scripts/flake.ts.
  • Test names: the titles no longer say "under 50 ms". They now read "answers in constant work".
  • What I left out: there is no wall-clock check at all any more. The 50 ms promise now rests on the work counts and the printed time.
  • Checks run: bun test test/changelog-timing.test.ts test/flake.test.ts passes (38 tests), and bun scripts/gate.ts --fix and bun x tsc --noEmit ran. The gate rewrapped comments in one file, which is committed.
  • How to try it: run bun test test/changelog-timing.test.ts.
Approved

Test-only change that replaces the flaky CPU-time check on GET /changelog with counted work. It uses the existing pageWork/expectWork helpers, so it follows the repo pattern and the no-clock principle. The bounds are 40 SQL statements and 8 git spawns, against 26-28 and 3-4 measured. They do not grow with entries, so an N+1 over the 500 entries would fail them. Elapsed time is printed and never asserted. No app code, dependency or README is touched. Two things I would do next: (1) add a guard that the statement count is the same at 50 and 500 entries, so the test pins constancy and not only a ceiling; (2) drop the printed ms line once the Server-Timing phases are logged elsewhere, to keep test output quiet.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs