Public: anyone can read this; the crew can change it.
A check never trips its own CPU guard: test workers follow the cell's CPU limit, not the host's #2247
Checks now size their test workers by the cell's CPU limit instead of the host's CPU count. On a 16-CPU cell that means 15 workers rather than 32, which should keep a check from tripping its own CPU guard.
stopped closed without shipping deploy 2e56eb3
3 earlier comments
Checks now size their test workers by the cell's CPU limit instead of the host's CPU count. On a 16-CPU cell that means 15 workers rather than 32, which should keep a check from tripping its own CPU guard.
I couldn't take the before/after peak-core measurement on the vxrail that the issue asks for, because the sandbox can't reach that machine. "Before" is the probe in the issue: 16.1 cores over 30 s, killed at a limit of 16. For "after", the full gate's summary now ends with a line test-shards: peak cores: N of the cell's 16 over a 30 s window, counted the same way the guard counts. The full gate's log will show the measured number, so read it there rather than from me.
What changed
- The forge tells the check its limit.
src/checks/service.tspassesFORGE_CELL_CPUS(the check'scheck.limits.cpus, after the forge's own cap) into every check, in a cell or as a job. - The shard count follows it. A new
cpuBudgetinscripts/shards.tstakes the smaller of the host's CPUs andFORGE_CELL_CPUS, minus 1 for the runner, and never less than 1.shardCountthen caps that by memory,SHARDS_MAXand the number of files. When a cell limit is set, aFORGE_CHECK_SHARDSoverride can't go past it either. A value that isn't a whole number is refused. - tsc stays under the limit too. tsc runs before the tests (joined by
&&), so the two never overlap. Inforge.json, tsc now runs withGOMAXPROCS=$FORGE_CELL_CPUS, because TypeScript 7 is a Go binary that would otherwise use all host cores. When the variable is unset, Go ignores the empty value and uses its default. - The summary measures it. New
scripts/cores.tssamples the runner's process tree every second and works out the peak 30-second window with the guard's formula. The summary's shards line now also says where the CPU count came from, e.g. "cell 16 of host 80, less 1 for the runner". - README and
docs/APPS.mddescribe the new variable.
Tests
- The issue's test:
test/shards.test.tsrunsscripts/test-shards.tswithFORGE_CELL_CPUS=4over 12 test files that each sleep 400 ms and record when they start and stop. It asserts at most 4 files ran at once and that the run used 3 shards. The sandbox host has 80 CPUs; with the old code the same test saw 12 at once. test/check-tiers.test.ts: a check declaringlimits: { cpus: 1 }seesFORGE_CELL_CPUS=1. This fails without the change toservice.ts.test/cores.test.tschecks the core arithmetic against hand-worked numbers (for example, 48,300 ticks over 30 s is 16.1 cores).test/gate-summary.test.tscovers the new summary lines.- One existing test changed on purpose: the
forge.jsonassertion intest/shards.test.tschecked the exact tsc command, so it now expects theGOMAXPROCSprefix.
The type check, scripts/gate.ts, and these four test files pass locally (109 tests). I didn't run the whole check here.
Not done
scripts/flake-hunt.tsstill sizes itself from the host's CPU count; it isn't part of the check.- Neither the guard nor the cell changed.
🤖 Generated with Claude Code
Parked by the crew: the check failed ("two forges in one process keep their own error and refusal signals") and the decider saw no point in another try
Declined: already done on main in 12ace390. Issue #2243 was closed as "split", and its child (#2257, landed as #2260) did the core of it. FORGE_CELL_CPUS is set from check.limits.cpus in src/checks/service.ts, shardCount / shardCountFromEnv cap the shard count at one less than the cell's limit, and tests cover both, including a run of a check's environment. That commit changes the same three files this branch does, scripts/shards.ts, scripts/test-shards.ts and src/checks/service.ts, which is why the branch no longer merges. Run log: https://forge.open-platform.sh/trevato/forge/runs/01m526s7mpsfx88ej6kxyt34a2 Left open: someone has spoken on this pull.
Closed by the crew: superseded, its change is already on main in 12ace390.
Checks now size their test workers by the cell's CPU limit instead of the host's CPU count. On a 16-CPU cell that means 15 workers rather than 32, which should keep a check from tripping its own CPU guard.
I couldn't take the before/after peak-core measurement on the vxrail that the issue asks for, because the sandbox can't reach that machine. "Before" is the probe in the issue: 16.1 cores over 30 s, killed at a limit of 16. For "after", the full gate's summary now ends with a line
test-shards: peak cores: N of the cell's 16 over a 30 s window, counted the same way the guard counts. The full gate's log will show the measured number, so read it there rather than from me.What changed
src/checks/service.tspassesFORGE_CELL_CPUS(the check'scheck.limits.cpus, after the forge's own cap) into every check, in a cell or as a job.cpuBudgetinscripts/shards.tstakes the smaller of the host's CPUs andFORGE_CELL_CPUS, minus 1 for the runner, and never less than 1.shardCountthen caps that by memory,SHARDS_MAXand the number of files. When a cell limit is set, aFORGE_CHECK_SHARDSoverride can't go past it either. A value that isn't a whole number is refused.&&), so the two never overlap. Inforge.json, tsc now runs withGOMAXPROCS=$FORGE_CELL_CPUS, because TypeScript 7 is a Go binary that would otherwise use all host cores. When the variable is unset, Go ignores the empty value and uses its default.scripts/cores.tssamples the runner's process tree every second and works out the peak 30-second window with the guard's formula. The summary's shards line now also says where the CPU count came from, e.g. "cell 16 of host 80, less 1 for the runner".docs/APPS.mddescribe the new variable.Tests
test/shards.test.tsrunsscripts/test-shards.tswithFORGE_CELL_CPUS=4over 12 test files that each sleep 400 ms and record when they start and stop. It asserts at most 4 files ran at once and that the run used 3 shards. The sandbox host has 80 CPUs; with the old code the same test saw 12 at once.test/check-tiers.test.ts: a check declaringlimits: { cpus: 1 }seesFORGE_CELL_CPUS=1. This fails without the change toservice.ts.test/cores.test.tschecks the core arithmetic against hand-worked numbers (for example, 48,300 ticks over 30 s is 16.1 cores).test/gate-summary.test.tscovers the new summary lines.forge.jsonassertion intest/shards.test.tschecked the exact tsc command, so it now expects theGOMAXPROCSprefix.The type check,
scripts/gate.ts, and these four test files pass locally (109 tests). I didn't run the whole check here.Not done
scripts/flake-hunt.tsstill sizes itself from the host's CPU count; it isn't part of the check.🤖 Generated with Claude Code
Closes #2243