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

The forge's own web process always answers: check cells and crew runs never starve it (readiness flapped with 9 checks) #16251

Merged opened this

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

Merged

I stopped partway through the merge and haven't pushed anything. The working tree is in a half-reset state. Merge result: merging origin/main conflicts in 16 files.

Notes

shipped production is serving it deploy 0adf720

opened this

I stopped partway through the merge and haven't pushed anything. The working tree is in a half-reset state.

Merge result: merging origin/main conflicts in 16 files. Main already has most of this branch's work, built separately. It has src/apps/background.ts, src/kernel/loop_lag.ts, the crew-run cgroup, the board lag series and serving-priority.test.ts. The add/add conflicts come from that overlap. The only commit I found that main lacks is fe7418aed. It reserves CPU for the web process with webReserve and FORGE_WEB_CPUS, and touches src/apps/cgroup.ts, src/core/capacity.ts and their tests. I didn't check the other branch commits against main.

Where it broke: I aborted the merge. Then I ran git reset --hard origin/main to start from main and re-apply only fe7418aed. It failed with this message:

error: unable to unlink old 'src/.mcp.json': Device or resource busy
error: unable to unlink old 'src/web/.mcp.json': Device or resource busy
fatal: Could not reset index file to revision 'origin/main'.

The sandbox keeps those two paths read-only, so git couldn't replace them. git status now shows hundreds of files as modified, which looks like the index and working tree being out of step. I did not run any more git commands that change things.

What I need from you: please fix the checkout from outside the sandbox. A fresh clone, or a reset where src/.mcp.json and src/web/.mcp.json can be written, would do it. With a clean tree I can cherry-pick fe7418aed onto origin/main, resolve its small conflicts in cgroup.ts and cgroup.test.ts, run the tests and push.

Continues #16251

8 earlier comments · 1 event
commented

This change reserves CPU for the web process, following the steward's first step on #3319. Checks and crew runs together can no longer take more than the pod's cores less the reserve.

  • Reserve: the reserve is FORGE_WEB_CPUS cores, 2 by default (1 on a pod under 4 cores). The forge sets cpu.max on R/cells to the pod's cores minus that reserve (in src/apps/cgroup.ts). Every check cell and crew run lives under cells, so /healthz always has those cores, whatever the weights do. The setting is best-effort: where the cpu controller isn't delegated it is skipped, as the weights already are.
  • Check concurrency: the "Checks at once" default is now sized from the cores that remain, floor((cpus − reserve) / (shards × 3)) (webReserve in src/core/capacity.ts). A pod with 25 cores now defaults to 1 check where it used to default to 2.
  • Tests: two new tests cover this. One reads cpu.max off a fake cgroup (8 cores gives 600000 100000), and one covers the reserve defaults, the env override and the sizing.
  • Checks run: tsc is clean and the cgroup and capacity tests pass. I ran bun scripts/gate.ts --fix before pushing; its output wasn't checked.
  • Failing test: serving-priority.test.ts ("the child … run at nice 10") fails here, and it fails the same way without my change, so I left it alone. It expects nice 10 and gets 19, which looks like this sandbox.

I did not cap an admin-set checks.concurrency. The cells ceiling already stops any value from taking the reserve, and a higher setting only makes checks slower. The kernel-level enforcement was not exercised here, because /sys/fs/cgroup is read-only in this sandbox. The event-loop-lag panel and the 12-burner /healthz load test from the issue are not part of this step.

Try it: set FORGE_WEB_CPUS (for example 4) on a pod with a delegated cgroup. Then cat <cgroup root>/cells/cpu.max should show the pod's cores minus 4. Settings → Capacity shows the new "Checks at once" default.

commented

I stopped partway through the merge and haven't pushed anything. The working tree is in a half-reset state.

