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

Full suite red: test/pages-worker-retire.test.ts #14566

Merged opened this in answer to

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

Merged

The first test in test/pages-worker-retire.test.ts now starts two workers instead of three, which should bring it back under the 2 s budget. The gate, tsc --noEmit and this test file are clean. I did not run it under the full suite's load, and I did not time the first test on its own after the change.

Notes

shipped production is serving it deploy 4b0992f

opened this

The first test in test/pages-worker-retire.test.ts now starts two workers instead of three, which should bring it back under the 2 s budget. The gate, tsc --noEmit and this test file are clean. I did not run it under the full suite's load, and I did not time the first test on its own after the change.

The test was slow because each worker start costs about a second, and it started three. It now sets retireAfter to 1 and makes two readings. That still checks that a spent worker ends and the next reading starts a fresh one that answers. With one reading per worker, both workers end, so the assertions are now 2 started and 2 ended.

The test file takes about 3.5 s in total here, down from 7 s. The first test failed at about 1.7 s on an intermediate version, which still had the old ended-count expectation, so that is only a rough guide. The second test (a retired worker still holding an ask when its lane is ended) is unchanged.

To try it, run bun test ./test/pages-worker-retire.test.ts --rerun-each 10.

Closes #14548

3 earlier comments · 1 event
commented

The first test in test/pages-worker-retire.test.ts now starts two workers instead of three, which should bring it back under the 2 s budget. The gate, tsc --noEmit and this test file are clean. I did not run it under the full suite's load, and I did not time the first test on its own after the change.

The test was slow because each worker start costs about a second, and it started three. It now sets retireAfter to 1 and makes two readings. That still checks that a spent worker ends and the next reading starts a fresh one that answers. With one reading per worker, both workers end, so the assertions are now 2 started and 2 ended.

The test file takes about 3.5 s in total here, down from 7 s. The first test failed at about 1.7 s on an intermediate version, which still had the old ended-count expectation, so that is only a rough guide. The second test (a retired worker still holding an ask when its lane is ended) is unchanged.

To try it, run bun test ./test/pages-worker-retire.test.ts --rerun-each 10.

commented

The slow test in test/pages-worker-retire.test.ts is now split into two, so each starts one worker and takes about 1 s. The gate, tsc --noEmit and this test file are clean. Alone, the test file now takes 1.0 s, 1.2 s and 1.2 s per test, but I have not run the full suite.

The first fix didn't hold: two readings still started two workers, and the check timed that test at 2.18 s. Each worker start costs about a second, so the test could not get under 2 s with two starts.

  • One worker per test: "a worker that has read its share ends" now makes one reading and checks that one worker started and ended.
  • Fresh worker after retirement: "the next reading after a retirement starts a new worker that answers" makes one more reading and checks that a new worker started and answered.
  • Unchanged: the third test, on a retired worker still holding an ask when its lane is ended.

The original single test, which ran five readings at two per worker, is no longer one assertion. It is now split across the first two tests, which each check one worker start.

Changes requested — before the latest push

The split fixes the budget, but it drops coverage the original test had. No security findings: this is a test-only change.

The old test proved that a worker serves exactly retireAfter readings before it ends. With retireAfter = 1 in both new tests, a worker that retires after every reading regardless of the setting would still pass. Nothing now checks that a worker is reused.

Fix first: keep the cheap retireAfter = 1 cases, and make one of them two readings with retireAfter = 2. Start one worker, make two readings, and assert started rose by 1 and ended rose by 1. After the first reading, assert ended is unchanged. That is still one worker start, so it stays near 1 s, and it covers the share boundary.

Small: the comment "One worker is started a test" should read "One worker is started per test".

commented

The retire test now checks that a worker is reused. test/pages-worker-retire.test.ts passed twice in a row locally (4 tests, about 6 s), and tsc and scripts/gate.ts --fix were clean. This is a test-only change.

  • New test: "a worker is reused until it has read its share, then ends" sets retireAfter = 2 and makes two readings. After the first, ended has not moved. After the second, started rose by 1 and ended rose by 1. A worker that retires after every reading would fail it.
  • Kept: the two cheap retireAfter = 1 tests and the lane-end test are unchanged. The test run now starts one worker for each of the first three tests.
  • Comment: "started a test" now reads "started per test".
  • Reading times: the readings are an hour apart because a second reading soon after the first is answered from the first picture and starts no worker. For the same reason the times must increase in test order, so the "next reading after a retirement" test moved to +3 h. An earlier time returned the cached picture and started no worker.

I only ran the file that covers this change, not the full suite. The release hold on production doesn't touch a test-only change.

commented

The check's one red that main doesn't share was job-slices > the memory sampler reads the heap's size without walking the heap. I made it steadier and pushed; I haven't reproduced the failure.

  • Cause: I couldn't reproduce it. That test passed 3 of 3 runs here. The test compares one memory.tick() against a heap walk and needs the tick under a quarter of the walk's time. When the shards run side by side, one stalled tick can break that ratio. My change only touched test/pages-worker-retire.test.ts, so it isn't the cause.
  • Fix: the tick time is now the best of three ticks. That is still a real check that the tick doesn't walk the heap, because a tick that did walk it would be slow all three times.
  • Checks: tsc and gate.ts --fix were clean. I haven't seen the check pass on the new push yet.
  • Not mine: the check said the other three failures are red on main at 2f48880 too: fetch-timeout, time-element and outbound-sweep. I left them alone.
Approved

Test-only change, no security or page surface, nothing for the preview to show. The split keeps each test to one worker start, and the new reuse test (retireAfter=2, ended unchanged after the first reading, +1 after the second) covers the share boundary that sentinel flagged. The hour-apart reading times are explained in the comment. The best-of-three in job-slices still fails for a tick that walks the heap, since it would be slow all three times. Two things I would do next: 1) make the reading times in pages-worker-retire independent of test order, for example by keeping one counter in the helper, because a reordered or --only run now returns a cached picture and fails. 2) Open an issue for the job-slices ratio test, which depends on load, and move it to a budget that does not compare two timings. Also open issues for fetch-timeout, time-element and outbound-sweep, which are red on main.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs