sandbox-meter: a member waiting on the kernel in the middle of its work is not settled #230
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/tree-energy-reap-under-load"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Two
sandbox-meterprocess-tree tests failed on loaded hosts. Looking into them found a defect in the tree meter's settle rule, which this fixes, and one test whose claim was stronger than the meter's contract.The defect
The meter took a member for settled when two reads of its counts agreed with no thread on a core or queued between them. A thread in a wait that no signal ends (the kernel's own waits: a block being written, a page being brought in, a lock) passes that rule, because it is off its core and folded. But it runs again when the kernel is done, with nothing arriving, so the member is in the middle of its work. A stop taken there read the span short by the rest of that work, and the reading was whole, with no gap.
Measured on an M4 Max, macOS 27.0.1, with a server whose reply is followed by twenty rounds of a 4 KiB write, an
fsyncand a short burn:The rule
Once
pti_numrunningis zero, the meter asks each thread's own run state (PROC_PIDLISTTHREADS, thenPROC_PIDTHREADINFO). A member with a thread inTH_STATE_UNINTERRUPTIBLEis not settled: it is walked again, and isTreeGap::Unsettledif it never comes to rest inside the bound.fsyncloop: 18 of 60), and none of an idle host's threads was at 5 looks.What it does not close: a member waiting mid-work on something a signal could end (a pipe, a socket, a child, a timer) still reads as settled. The module docs say so.
The tests
a_worker_reaped_while_its_tree_is_walked_is_never_missedasserted that no reading is whole. In one CI run, one round trip of 21 read the worker alive and off every core, counted its record, and was whole: the worker was read, not missed. The test now asserts its name: a whole reading must hold the worker as a member.a_server_that_reaps_its_worker_is_not_wholefailed its equality with the oracle once, at a load past 100 on a host short of memory. That is what a member read while it waits for a page looks like. The run's figures were not kept, so this is the likely cause, not a demonstrated one; the test is unchanged.a_reply_whose_tail_waits_on_the_disk_is_read_once_the_tail_is_done. It fails against the earlier rule on an idle host and passes with this one.Verification
On the build Mac:
cargo test -p sandbox-meter: all pass idle, and in each of twelve full runs under a load past 160 (72 disk-wait round trips, all exact, none with a gap).jcp-gateway,proof-solvers,sandbox-proof,joule-code-remediate.Neither original failure reproduced under CPU load alone, before or after the change; both were seen only on a host that was also short of memory.
🤖 Generated with Claude Code