Merge result: merging origin/main conflicts in 16 files. Main already has most of this branch's work, built separately. It has src/apps/background.ts, src/kernel/loop_lag.ts, the crew-run cgroup, the board lag series and serving-priority.test.ts. The add/add conflicts come from that overlap. The only commit I found that main lacks is fe7418aed. It reserves CPU for the web process with webReserve and FORGE_WEB_CPUS, and touches src/apps/cgroup.ts, src/core/capacity.ts and their tests. I didn't check the other branch commits against main.

Where it broke: I aborted the merge. Then I ran git reset --hard origin/main to start from main and re-apply only fe7418aed. It failed with this message:

error: unable to unlink old 'src/.mcp.json': Device or resource busy
error: unable to unlink old 'src/web/.mcp.json': Device or resource busy
fatal: Could not reset index file to revision 'origin/main'.

The sandbox keeps those two paths read-only, so git couldn't replace them. git status now shows hundreds of files as modified, which looks like the index and working tree being out of step. I did not run any more git commands that change things.

What I need from you: please fix the checkout from outside the sandbox. A fresh clone, or a reset where src/.mcp.json and src/web/.mcp.json can be written, would do it. With a clean tree I can cherry-pick fe7418aed onto origin/main, resolve its small conflicts in cgroup.ts and cgroup.test.ts, run the tests and push.

commented

I couldn't finish the merge, and nothing is pushed. I stopped at the same sandbox limit as last time.

Resolved: main already carries most of this branch, including the cell and crew CPU quotas and the event-loop lag board. I re-applied the one change main lacks, the web-process CPU reserve (fe7418aed), on top of origin/main:

  • src/apps/cgroup.ts: R/cells/cpu.max holds all cells together to the pod's cores less webReserve.
  • src/core/capacity.ts: webReserve and FORGE_WEB_CPUS. It sits next to main's servingCores. The checks default is sized from the cores left after the reserve.
  • Tests: test/cgroup.test.ts and test/capacity-cpus.test.ts are updated.

Checks: bun install, scripts/gate.ts --fix and tsc --noEmit were all clean. test/cgroup.test.ts and test/capacity-cpus.test.ts passed 33 with 3 skipped, none failed.

Where it stopped: to keep history non-force-pushable, I built a merge commit. Its parents are the old branch tip and origin/main, and its tree is main plus the reserve. The final git reset --hard to that commit failed:

error: unable to unlink old 'src/.mcp.json': Device or resource busy
error: unable to unlink old 'src/web/.mcp.json': Device or resource busy
fatal: Could not reset index file to revision '1d4a690ea0fc9076c553ac6aede8c80913a43936'.

The old branch doesn't track those two files and main does, so moving between the two trees tries to unlink read-only paths. The checkout is now in a mixed state: HEAD points at an ours merge commit whose tree is the old branch, not the resolved one. The correct commit is 1d4a690ea0fc9076c553ac6aede8c80913a43936, created but not checked out. I changed nothing more under .git.

What you need to do: from outside the sandbox, run git reset --hard 1d4a690ea0fc9076c553ac6aede8c80913a43936, then git push. It is a plain fast-forward of the branch, with no force. If that commit is missing, the fallback is a fresh checkout of the branch, git merge origin/main, and the three resolutions above.

commented

I merged main into the branch, resolved all 16 conflicts, and pushed. The cgroup, serving-priority, capacity, sampler and starting-boards test files pass (142 pass, 3 skip, 0 fail). I ran only those files, not the whole suite. tsc reports no errors in the files this merge touched. The type check still shows errors in other files (latin1 encodings, missing happy-dom and @vscode/ripgrep), so I only checked the ones the merge touched.

main had already landed most of the same machinery: background class, crew cells, cpu.max quotas, loop-lag gauge, serving board, cells.servingCores. So I took main's version of every conflicted file except the pieces only this pull adds.

What this pull still adds:

  • Reserve: FORGE_WEB_CPUS (default 2, 1 on a pod under 4), through webReserve in src/core/capacity.ts. prepare() in src/apps/cgroup.ts sets cpu.max on R/cells to the pod's cores less that reserve, so every cell and crew run together stays below it.
  • Checks default: it is sized from the cores left after the reserve.
  • Docs and tests: the docs/APPS.md paragraph and env-var row, and the by-hand cpu.max test in test/cgroup.test.ts (8 cores less 2 gives 600000 100000).

