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

Memory held, not hit: slow or refuse new processes in a Small child near its limit before any stop #11982

Parked opened this
Closed without merging

This pull covers part of fault 2 from #11975: a Small child near its memory limit now starts no new work, so the host's stop becomes less likely. The rest of fault 2 is not done (listed below). The gate and tsc are clean.

Notes

stopped parked by the crew deploy d9f0fa0

opened this

This pull covers part of fault 2 from #11975: a Small child near its memory limit now starts no new work, so the host's stop becomes less likely. The rest of fault 2 is not done (listed below). The gate and tsc are clean. I ran only the new tests and the neighbouring dispatch, checks and vitals suites (all green). I did not run the full suite, because scripts/fast.ts reported 2494 of 2992 files, so I picked the covering ones. I did not run it in a real cell, so nothing here shows the 2 GiB journey fits.

What changed

  • New src/spawn/memory_guard.ts reads the forge's own cgroup through selfUse. At 70% of its size's memory limit (MEMORY_HOLD), a child refuses to start new work. A forge that is not a cell child is never refused.
  • runStep (src/apps/process.ts) will not start a check cell when held. It logs one line and fails with the refusal, as the 80%-disk guard does.
  • The check pick (startable in src/checks/service.ts) leaves checks queued while held. A step refused for memory is queued again with MEMORY_HELD_SUMMARY and never goes red.
  • The dispatcher (src/crew/dispatch.ts) leaves queued crew runs queued, one log line each. It records them under a new hold cause memory, which vitals names as "the forge being near its memory limit".
  • Tests are in test/memory-held.test.ts; the how-to is docs/features/memory-held.md.

Not done (stays open on #11975)

  • Smaller heap (--smol) for the child's Bun processes.
  • Test shards one at a time.
  • Reclaiming idle app cells.
  • A stop that takes the largest process instead of the whole forge. The host-side stop in src/apps/contain.ts is unchanged.
  • An agent's own shell commands are not gated, because they are not started through runStep. A single builder run can still push the forge past the limit. Fault 1 (a first ask makes a new app) is what should keep that run small.
  • Faults 1 and 4 are separate pulls.
  • Not proven for a real Small forge: 70% is a threshold I chose, not a measured one.

Try it: there is no page change. In a child forge with FORGE_CELL_SIZE=small, push a check while it uses 70% or more of 2 GiB. The check log shows queued, not started: this forge is using … and the run stays queued until memory drops.

🤖 Generated with Claude Code

Closes #11980

3 earlier comments
commented

This pull covers part of fault 2 from #11975: a Small child near its memory limit now starts no new work, so the host's stop becomes less likely. The rest of fault 2 is not done (listed below). The gate and tsc are clean. I ran only the new tests and the neighbouring dispatch, checks and vitals suites (all green). I did not run the full suite, because scripts/fast.ts reported 2494 of 2992 files, so I picked the covering ones. I did not run it in a real cell, so nothing here shows the 2 GiB journey fits.

What changed

  • New src/spawn/memory_guard.ts reads the forge's own cgroup through selfUse. At 70% of its size's memory limit (MEMORY_HOLD), a child refuses to start new work. A forge that is not a cell child is never refused.
  • runStep (src/apps/process.ts) will not start a check cell when held. It logs one line and fails with the refusal, as the 80%-disk guard does.
  • The check pick (startable in src/checks/service.ts) leaves checks queued while held. A step refused for memory is queued again with MEMORY_HELD_SUMMARY and never goes red.
  • The dispatcher (src/crew/dispatch.ts) leaves queued crew runs queued, one log line each. It records them under a new hold cause memory, which vitals names as "the forge being near its memory limit".
  • Tests are in test/memory-held.test.ts; the how-to is docs/features/memory-held.md.

Not done (stays open on #11975)

  • Smaller heap (--smol) for the child's Bun processes.
  • Test shards one at a time.
  • Reclaiming idle app cells.
  • A stop that takes the largest process instead of the whole forge. The host-side stop in src/apps/contain.ts is unchanged.
  • An agent's own shell commands are not gated, because they are not started through runStep. A single builder run can still push the forge past the limit. Fault 1 (a first ask makes a new app) is what should keep that run small.
  • Faults 1 and 4 are separate pulls.
  • Not proven for a real Small forge: 70% is a threshold I chose, not a measured one.

Try it: there is no page change. In a child forge with FORGE_CELL_SIZE=small, push a check while it uses 70% or more of 2 GiB. The check log shows queued, not started: this forge is using … and the run stays queued until memory drops.

🤖 Generated with Claude Code

commented

Nothing needs fixing and I pushed nothing new. The preview deploy didn't fail on anything in my change.

  • Deploy log: it shows the app starting, ready:, serving and done:, with no error. The preview answers 200 at /.
  • "No tests declared, none run": this is the state of the preview deploy, not a failure. forge.json has no app-level test for it. The tests run through the check block, and that check reads green on #11982 at head f89250b.
  • Possible tooling issue: if that "no tests declared" line is what marked the deploy failed, that looks like a deploy-tooling issue. A repo whose tests all run in check would hit it on every pull.

Pull #11982 is otherwise unchanged and its description still applies.

commented

This push fixes the gate failure: two comment lines were over 100 columns, and I rewrapped them. The gate and bun x tsc --noEmit now pass locally. I did not rerun the tests, because the change only moves line breaks inside comments.

  • Changed: the comment at src/crew/dispatch.ts:1706 and the one at src/checks/service.ts:932. No code changed.
  • Why the gate stayed red at first: it reads the lines the pull adds from the commit, so it only went green once I committed the rewrap.

The pull still holds new work in a child near its memory limit (#11980). Checks and crew runs stay queued instead of failing or being refused.

commented

Parked by the crew: the check stayed red through 2 automatic tries: the forge kept going away under this check (4 times); not trying again

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs