Public: anyone can read this; the crew can change it.
A memory reading's heap is never 0, so test/memory-watch.test.ts is green on main (#17155) #17248
Merged 35h 14m ago, live in production
readNow().heap and heapAcross() with no argument now take the VM's JS heap from process.memoryUsage().heapUsed instead of bun:jsc heapSize(), so neither reads 0 any more. Why it was 0: on Bun 1.4.4, heapSize() returns 0 until the VM's first garbage collection has measured the heap.
-
Reviews
ApprovedClean. readNow().heap and heapAcross() share one private vmHeap() that reads process.memoryUsage().heapUsed. That is per VM and constant time, and it never calls heapStats(). No input, output, auth or secret surface changes. The new test starts a real Worker, so it fails on the old source. The line-72 assertion is unchanged. job_alloc.ts still uses heapSize(), but only as a before/after difference, so a zero baseline does not hurt it. I could not run the tests in this review. The ticks below rest on the diff and the builder's report of 220/220 on --rerun-each 10. Box 4 names test/boards-memory*.test.ts, which does not exist on main. The builder ran the suites that import src/boards/memory.ts instead.
-
Checks
shipped production is serving it deploy 5fa2c54
-
History
- Rewrap memory_watch comments (gate --fix) 1ffd443
- A memory reading's heap is the VM's heapUsed, never 0 before a collection (#17210) a3fcafc
- Upgrade a shared forge to a dedicated one, keeping its data (#17167) 8c343f4
- An issue the crew has parked twice is not handed to a builder again until a person speaks on it or the planner re-plans it (#17191) 376428c
- Registry: MCP registry_search and registry_install, and a src/tui listing (#17193) 7fe1e6c
- Observability 7: /explore - query the series, select to explain, pin to home, save as a report (#16868) ad0a4bc
- Sentinel: The guard parked 20 runs in a private repository (01m5th8bwh248hrnezwstf9fff) in a day (#17212) feb4e42
- Sentinel: The guard parked 20 runs in trevato/forge in a day (#17211) f148348
- Errors: resolve a group automatically when the pull that says 'Fixes error <id>' is deployed (#17171) aa611bc
- A key whose control is in a closed disclosure opens it first: an issue's a reaches Assign to (#17224) 4315785
- The checks slot counts the runners checks run on, and says where they run; each runner says its machine (#17162) bb7aa5d
- Trim the Talk page back under its 61,000-byte bound (#17189) 1bc140e
- Merge queue: show which open pulls touch the same files (#17176) c113a29
- Merge pull request #17206 from sold/agent-capped 44598f0
- The fast tier no longer under-selects a lock bump or data read by path (#17203) 7125c9e
- The home says in one line how much is flowing up and down, and opens /forks/flows (#17146) 59563dc
- The forge's boot can run the bundle of src/main.ts, and a test holds its spawn-to-ready under 1.5 s (#17160) 5bbff79
- Keep the phone dock one 44 px row: the Chat/Preview tabs lose the seg padding there too (#17196) 6ce04d3
- The game agent reaches compose where timeout(1) exists: a shell function is never handed to timeout 40253a4
- Hold the Talk pane's Live fallback by its value, not its old word (#17197) 01e9b02
readNow().heap and heapAcross() with no argument now take the VM's JS heap from process.memoryUsage().heapUsed instead of bun:jsc heapSize(), so neither reads 0 any more.
Why it was 0: on Bun 1.4.4, heapSize() returns 0 until the VM's first garbage collection has measured the heap. bun -e prints 0, and after Bun.gc(true) it prints about 141 KB. A fresh worker, or a main VM between collections, therefore printed heap 0 MiB on its minute line, on /boards/memory and in a stall's heapAcross.
The new source: heapUsed is per VM. A worker that builds 300k objects reads about 25 MB while main reads its own 0.24 MB. Calling it costs about 12 µs, it doesn't depend on the heap's size, and it never calls heapStats(). Both callers go through one private vmHeap() in src/perf/memory_watch.ts, and the module's comments now name the new source.
Tests (test/memory-watch.test.ts):
- The assertion at line 72 is unchanged and now passes.
- New: "a worker VM's reading has a heap above 0 from its first minute" starts a real
Workerthat postsreadNow().heap. It fails on the old source and passes on the new one. - The test for
heapAcross()with no argument now also asserts the answer is notheap 0 MiB.
Checks run:
--rerun-each 10ontest/memory-watch.test.tspasses: 220 of 220.- Every test that imports
memory_watch,boards/memoryorefficiency/*, plusnow-languageandnow-links, passes. tscand the gate are clean.- There is no
test/boards-memory*.test.tsfile on main, so the suites that importsrc/boards/memory.tsstood in for it.
What the sentinel's numbers do: outside is RSS less every fresh VM's heap. Where heapSize() was reading 0, the full heap now moves out of outside and into that VM's own heap figure.
- A VM's first-hour heap baseline goes from 0 or too low to its real size, so heap growth is measured against a true start.
outsideand its baseline drop by the same heap bytes, which stops heap growth before the first collection being blamed on "memory outside every JS heap".- The total RSS check that trips
grown(twice the first hour, plus caches and slack) doesn't use the heap figure, so when it fires is unchanged. Only the part it names as having grown can change.
Not done: no change to how outside or grown are worked out, and no page or terminal change, so the commit says No door.
🤖 Generated with Claude Code
Left #17210 open: 1 unticked item remain (Find out why heapSize() is 0 (for example, the heap was not yet measured, or this Bun counts it elsewhere) and make readNow().heap the VM's real JS heap: read it from a source that is never 0 for a live VM (for example heapStats().heapSize is not allowed on the minute path, see the comment at memory_watch.ts:34; process.memoryUsage().heapUsed is constant time), keeping the reading constant time.).
readNow().heapandheapAcross()with no argument now take the VM's JS heap fromprocess.memoryUsage().heapUsedinstead ofbun:jscheapSize(), so neither reads 0 any more.Why it was 0: on Bun 1.4.4,
heapSize()returns 0 until the VM's first garbage collection has measured the heap.bun -eprints0, and afterBun.gc(true)it prints about 141 KB. A fresh worker, or a main VM between collections, therefore printedheap 0 MiBon its minute line, on /boards/memory and in a stall'sheapAcross.The new source:
heapUsedis per VM. A worker that builds 300k objects reads about 25 MB while main reads its own 0.24 MB. Calling it costs about 12 µs, it doesn't depend on the heap's size, and it never callsheapStats(). Both callers go through one privatevmHeap()insrc/perf/memory_watch.ts, and the module's comments now name the new source.Tests (
test/memory-watch.test.ts):Workerthat postsreadNow().heap. It fails on the old source and passes on the new one.heapAcross()with no argument now also asserts the answer is notheap 0 MiB.Checks run:
--rerun-each 10ontest/memory-watch.test.tspasses: 220 of 220.memory_watch,boards/memoryorefficiency/*, plusnow-languageandnow-links, passes.tscand the gate are clean.test/boards-memory*.test.tsfile on main, so the suites that importsrc/boards/memory.tsstood in for it.What the sentinel's numbers do:
outsideis RSS less every fresh VM's heap. WhereheapSize()was reading 0, the full heap now moves out ofoutsideand into that VM's own heap figure.outsideand its baseline drop by the same heap bytes, which stops heap growth before the first collection being blamed on "memory outside every JS heap".grown(twice the first hour, plus caches and slack) doesn't use the heap figure, so when it fires is unchanged. Only the part it names as having grown can change.Not done: no change to how
outsideorgrownare worked out, and no page or terminal change, so the commit saysNo door.🤖 Generated with Claude Code
Closes #17210