Things to check:

  • Two reserves compound. main's cells.servingCores is a cpuset that keeps whole CPUs from cells. This pull's reserve is a quota on the cells together. They are separate knobs and can both apply on a large pod, so say if you want one to give way.
  • README.md is main's version. It was cut from about 2,000 lines to 54 on main. The one line this pull had added to it, naming the Serving board, is gone.
  • gate --fix still flags two things. One is real-timer sleeps in test/serving-priority.test.ts, in code that came from main. The other is two README sections, "Try it" and "Learn more", which main's README already carries. I left both alone.
  • Extra commit. The pre-push hook wanted a commit saying how to try the change, so I added an empty "Try:" commit.

To try it: open /boards/serving. On a host with a delegated cgroup, set FORGE_WEB_CPUS=3 and <R>/cells/cpu.max reads the pod's cores less 3.

commented

<!-- look-pages 9eab0613460d --> Look pages for 9eab061, from the gate:

  • look pages (inferred): this pull changes src/web/asset.ts, src/web/bind.ts, src/web/code_rows_pool.ts and 92 more; the forge pictures / (src/web/asset.ts), /docs (src/web/asset.ts), /explore (src/web/asset.ts) and 28 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
commented

I pushed a commit that tells the look-pages gate this pull needs no page looks. I didn't take pictures of the 31 pages it inferred.

This pull doesn't change any page. The gate listed src/web/asset.ts, src/web/bind.ts and about 92 other web files. Those come from main, merged in, so the diff against the old base makes them look like mine.

What the pull itself changes:

  • the cpu.max reserve on R/cells in src/apps/cgroup.ts
  • the checks-concurrency default in src/core/capacity.ts
  • the matching paragraph and env-var row in docs/APPS.md
  • the test in test/cgroup.test.ts

The commit carries a No look: line saying that, which the gate's message says overrides the inference. If it still wants looks for the merged-in web files, a person will need to pick the pages. I haven't run anything since the last push.

commented

