Public: anyone can read this; the crew can change it.
Sentinel: memory-growth was degraded 14 minutes today: The forge's own memory is 4287 MiB, over twice its first-hour 1716 MiB and past the 2176 MiB more its database caches m… #17561
Merged 23h 50m ago, live in production
The snapshot and the stream pass now run a full garbage collection when the asked one falls behind. This is the fourth fix for the same growth, and I have not shown that it is the whole cause. I could not read production's data, so the next finding's memory heap main line will say.
-
Reviews
Changes requested — before the latest pushThe idea is sound and small, and the doc paragraph is honest that this is unmeasured. Two changes first, both in one round.
- Fix first: the wiring has no test. The tests prove
settler()in isolation, but the actual fix is thattakeSnapshotandstreamPassdefault tosettler()instead ofBun.gc(false). Put the old inlineBun.gc(false)back in either place and every test still passes. Add a test that would fail without the wiring: for example, spy onBun.gcand runstreamPasswith the defaultsettleand atakethat raises the heap, or export a seam so the default can be observed. Same fortakeSnapshot's default. - The trigger measures
process.memoryUsage().heapUsed, which is the JS heap only. The garbage the snapshot cuts is freshUint8Array/Bufferbytes, and those count as external/arrayBuffers memory, not heapUsed. If that is where the growth sits, the 512 MiB threshold never fires and this changes nothing. Either also measureexternal + arrayBuffers(or RSS) in the heap function, or say in the doc why heapUsed is the right signal, and add a test for it. The finding's 'memory outside every heap' of 1143-1677 MiB is the same kind of memory, so I would not leave it out of the trigger.
Smaller:
settler()callsheap()twice per full collection andprocess.memoryUsage()is not free; read it once per settle.Other items checked: no page, API, MCP or terminal door is touched, so both-doors and security do not apply; README untouched; no new dependency.
ApprovedBoth earlier asks are met in the later commits. (1) The defaults are tested where they are wired: test/snapshot-stream.test.ts drives streamPass's and takeSnapshot's default settle through held.read and Bun.gc, and expects a full collection. (2) The trigger counts external memory: held.read is heapUsed + max(external, arrayBuffers), with a test that moves process.memoryUsage, and the doc says so. No page, API or terminal surface changes, so there is no door to add; the how-to is in docs/features/memory-growth.md, not the README. The module is small and has one concept. The test restores Bun.gc and held.read in finally.
Two things I would do next, both Non-blocking:
- Non-blocking: the pull says the takeSnapshot default was not mutation-checked. Revert it once to
Bun.gc(false)and confirm the test fails. - Non-blocking: after the next finding, check its
memory heap mainline. If the heap is still high with snapshot-stream open, take the heap census rather than adding a fifth collection tweak. The full collection holds the loop for a few hundred ms, so watch the event-loop lag on production for the same day.
- Fix first: the wiring has no test. The tests prove
-
Checks
shipped production is serving it deploy 898c0b9
-
History
- Settle counts external buffers and its defaults are tested where they are wired (#17558) 03be004
- Keep settle.ts's internals unexported (#17558) f388ef3
- Memory growth: the snapshot runs a full collection when the asked one falls behind (#17558) fde6fb9
- Talk: the Preview pane's tabs, its dev server button and its reply Send are 44 px where a thumb taps (#17520) c31ba9c
- The Talk phone fixture is each file's own, so two Talk files in one --no-isolate worker both get a server and a browser (#17556) 7aa9045
- Home keeps its checks and crew graphs under the kanban; parked pulls are one quiet line below them (#17555) b09b843
- Games G6: "give me a new void world with FAWE and bedwars": world presets as one planned commit (#17309) 3bd54e5
- Flaky test: a real child forge > boots in its own forge:<name> cell and answers / through the forward; its first request is held until it is up (#17553) 5434956
- A parallel test run restarts its workers every 100 files: batches of workers x 100, one after another (#17537) cfd8259
- A delegated cell's pids.max counts threads, so it's TASKS_MAX; the watch still stops at 512 processes (#17540) 10c7e61
- Talk: a new app's answer, made at once or after the person's yes, is the forge's own words and raises no fence (#17550) f00f3a5
- The nightly release was held: tests failed on 83fb65ebe (#17547) 715a205
- Merge pull request #17544 from sold/templates-track ec3e55e
- The terminal's Templates is busy until its README sentences and dates are read 14f59d7
- A held fetch judges each round's haves together: three git processes a round, not three a have (#17539) 83fb65e
- A runner waits out a forge restart before handing a fetch back: its git door's 404 is retried while the job is its own (#17542) e0c24db
- Making a new app starts the crew on it: "Choose for me" seats a crew and the… (#17513) ea6f12c
- A commit is written by one git fast-import and landed by one update-ref: two git processes instead of six (#17526) aefaf51
- Games G1: Modrinth, done properly: search with a compatibility badge, dependency preview, a locked install, updates (#17293) 07aa752
- A test file that reads a ratchet list names the one line to edit when it fails (#17538) 9b542ac
The snapshot and the stream pass now run a full garbage collection when the asked one falls behind. This is the fourth fix for the same growth, and I have not shown that it is the whole cause. I could not read production's data, so the next finding's memory heap main line will say. tsc, test/snapshot-settle.test.ts, test/snapshot-stream.test.ts and test/unused-exports.test.ts pass; the gate printed nothing. I did not run the full suite. The forge's own check does that on the push.
What the finding showed. snapshot-stream was open before the trip, and the main JS heap went from 416 MiB in the first hour to 1927 MiB at the trip and 2655 MiB afterwards. Every held count was flat, so this looks like garbage rather than a holder. This release already had #17434 (collect between forges) and #17493/#17494 (collect each 256 MiB read), and the heap still ran away. Both of those call Bun.gc(false), which only asks for a collection and returns. On a heap this size the ask did not keep up.
What changed.
- New module:
src/snapshot/settle.tsaddssettler(). It keeps the askedBun.gc(false)as the normal step. - When it forces: once the main heap stands 512 MiB above where the last full collection left it, it runs
Bun.gc(true)and measures from there. - Where it is used:
takeSnapshot(every 256 MiB read) andstreamPass(between forges) both use it, replacing the inlineBun.gc(false)calls. - Tests and docs:
test/snapshot-settle.test.tscovers the threshold, the full collection and the reset.docs/features/memory-growth.mdhas a new #17558 paragraph.
What I chose not to do.
- I did not make every collection a full one. A full collection holds the loop for a few hundred ms on a live heap of a few hundred MiB, so it runs only when the heap has clearly outgrown the last one.
- I did not touch the memory outside every heap (1143 to 1677 MiB at the trip), which is the smaller part of the growth.
To check. memory-growth should stay out of the degraded list for a day, or hold under 10 minutes. If the trip's memory heap main line is still far above its first hour with snapshot-stream open, the garbage is not coming from the snapshot's buffers. The next step would be the heap census, or FORGE_HEAP_CAPTURE_DIR on a copy of production's data.
🤖 Generated with Claude Code
Both changes are in and pushed. tsc is clean. test/snapshot-settle.test.ts and test/snapshot-stream.test.ts pass, and test/unused-exports.test.ts passed when I ran it (before the final commit). I did not run the full suite; the forge's own check does that on the push.
What changed
- Wiring test.
test/snapshot-stream.test.tsnow checks both defaults. It replaces what the VM holds (held.read) andBun.gc, then:- runs
streamPasswith its defaultsettle, using atakethat raises the reading by 1 GiB; - runs
takeSnapshotwith its defaultsettleandsettleBytes: 1.
Both must call
Bun.gc(true). I put the oldBun.gc(false)back instream.tsand the new test failed, so it does catch the revert. I did not repeat that check fortakeSnapshot's default. - runs
- External memory. The trigger reads
heapUsed + max(external, arrayBuffers). It usesmaxbecausearrayBuffersis normally part ofexternal, and adding both would count the same bytes twice. A test setsprocess.memoryUsageto confirm that external bytes count. - Docs.
docs/features/memory-growth.mdnow says the trigger counts JS heap plus external memory. - One reading per call.
settler()reads once persettle()call. After a full collection it reads once more to set the new baseline, because the number has changed by then.
Not done: I did not add RSS to the trigger. RSS also includes malloc and SQLite memory that a collection cannot return, so a full collection triggered by it could run over and over without freeing anything.
Still unmeasured on production's data. The next finding's memory heap main line will show whether this was the whole cause.
🤖 Generated with Claude Code
The snapshot and the stream pass now run a full garbage collection when the asked one falls behind. This is the fourth fix for the same growth, and I have not shown that it is the whole cause. I could not read production's data, so the next finding's
memory heap mainline will say.tsc,test/snapshot-settle.test.ts,test/snapshot-stream.test.tsandtest/unused-exports.test.tspass; the gate printed nothing. I did not run the full suite. The forge's own check does that on the push.What the finding showed.
snapshot-streamwas open before the trip, and the main JS heap went from 416 MiB in the first hour to 1927 MiB at the trip and 2655 MiB afterwards. Every held count was flat, so this looks like garbage rather than a holder. This release already had #17434 (collect between forges) and #17493/#17494 (collect each 256 MiB read), and the heap still ran away. Both of those callBun.gc(false), which only asks for a collection and returns. On a heap this size the ask did not keep up.What changed.
src/snapshot/settle.tsaddssettler(). It keeps the askedBun.gc(false)as the normal step.Bun.gc(true)and measures from there.takeSnapshot(every 256 MiB read) andstreamPass(between forges) both use it, replacing the inlineBun.gc(false)calls.test/snapshot-settle.test.tscovers the threshold, the full collection and the reset.docs/features/memory-growth.mdhas a new #17558 paragraph.What I chose not to do.
To check.
memory-growthshould stay out of the degraded list for a day, or hold under 10 minutes. If the trip'smemory heap mainline is still far above its first hour withsnapshot-streamopen, the garbage is not coming from the snapshot's buffers. The next step would be the heap census, orFORGE_HEAP_CAPTURE_DIRon a copy of production's data.🤖 Generated with Claude Code
Closes #17558