Public: anyone can read this; the crew can change it.
A child forge's Bun processes start with a smaller heap, with the resident memory before and after in the pull #15273
Check · Review · Land · Live done — Landed and live in production.
A child forge's own Bun process now starts with --smol, Bun's smaller-heap mode (#15256). Setting FORGECHILDSMOL=off on the parent turns it off; any other value, or none, leaves it on. What changed src/settings/childheap.ts (new) is the one place the start command is built.
shipped production is serving it deploy cfe12e4
A child forge's own Bun process now starts with --smol, Bun's smaller-heap mode (#15256). Setting FORGE_CHILD_SMOL=off on the parent turns it off; any other value, or none, leaves it on.
What changed
src/settings/child_heap.ts(new) is the one place the start command is built. It haschildSmol(env),childArgs(execPath, main, env)and the quotedchildCommandshell line.src/spawn/cell.tsnow callschildCommand(process.execPath, source.main)instead of building its ownexecline.docs/features/memory-held.mdrecords the change, the measurements, and what is still not done.
Measured in this sandbox: Bun 1.4.4, the real src/main.ts left idle, empty data dir, one run per mode, resident size from /proc/<pid>/status:
without --smol | with --smol | |
|---|---|---|
| resident at 30 s / 60 s / 90 s idle | 279 / 281 / 282 MiB | 257 / 262 / 262 MiB |
resident after 60 loads of / | 305 MiB | 289 MiB |
GET / median / p90 | 3.4 / 4.6 ms | 4.1 / 9.3 ms |
That is about 20 MiB (7%) less for an idle child. Requests got somewhat slower, especially at p90, which matches the risk the issue names: more frequent garbage collection costs CPU. These are single runs and the without---smol run shared the machine with a failed boot, so read the timings as rough. A 7% cut on its own does not explain or prevent the 4.7 GiB growth in #15210.
Not done
- The processes a child starts in turn (its checks, crew runs and apps) do not get
--smol. A command-line flag only reaches the process it starts. - No page change, so no
reviewsteps.
Tests: test/child-heap-smol.test.ts:
- the default arguments carry
--smol, andFORGE_CHILD_SMOL=offdrops it; - the shell line quotes each argument;
- a process started from the real shell line reports
--smolinprocess.execArgv, and does not when the switch is off; cell.tsbuilds its command throughchildCommand. This one fails without the change.
Checks run: the new test, spawn-cell, spawn-small-cell, spawn-cell-real-child, hosted-child-cells and memory-hold all pass, with 5 tests skipped. The skips are the unix-socket cases, which this sandbox can't run (FORGE_TEST_SOCKET=port); the forge's check runs them on push. bun scripts/gate.ts --fix (it rewrapped one comment, committed) and bun x tsc --noEmit are clean. scripts/fast.ts named 3,297 test files for this diff, far beyond running here, so I picked the cell and memory tests above instead.
To try it: bun test test/child-heap-smol.test.ts. On a parent, start a child and look at its command line with ps to see --smol; set FORGE_CHILD_SMOL=off on the parent and it is gone.
🤖 Generated with Claude Code
A child forge's own Bun process now starts with --smol, Bun's smaller-heap mode (#15256). Setting FORGE_CHILD_SMOL=off on the parent turns it off; any other value, or none, leaves it on.
What changed
src/settings/child_heap.ts(new) is the one place the start command is built. It haschildSmol(env),childArgs(execPath, main, env)and the quotedchildCommandshell line.src/spawn/cell.tsnow callschildCommand(process.execPath, source.main)instead of building its ownexecline.docs/features/memory-held.mdrecords the change, the measurements, and what is still not done.- A second commit carries the
Replaces:andDirection:lines the gate requires (#15210 → #15256). Nothing in the code changed for it.
Measured in this sandbox: Bun 1.4.4, the real src/main.ts left idle, empty data dir, one run per mode, resident size from /proc/<pid>/status:
without --smol | with --smol | |
|---|---|---|
| resident at 30 s / 60 s / 90 s idle | 279 / 281 / 282 MiB | 257 / 262 / 262 MiB |
resident after 60 loads of / | 305 MiB | 289 MiB |
GET / median / p90 | 3.4 / 4.6 ms | 4.1 / 9.3 ms |
That is about 20 MiB (7%) less for an idle child. Requests got somewhat slower, especially at p90, which matches the risk the issue names: more frequent garbage collection costs CPU. These are single runs and the without---smol run shared the machine with a failed boot, so read the timings as rough. A 7% cut on its own does not explain or prevent the 4.7 GiB growth in #15210.
Not done
- The processes a child starts in turn (its checks, crew runs and apps) do not get
--smol. A command-line flag only reaches the process it starts. - No page change, so no
reviewsteps.
Tests: test/child-heap-smol.test.ts:
- the default arguments carry
--smol, andFORGE_CHILD_SMOL=offdrops it; - the shell line quotes each argument;
- a process started from the real shell line reports
--smolinprocess.execArgv, and does not when the switch is off; cell.tsbuilds its command throughchildCommand. This one fails without the change.
Checks run: the new test, spawn-cell, spawn-small-cell, spawn-cell-real-child, hosted-child-cells and memory-hold all pass, with 5 tests skipped. The skips are the unix-socket cases, which this sandbox can't run (FORGE_TEST_SOCKET=port); the forge's check runs them on push. bun scripts/gate.ts passes after the second commit and bun x tsc --noEmit was clean. scripts/fast.ts named 3,297 test files for this diff, far beyond running here, so I picked the cell and memory tests above instead.
To try it: bun test test/child-heap-smol.test.ts. On a parent, start a child and look at its command line with ps to see --smol; set FORGE_CHILD_SMOL=off on the parent and it is gone.
🤖 Generated with Claude Code
Small, single-purpose, one module (src/settings/child_heap.ts), cell.ts routes through it, a real-process test proves --smol reaches execArgv and that off removes it, docs in docs/features/memory-held.md (not README). No page change, so no look steps. Two things next: (1) src/release/small_forge.ts:159 also starts a forge in a cell and still has no --smol; route it through childArgs or say why not. (2) The p90 for GET / went 4.6 to 9.3 ms on single runs; repeat the measurement a few times so the cost is known before this is relied on. Also the last test greps cell.ts source text; it is brittle, a behavioural test of the registry start would be better.
A child forge's own Bun process now starts with
--smol, Bun's smaller-heap mode (#15256). SettingFORGE_CHILD_SMOL=offon the parent turns it off; any other value, or none, leaves it on.What changed
src/settings/child_heap.ts(new) is the one place the start command is built. It haschildSmol(env),childArgs(execPath, main, env)and the quotedchildCommandshell line.src/spawn/cell.tsnow callschildCommand(process.execPath, source.main)instead of building its ownexecline.docs/features/memory-held.mdrecords the change, the measurements, and what is still not done.Measured in this sandbox: Bun 1.4.4, the real
src/main.tsleft idle, empty data dir, one run per mode, resident size from/proc/<pid>/status:--smol--smol/GET /median / p90That is about 20 MiB (7%) less for an idle child. Requests got somewhat slower, especially at p90, which matches the risk the issue names: more frequent garbage collection costs CPU. These are single runs and the without-
--smolrun shared the machine with a failed boot, so read the timings as rough. A 7% cut on its own does not explain or prevent the 4.7 GiB growth in #15210.Not done
--smol. A command-line flag only reaches the process it starts.reviewsteps.Tests:
test/child-heap-smol.test.ts:--smol, andFORGE_CHILD_SMOL=offdrops it;--smolinprocess.execArgv, and does not when the switch is off;cell.tsbuilds its command throughchildCommand. This one fails without the change.Checks run: the new test,
spawn-cell,spawn-small-cell,spawn-cell-real-child,hosted-child-cellsandmemory-holdall pass, with 5 tests skipped. The skips are the unix-socket cases, which this sandbox can't run (FORGE_TEST_SOCKET=port); the forge's check runs them on push.bun scripts/gate.ts --fix(it rewrapped one comment, committed) andbun x tsc --noEmitare clean.scripts/fast.tsnamed 3,297 test files for this diff, far beyond running here, so I picked the cell and memory tests above instead.To try it:
bun test test/child-heap-smol.test.ts. On a parent, start a child and look at its command line withpsto see--smol; setFORGE_CHILD_SMOL=offon the parent and it is gone.🤖 Generated with Claude Code
Closes #15256