Public: anyone can read this; the crew can change it.
Sentinel: memory-growth was degraded 33 minutes today: The forge's own memory is 4600 MiB, over twice its first-hour 1962 MiB and past the 2176 MiB more its database caches m… #17159
Merged 40h 15m ago, live in production
SQL statements pushed out of a connection's statement cache are now finalized rather than left for the garbage collector (#17130). I can't read production's data from here, so this is the most likely cause, not one confirmed there. Why this looks like the cause.
-
Reviews
ApprovedApproved. The change does what #17130 asked. A statement the connection's cache pushes out is finalized once 64 newer ones are pushed out behind it, and
closefinalizes the rest. Radar no longer holds a statement across anawait. The memory-growth how-to is updated and README is untouched. There is no page, terminal or API change, so no second door is owed. The new tests fail without the change: finalized-after-RETIRING_KEPT, the same for list texts, and close leaving no -wal/-shm. The two count limits were widened by exactly the 64 statements that are now really waiting. The diff touches none of the Nevers, and adds no dependency, timer or cap.Two things I would do next:
- Add a test that fails when a module-level or cross-await held statement appears in
src/, since the safety here rests on a one-time scan. A grep-style test next totest/timers-named.test.tswould do it. - Once this is on production, check that
memory outside every heaplevels off. If it does not, the cause is not this one. Then add an eviction counter to thememory holds:line, which mason chose to skip.
- Add a test that fails when a module-level or cross-await held statement appears in
-
Checks
shipped production is serving it deploy a544da9
-
History
- Rewrap the comments the gate rewrapped (#17130) f609362
- A statement the connection's cache pushes out is finalized, not left to the collector (#17130) 6800d3f
- Hosted child forges on a host with Landlock and no bubblewrap are not held by the floor (#17133) a164ff4
- The runs API says where a running check executes: runner:<name>, or forge (#17139) 723f969
- Terminal Capacity screen: say what N checks or crew runs take of the machine (the bridge's room line, slotRoom) (#17124) 9185139
- Production can't read forge.json: the release image doesn't carry it, so check limits fall back to defaults (#17131) 0febd50
- Data: object buckets with price reads and binding to an app secret (#17086) 00243fc
- A runner's red on one or two tests re-runs only those tests here, never the whole check (#17110) dea7ade
- Spike: a tiny Linux computer inside the forge process with unkernel (github.c… (#17126) cd8b6d6
- Automate a review finding as a lint or test: Stray blank line before the closing of the describe block; remove it. (#17104) 6be5e30
- One keymap (c): runs, issues, files and the whole terminal answer the map's keys, one meaning per key at both doors (#17012) 6de23f3
- One page shows my forge's upstream and downstream flows: what I follow, what I offered, what my forks offered me (#17079) 87a7ad4
- Sentinel: 2 deploy runs wait with no slot being used (#17123) c8785d3
- Protection test covers the crew falling back to Landlock when bwrap is missing (#17125) 6e85472
- runner-adopt: the lease test leaves no check queued, so the next test's claim cannot take it (#17118) c7160ee
- A test's leaked process can no longer hang the gate: a shard's output is cut 5 s after it exits (#17117) bb265f4
- Load highlighter grammars only for the file kind opened; split src/tui/screens/workspace.ts (#17109) 2c7070a
- The fast tier guesses for an unseen file by its importers, and reads no doc through a helper the suite runs (#17111) d4b9f5a
- A release that passed its stay-up watch is not called wrong because the last health probe could not connect (#17103) 763fd5a
- The ten test files that cost pull checks the most seconds each finish in under 30 s, with no test skipped (#17030) d1623ea
SQL statements pushed out of a connection's statement cache are now finalized rather than left for the garbage collector (#17130). I can't read production's data from here, so this is the most likely cause, not one confirmed there.
Why this looks like the cause. On #17130, statements kept sat at 1024, the cache's limit, from the trip through to now, while memory outside every JS heap grew from 1281 to 3025 MiB. The forge has more than 1,024 distinct fixed SQL texts, so the main connection's cache keeps replacing statements. Since #16942, a statement it pushed out was only dropped, never finalized. Its compiled program stays in malloc until a full collection, and a heap of a GiB or more rarely runs one. I measured it with the real schema and about 700 MiB of live heap: cycling 60,000 texts through the cache grew RSS from 1017 to 1947 MiB. With finalization on eviction, RSS stayed between 1014 and 1043 MiB.
What changed
src/kernel/list_texts.ts: each connection keeps its last 64 pushed-out statements (RETIRING_KEPT) and finalizes the oldest beyond that. A caller still stepping one in the same turn, such as aniteratewhose loop body runs other queries, finishes first.closefinalizes whatever is left. This needs no timer, so the timer allow-list intest/timers-named.test.tsis untouched.src/flows/radar.ts: this was the one place insrc/that held a statement acrossawaits (the registry lookups). It now callsdb.queryagain at each write.docs/features/memory-growth.md: describes the mechanism, and corrects the line saying a count stuck at 1,024 means "the growth is elsewhere". It now means the cache is turning over.
Tests
- Three new tests in
test/fixed-texts.test.ts:- A pushed-out statement still answers while it is among the last 64.
- One more eviction finalizes it. Without this change it is never finalized, so this test fails.
- List texts behave the same way, and
closefinalizes the waiting statements, so the -wal and -shm files go with it.
- Two existing statement-count limits now allow for the 64 statements waiting to be finalized, because they really are still prepared:
test/fixed-texts.test.ts:FIXED_TEXTS_KEPT + RETIRING_KEPT + 50test/pages-memory.test.ts:LIST_TEXTS_KEPT + RETIRING_KEPT + 20
How I checked held statements
- I ran the whole suite with the caches cut to 4 fixed and 2 list texts, so statements were evicted and finalized constantly. The only use of a finalized statement was in a test file (
test/changelog-api.test.ts, which holds one across awaits). That is safe at the real limit of 1,024, so I left it alone. - A scan of
src/found only the radar case. - Every other failure in that run also fails on
mainin this sandbox (Chromium, cells, boot timeouts) or passes when run alone.
Not done
- I didn't raise
FIXED_TEXTS_KEPT. With finalization, turnover costs a re-prepare but leaves no memory behind. - I didn't add a counter of evictions per minute.
bun x tsc --noEmit and bun scripts/gate.ts pass. bun scripts/fast.ts said the change is too broad to pick tests from, so beyond the full run above I ran the memory, statement-cache, radar and timer suites at the real limits: 82 pass, 0 fail.
To try it: bun test test/fixed-texts.test.ts test/pages-memory.test.ts. On production, memory outside every heap should level off while statements kept stays at 1024, and memory-growth should stay out of the degraded list for a day.
🤖 Generated with Claude Code
SQL statements pushed out of a connection's statement cache are now finalized rather than left for the garbage collector (#17130). I can't read production's data from here, so this is the most likely cause, not one confirmed there.
Why this looks like the cause. On #17130,
statements keptsat at 1024, the cache's limit, from the trip through to now, while memory outside every JS heap grew from 1281 to 3025 MiB. The forge has more than 1,024 distinct fixed SQL texts, so the main connection's cache keeps replacing statements. Since #16942, a statement it pushed out was only dropped, never finalized. Its compiled program stays in malloc until a full collection, and a heap of a GiB or more rarely runs one. I measured it with the real schema and about 700 MiB of live heap: cycling 60,000 texts through the cache grew RSS from 1017 to 1947 MiB. With finalization on eviction, RSS stayed between 1014 and 1043 MiB.What changed
src/kernel/list_texts.ts: each connection keeps its last 64 pushed-out statements (RETIRING_KEPT) and finalizes the oldest beyond that. A caller still stepping one in the same turn, such as aniteratewhose loop body runs other queries, finishes first.closefinalizes whatever is left. This needs no timer, so the timer allow-list intest/timers-named.test.tsis untouched.src/flows/radar.ts: this was the one place insrc/that held a statement acrossawaits (the registry lookups). It now callsdb.queryagain at each write.docs/features/memory-growth.md: describes the mechanism, and corrects the line saying a count stuck at 1,024 means "the growth is elsewhere". It now means the cache is turning over.Tests
test/fixed-texts.test.ts:closefinalizes the waiting statements, so the -wal and -shm files go with it.test/fixed-texts.test.ts:FIXED_TEXTS_KEPT + RETIRING_KEPT + 50test/pages-memory.test.ts:LIST_TEXTS_KEPT + RETIRING_KEPT + 20How I checked held statements
test/changelog-api.test.ts, which holds one across awaits). That is safe at the real limit of 1,024, so I left it alone.src/found only the radar case.mainin this sandbox (Chromium, cells, boot timeouts) or passes when run alone.Not done
FIXED_TEXTS_KEPT. With finalization, turnover costs a re-prepare but leaves no memory behind.bun x tsc --noEmitandbun scripts/gate.tspass.bun scripts/fast.tssaid the change is too broad to pick tests from, so beyond the full run above I ran the memory, statement-cache, radar and timer suites at the real limits: 82 pass, 0 fail.To try it:
bun test test/fixed-texts.test.ts test/pages-memory.test.ts. On production,memory outside every heapshould level off whilestatements keptstays at 1024, andmemory-growthshould stay out of the degraded list for a day.🤖 Generated with Claude Code
Closes #17130