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 #2255

Closed opened this in answer to
Closed without merging

A check's test workers now stop at its cell's CPU limit instead of the host's CPU count. I did not measure the peak cores on the vxrail before and after, which the issue asked for. Limit passed in: src/checks/service.ts sets FORGECELLCPUS in the check's environment.

Notes

stopped closed without shipping deploy 1eedc3c

opened this

A check's test workers now stop at its cell's CPU limit instead of the host's CPU count. I did not measure the peak cores on the vxrail before and after, which the issue asked for.

  • Limit passed in: src/checks/service.ts sets FORGE_CELL_CPUS in the check's environment. It comes from resolveLimits("step", manifest.limits).cpus, so it is check.limits.cpus from forge.json, capped by the forge's maximum.
  • Shard count: scripts/test-shards.ts now asks a new shardCpus() in scripts/shards.ts how many CPUs it may use. That is the host's count, or FORGE_CELL_CPUS minus 1 for the runner when the limit is lower, and never below 1. shardCount then applies SHARDS_MAX, memory and the number of files as before. With a limit of 16 the check runs 15 workers, however many CPUs the host reports. A missing or malformed value falls back to the host's count.
  • Tests: I added three tests in test/shards.test.ts. One of them pins 80 host CPUs with FORGE_CELL_CPUS=4 to 3 shards. They check the pure function rather than spawning test-shards, so they don't run it on a many-core host as the issue asked.
  • Test results: test/checks.test.ts passes. In test/shards.test.ts, 45 of 46 pass. The one failure is the audit that reads typescript/package.json, which isn't installed in this sandbox. It fails the same way without my change. tsc could not run here for the same reason, so the forge's check is the first type check of this change.
  • Not done:
    • tsc and the tests were already run one after the other in forge.json's run command, so I changed nothing there.
    • I did not touch scripts/flake-hunt.ts, which also reads availableParallelism().

To try it, run FORGE_CELL_CPUS=4 bun scripts/test-shards.ts and it uses at most 3 workers.

🤖 Generated with Claude Code

Closes #2243

3 earlier comments
commented

A check's test workers now stop at its cell's CPU limit instead of the host's CPU count. I did not measure the peak cores on the vxrail before and after, which the issue asked for.

  • Limit passed in: src/checks/service.ts sets FORGE_CELL_CPUS in the check's environment. It comes from resolveLimits("step", manifest.limits).cpus, so it is check.limits.cpus from forge.json, capped by the forge's maximum.
  • Shard count: scripts/test-shards.ts now asks a new shardCpus() in scripts/shards.ts how many CPUs it may use. That is the host's count, or FORGE_CELL_CPUS minus 1 for the runner when the limit is lower, and never below 1. shardCount then applies SHARDS_MAX, memory and the number of files as before. With a limit of 16 the check runs 15 workers, however many CPUs the host reports. A missing or malformed value falls back to the host's count.
  • Tests: I added three tests in test/shards.test.ts. One of them pins 80 host CPUs with FORGE_CELL_CPUS=4 to 3 shards. They check the pure function rather than spawning test-shards, so they don't run it on a many-core host as the issue asked.
  • Test results: test/checks.test.ts passes. In test/shards.test.ts, 45 of 46 pass. The one failure is the audit that reads typescript/package.json, which isn't installed in this sandbox. It fails the same way without my change. tsc could not run here for the same reason, so the forge's check is the first type check of this change.
  • Not done:
    • tsc and the tests were already run one after the other in forge.json's run command, so I changed nothing there.
    • I did not touch scripts/flake-hunt.ts, which also reads availableParallelism().

To try it, run FORGE_CELL_CPUS=4 bun scripts/test-shards.ts and it uses at most 3 workers.

🤖 Generated with Claude Code

commented

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

commented

Declined: already done on main in 12ace390. Main already has the same change: test shards follow the cell's CPU limit instead of the host's (#2260). That commit touches the same four files my branch changes, so the pull conflicts with main. Release ea64226c carries it as well. A person can close the issue. Run log: https://forge.open-platform.sh/trevato/forge/runs/01m526s7kgt610qr1rb7b89qs6 Left open: someone has spoken on this pull.

commented

Closed by the crew: superseded, its change is already on main in 12ace390 ea64226c.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs