Repository navigation
test(daemon-client): stop waiting out the contention budget in real time - #4855
Conversation
`ensureDaemon` judges a contended state directory once per attempt and waits `JUDGE_AGAIN_DELAY_MS` between attempts, for `ceil(DAEMON_TEARDOWN_GRACE_MS / JUDGE_AGAIN_DELAY_MS)` attempts. The file already mocks `sleep`, so the waits cost nothing, but every attempt re-reads the registration, and one read of a held lock runs one host process-table snapshot. 300 snapshots of a registration the case keeps alive and unchanged is what made these two tests the slowest in the file and pushed them past the slow-test budget on 2-core runners, and to the 5 s test timeout inside the Stryker dry run. Read the registration's lock inspection once, from the real host, and replay it for the rest of the loop, scoped to that one lock path. The budget is now asserted through the waits it asks for instead of being waited out, so shrinking the loop in production fails these tests.
Size Report
Startup median (7 runs, lower is better):
|
c0bcc39 to
f251a06
Compare
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
This PR is ready at f251a06. The change is test-only and touches no production route. CI is green: 19 checks, none failing. There are no conflicts. Nothing else must happen before merge. Not verified here: the tests and the author's mutations were not run locally, and the timing figures are the author's own measurements. Not blocking, and fine to take or leave: the |
Summary
daemon-client-ensure-explicit-lifecycle.test.tsproved the contention budget by exhausting it.ensureDaemonjudges a contended state directory once per attempt and waitsJUDGE_AGAIN_DELAY_MSbetween attempts, for
ceil(DAEMON_TEARDOWN_GRACE_MS / JUDGE_AGAIN_DELAY_MS)= 300 attempts. The filealready mocks
sleep, so the waits were free — but every attempt re-reads the registration, and oneread of a held lock runs one host process-table snapshot. 300 snapshots of a registration the case
keeps alive and unchanged is the real wall clock.
The two
daemon-lifecycle-contendedtests now read that lock inspection once, from the real host, andreplay it for the rest of the loop, scoped to that one lock path, and assert the attempt budget
through the waits it asks for instead of waiting it out. No production change, no new option.
Measured locally, solo file,
--project unit-core, base and head on the same install and machine:357e0d4a75On 2-core CI runners these two ran 4.7–5.1 s, past the 2.5 s slow-test budget (2x hard limit), and hit
the 5000 ms test timeout inside the mutation gate's Stryker dry run:
Mutants (kernel-errors-3)and(kernel-errors-4)failed three times on #4846, and the Coverage slow-test gate failed once on #4828.Validation
Head
f251a06471, focused checks (no localcheck:affected, per task):packages/daemon-client: 40 files, 351 passed (the 3 gate warnings left are pre-existing, other files)pnpm typecheck,pnpm check:layering,pnpm format,fallow audit --base origin/main,pnpm check:production-exports: cleanENSURE_ATTEMPTShalved →2 failed | 22 passed(150 judge-again waits of 250ms must just cover the 75000ms teardown grace (37500ms)); an off-by-one losing one attempt → the same 2 failures (74750 ms). Both reverted by hand;git statusclean.Unresolved: unrelated tests in this file still do 1–5 real 100–250 ms probe/poll waits (max 1.1 s,
a live daemon on another transport is quiesced). Bounding those means the virtual clockdaemon-client-ensure-drain.test.tsalready has — separate work.