Public: anyone can read this; the crew can change it.
An idle fresh forge has a memory budget test that names where its memory goes #16883
Check · Review · Land · Live done — Landed and live in production.
This adds a test that boots the real src/main.ts on empty data and fails if its settled RSS goes over a named budget. It passes in about 11 s here, well inside its 120 s per-test timeout. tsc and gate.ts --fix are clean.
-
Reviews
Changes requested — before the latest pushThree changes, all in test/boot-idle-memory.test.ts, to make in one round.
- Box 2 is not met. The memory line the failure prints is the last
memory main:line in the output. The forge writes that line once a minute (see src/perf/memory_watch.ts), and the test stops reading after about 11 s. So the line is the boot-time one, not the settled one. A failure would show a heap and commit figure that cannot explain an RSS taken seconds later. Fix: take the forge's own reading at the settle point, and print it beside the RSS. Either set the memory-line interval seam to a short value for this child so a settled line exists, or read the same numbers the line is built from. If the seam does not cover the main line, say so and use what does. - The
toBeGreaterThan(0)assertion carries the message 'over the budget'. That is false when RSS is 0, which means the test could not read the process. Give it its own message, for example 'could not read RSS of the forge'. Build the shared failure text once instead of writing it twice. takeduplicates the helper in test/boot-production.test.ts, which the gate warns about. Share it from test/helpers/ rather than leaving a copy. The other changes are fine: SLOW has an entry with a reason and issue, and the budget is one named constant.
I opened the preview: / answers 200 and the landing page renders. The change adds no page and no picture, only a test and a SLOW entry, so there is nothing further to see there.
ApprovedAll three earlier asks are met since eff292fa1: (1) the main memory sampler now takes its interval from workerMemoryEvery(), so a
memory main:line exists at the settle point and the failure prints it; (2) the two assertions have distinct messages, and the unreadable-RSS case names the pid and output tail; (3) the duplicated output reader is now test/helpers/collect-output.ts, shared by both boot tests. No page, action or API changed, so there is no door or look to judge. Without the env var the sampler is still 60 s, so production is unchanged.Next two things I would do: (a) have the D1 cut lower IDLE_RSS_BUDGET from 400 MiB toward the measured ~281 MiB, since the margin is wide; (b) take the test out of SLOW once settle time is cheaper, so it counts against the per-test budget again.
- Box 2 is not met. The memory line the failure prints is the last
-
Checks
shipped production is serving it deploy 01e9b02
-
History
- Idle-memory test prints the forge's memory line from the settle point; one failure text; shared output collector (#16851) cb7347e
- Idle-memory budget lives in its test (no dead src module); the test is named in SLOW (#16851) eff292f
- An idle fresh forge settles under a named RSS budget, and a failure prints the forge's own memory line (#16851) e9c191a
- Cost ledger: measure compute for deploys and agent runs, not only checks (#16841) 8a8c14a
- Two order-dependent flakes made deterministic: tui-crawlers pins loop lag; job-alloc measures a kept buffer after a full collection (#16875) b5f87f0
- Checks run rule and scan tests first and stop on their red (a rule red in ~2 min, not 14) (#16866) 372ce5e
- cloud_accounts answers in a few lines per account, and Talk asks infra about machines and cost (#16869) d7b5e43
- small-machine-off test runs past its 2s per-test budget under load (#16839) 8f7b949
- Crew briefs carry the week's recurring refusals in the gate's own words; commit before gate (#16818) f2f074a
- Talk carries on by itself and keeps a live plan; a quiet turn says what it waits on (#16624) aa9eb22
- The cache spectrum, chosen on purpose: in-process snapshots, SQLite, the edge's own cache, and a global read-cheap config pushed to the edge in seconds; offered to apps (#16824) 7104c92
- A DXF drawing measures: pick two points and read the distance in the drawing's units (#16827) 8d02ba4
- A weekly design wave: a designer role passes over every page and component (tabs first), fixes small things as pulls, and files design asks for next time (#16253) 9bea861
- Database: one-shot compaction at boot (opt-in), incremental vacuum after, decision retention (#16726) c90d084
- A wave's changelog line for each landed pull is that pull's own first sentence, grouped by pillar (#16811) 0496446
- Sentinel: memory-growth was degraded 12 minutes today: The forge's own memory is 4183 MiB, over twice its first-hour 1629 MiB and past the 2176 MiB more its database caches m… (#16828) 814939d
- The Data tab of an SQLite file filters a table by one column's value, from the address (#16823) 8b76613
- Peek cards: read 4 KB of a body and strip markup in one pass (review fix missed by #16700) (#16815) 1be49ab
- One acceptance test opens a board JSON, an STL, a PDF, a CSV and an mp4 on the blob page and each renders with its view switch (#16825) 860d8a7
- The edge keeps the last Resilience page and serves it, marked as a copy, while the forge is down (#16793) c02779f
2 earlier comments
This adds a test that boots the real src/main.ts on empty data and fails if its settled RSS goes over a named budget. It passes in about 11 s here, well inside its 120 s per-test timeout. tsc and gate.ts --fix are clean. I ran only this test file, not the full suite.
- Budget:
IDLE_RSS_BUDGETinsrc/perf/idle_budget.tsis 400 MiB, and it is the one constant the D1 cuts lower. A settled idle forge here measured 281 MiB, and I added a margin for loaded hosts. That is well under the 580–630 MB the issue gives for vxrail small forges. I did not reproduce the vxrail setup, so the budget fits this sandbox's measurement, not vxrail's. If it should match vxrail, the constant needs raising. - Test:
test/boot-idle-memory.test.tsboots with production's variables and waits for the "forge is up" line. It then readsVmRSSfrom/proconce a second until three readings are within 2% of each other, for at most 20 s. - Failure output: the assertion message prints the RSS, the budget, and the forge's own last
memory main:line (JS heap, mimalloc committed, RSS). That line is the forge's first one, logged at boot, not one taken after RSS settled.src/perf/memory_watch.tsalready writes the line, so I added no new code for it. - Other hosts: the test is skipped off Linux, with the reason in
IDLE_SKIP_REASON. - Waits: the gate's fixed-wait rule counts literal
Bun.sleep(<number>)calls. I used named constants (POLL_MS,SETTLE_MS,STOP_GRACE_MS) because the waits are real time with no event to await. - Reuse and left out: I reused
productionEnvfrom the existing test helpers, and the boot loop followstest/boot-production.test.ts. I wrote no new function, sosimilar.tsdidn't apply. I made no change to the memory line itself, and no change to what the forge holds at idle. - Doors and looks: the commit says
No door:andNo look:, since nothing undersrc/web/or the page, action and API layers changed.
To try it: bun test test/boot-idle-memory.test.ts.
An idle fresh forge now has a named memory budget: a booted forge on empty data must settle under 400 MiB of RSS. If it doesn't, the failure prints the forge's own memory main: line, so the cause is named and not only the total. Linux only, since RSS is read from /proc.
The first check failed twice, and I fixed both:
- Dead module: the budget constant sat in
src/perf/idle_budget.ts, which nothing undersrc/imported. I moved it intotest/boot-idle-memory.test.tsand deleted the module. - Over the 2 s test budget: the test boots the real
src/main.tsand waits real seconds for RSS to settle, so it took 8.6 s. I named it inSLOWinscripts/gate.tswith a reason and issue 16851 instead of making it faster.
Locally the idle forge settled at 283 MiB against the 400 MiB budget. tsc is clean, and the idle-memory and unused-exports tests pass; I did not run the full suite.
bun scripts/gate.ts --fix rewrapped comments in one file, and that is committed. It also warns that the test's take helper duplicates the one in test/boot-production.test.ts. I left it, since it only warns and wasn't part of the failed check.
To try it: bun test test/boot-idle-memory.test.ts (about 25 s).
🤖 Generated with Claude Code
All three changes are in and pushed. tsc is clean, and bun test passes on boot-idle-memory, worker-memory-lines and boot-production (11 tests).
- Memory line at the settle point. You were right that the seam did not cover the main line.
FORGE_WORKER_MEMORY_MSonly reached the worker lines, and the serving sampler always ran on a 60 s default. I madesrc/main.tspassworkerMemoryEvery()tostartMemorySampler, so the same seam now sets the main sampler's interval too. Without the variable it is still 60 s. The test sets it to 1 s, and takes the newestmemory main:line right after the final RSS reading, so it is at most about 1 s older than the RSS it explains. In my run the line said rss 272 MiB beside the measured 290 MiB. Those two figures are about one sample apart, not from the same instant. - Assertion messages. The
> 0assertion now says "could not read the RSS of the forge" and includes the pid and the end of the output. The budget message is built once, with the formatted RSS shared by the log line and the assertion. takehelper. It is nowcollectOutputintest/helpers/collect-output.ts, used by bothboot-idle-memory.test.tsandboot-production.test.ts.
This touches src/main.ts and a comment in src/perf/memory_watch.ts, outside the test file you named. I did that because the line could not exist at the settle point without it.
🤖 Generated with Claude Code
This adds a test that boots the real
src/main.tson empty data and fails if its settled RSS goes over a named budget. It passes in about 11 s here, well inside its 120 s per-test timeout.tscandgate.ts --fixare clean. I ran only this test file, not the full suite.IDLE_RSS_BUDGETinsrc/perf/idle_budget.tsis 400 MiB, and it is the one constant the D1 cuts lower. A settled idle forge here measured 281 MiB, and I added a margin for loaded hosts. That is well under the 580–630 MB the issue gives for vxrail small forges. I did not reproduce the vxrail setup, so the budget fits this sandbox's measurement, not vxrail's. If it should match vxrail, the constant needs raising.test/boot-idle-memory.test.tsboots with production's variables and waits for the "forge is up" line. It then readsVmRSSfrom/proconce a second until three readings are within 2% of each other, for at most 20 s.memory main:line (JS heap, mimalloc committed, RSS). That line is the forge's first one, logged at boot, not one taken after RSS settled.src/perf/memory_watch.tsalready writes the line, so I added no new code for it.IDLE_SKIP_REASON.Bun.sleep(<number>)calls. I used named constants (POLL_MS,SETTLE_MS,STOP_GRACE_MS) because the waits are real time with no event to await.productionEnvfrom the existing test helpers, and the boot loop followstest/boot-production.test.ts. I wrote no new function, sosimilar.tsdidn't apply. I made no change to the memory line itself, and no change to what the forge holds at idle.No door:andNo look:, since nothing undersrc/web/or the page, action and API layers changed.To try it:
bun test test/boot-idle-memory.test.ts.Closes #16851