Still red on current main: check failed: gate: rule "the diff is the change": test/welcome.test.ts:104 only rewraps a comment this pull did not write; restore the lines, and keep the diff to the change (`bun scripts/gate.ts --f. Fix it and push.

commented

This pull now reserves CPU for the forge's own web process, so a full lane of checks and crew runs can't starve /healthz. The check's "diff is the change" failures are fixed: the diff against main is down to 5 files.

The earlier rewrap had touched about 1,400 files whose comments this pull never wrote. I merged current main in and restored every file this pull doesn't change to main's text, plus the comment rewraps inside the files it does change. I also made one test restore the environment variable it deletes, because the gate flagged it.

What changed

  • Reserve: every cell and crew run together is held to the pod's cores less FORGE_WEB_CPUS. The default is 2, or 1 on a pod under 4 cores. webReserve in src/core/capacity.ts computes it, and cpu.max on R/cells enforces it in src/apps/cgroup.ts.
  • Checks default: it is sized from the cores that remain after the reserve.
  • Docs: docs/APPS.md describes the reserve.
  • Tests: test/capacity-cpus.test.ts and test/cgroup.test.ts cover the reserve and the checks default. In capacity-cpus, 26 cores less 2 gives 2 checks at once, and 25 gives 1.

Checks run here

  • bun scripts/gate.ts passes. Its only note is one comment line over 100 columns in src/apps/cgroup.ts, which the nightly rewrap handles.
  • bun x tsc --noEmit is clean.
  • The five test files covering this change pass: 68 pass, 3 skipped, 0 fail. I did not run the full suite. scripts/fast.ts said the diff was too broad to name tests, so I picked these five myself.

What I chose not to do

  • I did not rewrap the comments that were already over 100 columns on main, since the gate says to keep the diff to the change.

To try it: set FORGE_WEB_CPUS=3 and /system's cells hold to the pod's cores less 3. Open /boards/serving to see the event-loop lag next to the running checks and crew runs.

I made no page changes, so there is no review block.

Changes requested — before the latest push

I read the diff, the docs and the tests. I did not run the tests, and the preview shows nothing for this change: it touches no page. Three things need fixing in one round.

  1. A second CPU ceiling is added where main already has one. Main's cells.servingCores is a cpuset that keeps whole CPUs from cells. This pull adds a cpu.max quota on R/cells for the same purpose, FORGE_WEB_CPUS, and its own comment says the two compound on a large pod. The owner's rule is "we dont want govenors on this engine", and a new cap where main already holds the cores back breaks it. It also leaves two ways to do one thing. Keep one: reuse servingCores for the reserve and drop the new env var and the cpu.max write. Or, if the quota is truly needed, replace the cpuset in the same pull. Say in the pull which one reserves the cores, and explain it in docs/APPS.md.
  2. The Settings → Capacity help for checks.concurrency still says the default is "the pod's CPUs over three per shard". The default is now sized from the cores less the reserve, so the text a person reads is wrong. Update help in src/core/capacity.ts. The example "80 CPUs give 6" must be recomputed or removed.
  3. Small things:
  • The test title "26 / 12 = 2, not 26 / 12 = 2" contradicts itself. Reword it.
  • docs/APPS.md says "the checks default is sized from what remains" in a broken sentence. Say it plainly.
  • Move the new webReserve import in test/capacity-cpus.test.ts into alphabetical place.
  • The pull has no test that FORGE_WEB_CPUS reaches cpu.max. Add one that sets it, for example to 3 on 8 cores, and expects 500000 100000.
commented

This round drops the second CPU ceiling. cells.servingCores, the cpuset main already has, is now the only thing that reserves cores for the forge's web process.

  • The checks default: Checks at once is now sized from the pod's cores less that reserve. That is servingCoresForCpus, the same default servingCores uses (none under 8 CPUs, then one per 16, at most 4). The shard count still comes from the full core count. Concretely, 80 CPUs keep 4 and give 76 / 12 = 6 checks, and 24 CPUs keep 1 and give 1 check where the whole 24 gave 2.
  • Removed: The cpu.max write on R/cells, FORGE_WEB_CPUS, webReserve, and their tests and doc row. src/apps/cgroup.ts and test/cgroup.test.ts are back to main's text.
  • Capacity help: The checks.concurrency help in src/core/capacity.ts now says the default is the pod's CPUs less the ones kept for the forge, over three per shard.
  • docs/APPS.md: The paragraph now says plainly that cells.servingCores reserves the cores and the checks default is sized from what's left.
  • Tests: The contradictory test title is gone with the old test. A new test in test/capacity-cpus.test.ts checks the sizing by hand for 26 and 24 CPUs, and it would fail without the change.

I did not add the FORGE_WEB_CPUS → cpu.max test you listed, because that mechanism no longer exists. The webReserve import you asked me to reorder went with it.

The default reserve is 0 under 8 CPUs, so a small pod gets no protection from this pull. An admin can raise cells.servingCores there.

I ran test/capacity-cpus.test.ts, test/serving-cores.test.ts and test/cgroup.test.ts: 35 passed, 3 skipped (the kernel-kill cases, which need a delegated cgroup), none failed. tsc --noEmit is clean. gate.ts only noted an over-long comment line in src/apps/cgroup.ts, which is main's own text.

No page changed, so there is no review block.

Approved

Clean and small. The checks-at-once default is now sized from the pod's cores less cells.servingCores, the one existing reserve. The second quota is gone, so there is one way to do it. The Settings help text matches the new sizing (80 CPUs keep 4, 76/12 gives 6). The new test checks 26 and 24 CPUs by hand and fails without the change. No page, input, auth or secret is touched. Nit, not blocking: the added docs/APPS.md sentence is one very long line; wrap it. Note: under 8 CPUs the default reserve is 0, so small pods get no extra protection from this pull; an admin can raise cells.servingCores.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs