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

small-machine-off test runs past its 2s per-test budget under load #16839

Merged opened this in answer to

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

Merged

The kept-page cache test in test/small-machine-off.test.ts no longer starts a bun subprocess. I haven't re-measured it under load, only alone. All 9 tests in the file pass, tsc --noEmit is clean, and the gate reports nothing else to fix.

Notes

opened this

The kept-page cache test in test/small-machine-off.test.ts no longer starts a bun subprocess. I haven't re-measured it under load, only alone. All 9 tests in the file pass, tsc --noEmit is clean, and the gate reports nothing else to fix.

  • Cause: it started two bun processes to load kept_page.ts (which pulls in ViewCache and the layout) under a mocked memory size. That was real work, and it's what ran past 2s when four checks shared a machine.
  • Change: the test now fakes the machine size by passing it to cacheBytes(64 MiB, bytes) and cacheShare(bytes) in-process. It checks 512 MiB gives 16 MiB and not a large cache, and 4096 MiB gives 64 MiB and a large cache. One extra assertion, KEPT_PAGE_BYTES === cacheBytes(64 MiB), checks the real module is built from the same formula.
  • Removed: test/fixtures/cache-under.ts, which only that test used, and its mock.module allowance in scripts/test-honesty-allow.json. The gate requires that entry to go.
  • Timing: run alone, the test reports 1.39s. I think that's mostly the one-time import of kept_page.ts (the file's imports already ran the first time through), but I didn't confirm it. The 2.27–2.61s failures were with four checks running at once, so I can't promise a margin under that load.
  • Not done: I didn't raise the 2s budget, add a retry, or skip the test. No source files changed. I didn't run the full suite; the forge's check does that on push.

To try it: bun test test/small-machine-off.test.ts.

Closes #16833

3 earlier comments
commented

The kept-page cache test in test/small-machine-off.test.ts no longer starts a bun subprocess. I haven't re-measured it under load, only alone. All 9 tests in the file pass, tsc --noEmit is clean, and the gate reports nothing else to fix.

  • Cause: it started two bun processes to load kept_page.ts (which pulls in ViewCache and the layout) under a mocked memory size. That was real work, and it's what ran past 2s when four checks shared a machine.
  • Change: the test now fakes the machine size by passing it to cacheBytes(64 MiB, bytes) and cacheShare(bytes) in-process. It checks 512 MiB gives 16 MiB and not a large cache, and 4096 MiB gives 64 MiB and a large cache. One extra assertion, KEPT_PAGE_BYTES === cacheBytes(64 MiB), checks the real module is built from the same formula.
  • Removed: test/fixtures/cache-under.ts, which only that test used, and its mock.module allowance in scripts/test-honesty-allow.json. The gate requires that entry to go.
  • Timing: run alone, the test reports 1.39s. I think that's mostly the one-time import of kept_page.ts (the file's imports already ran the first time through), but I didn't confirm it. The 2.27–2.61s failures were with four checks running at once, so I can't promise a margin under that load.
  • Not done: I didn't raise the 2s budget, add a retry, or skip the test. No source files changed. I didn't run the full suite; the forge's check does that on push.

To try it: bun test test/small-machine-off.test.ts.

commented

The kept-page cache test now checks the real module's sizing, and it takes well under a millisecond. I took your option 1, which means this pull is no longer test-only: it adds one small pure function in src/web/pages/kept_page.ts.

What changed

  • kept_page.ts exports keptPageBytes(machineBytes?), which is cacheBytes(64 MiB, machineBytes). KEPT_PAGE_BYTES is now keptPageBytes(), so /system shows the same value as before.
  • The test calls keptPageBytes directly. It expects 16 MiB at 512 MiB of machine memory and 64 MiB at 4096 MiB. It also checks that KEPT_PAGE_BYTES equals keptPageBytes(). The assertions would fail if the cap or the formula in kept_page.ts changed. The test no longer spawns anything or mocks anything.
  • The old made() helper, which restated cacheShare and cacheBytes, is gone, and the comment that was wrapped mid-sentence went with it.
  • test/fixtures/cache-under.ts and its allow-list entry are still removed.
  • The push hook asked for a "how to try it" commit line. I added an empty commit (Try: …) to satisfy it, since the pull now touches src/web/pages.

Timing

  • I ran the file four times in parallel with a junit report. In every run the kept-page test took about 0.07 ms, and the whole file took about 0.4 s across its tests. The slowest are "a push lands" at about 0.33 s and "the home page answers" at about 0.065 s.
  • The 1.39 s I quoted earlier was bun's startup and import time for the file, not the test's own time. Importing kept_page.ts happens when the file loads, outside any test, so no test's budget pays for it.
  • The 9 tests pass and tsc --noEmit is clean.
  • I did not repeat the original four-checks-at-once load, so the claim rests on the per-test times above.
commented

<!-- look-pages 3d1e7076db0a --> Look pages for 3d1e707, from the gate:

  • look pages (inferred): this pull changes src/web/pages/kept_page.ts; the forge pictures /settings/crew (src/web/pages/kept_page.ts), /settings/crew?help (src/web/pages/kept_page.ts), /settings/captain (src/web/pages/kept_page.ts) and 4 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

The small-machine-off test no longer spawns bun and no longer runs past its 2s budget. It fakes the machine size in-process and checks the real module through keptPageBytes(machineBytes) in src/web/pages/kept_page.ts.

The look-pages note was informational, not a change request. The forge inferred the settings pages that import kept_page.ts. That file only gained the keptPageBytes export, which names the existing cap: 64 MiB, a quarter of a machine under 1 GiB. No markup or style changed, so those pages render the same. I did not run the test or the other pre-push checks again for this push, because it adds only an empty commit.

I pushed an empty commit with a No look: line saying so, which overrides the inferred look pages. I did not add a review block because no page behaviour changed.

To try it: bun test test/small-machine-off.test.ts.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs