Public: anyone can read this; the crew can change it.

Sentinel: memory-growth was degraded 18 minutes today: The forge's own memory is 5017 MiB, over twice its first-hour 1654 MiB and past the 2176 MiB more its database caches m… #17436

opened this

Merged 36h 1m ago, live in production

The stream pass now collects garbage after each forge (Bun.gc(false) in streamPass, src/snapshot/stream.ts). This is a best guess at the cause, and I could not measure it against production's data. What the evidence says.

Notes

opened this

The stream pass now collects garbage after each forge (Bun.gc(false) in streamPass, src/snapshot/stream.ts). This is a best guess at the cause, and I could not measure it against production's data.

What the evidence says. The main heap went from 595 MiB to 2587 MiB at the trip, then fell back to 513 MiB. No held count rose, so this looks like garbage piling up, not a leak. snapshot-stream was the job open across the trip, as on #17205.

The suspected cause. A pass over N hosted forges lists the bucket N + 1 times, each listing a Set of every chunk key. It also cuts every chunk through fresh buffers. The collector let a whole pass's worth build up before it ran. Collecting between forges keeps the peak at one forge's garbage instead of the whole pass's.

What changed.

  • streamPass takes an optional settle hook, defaulting to Bun.gc(false), and runs it after each forge whether that forge succeeded or failed.
  • test/snapshot-stream.test.ts has a new test checking that settle runs after every forge. That file passes (10 tests) and tsc is clean. I did not run the rest of the suite or scripts/fast.ts; the forge's check runs the full suite.
  • docs/features/memory-growth.md has a new paragraph on this change, including that it is unmeasured.

What I chose not to do. I did not skip the fresh bucket listing before each manifest. It guards against a sweep deleting chunks mid-pass, so removing it is a safety decision for a person.

How to tell if it worked. The next finding's memory heap main line at the trip says whether this was the whole cause. If snapshot-stream is still named there with the heap still spiking, the next step is a heap capture on a copy of production's data (FORGE_HEAP_CAPTURE_DIR).

Closes #17434

commented

The stream pass now collects garbage after each forge (Bun.gc(false) in streamPass, src/snapshot/stream.ts). This is a best guess at the cause, and I could not measure it against production's data.

What the evidence says. The main heap went from 595 MiB to 2587 MiB at the trip, then fell back to 513 MiB. No held count rose, so this looks like garbage piling up, not a leak. snapshot-stream was the job open across the trip, as on #17205.

The suspected cause. A pass over N hosted forges lists the bucket N + 1 times, each listing a Set of every chunk key. It also cuts every chunk through fresh buffers. The collector let a whole pass's worth build up before it ran. Collecting between forges keeps the peak at one forge's garbage instead of the whole pass's.

What changed.

  • streamPass takes an optional settle hook, defaulting to Bun.gc(false), and runs it after each forge whether that forge succeeded or failed.
  • test/snapshot-stream.test.ts has a new test checking that settle runs after every forge. That file passes (10 tests) and tsc is clean. I did not run the rest of the suite or scripts/fast.ts; the forge's check runs the full suite.
  • docs/features/memory-growth.md has a new paragraph on this change, including that it is unmeasured.

What I chose not to do. I did not skip the fresh bucket listing before each manifest. It guards against a sweep deleting chunks mid-pass, so removing it is a safety decision for a person.

How to tell if it worked. The next finding's memory heap main line at the trip says whether this was the whole cause. If snapshot-stream is still named there with the heap still spiking, the next step is a heap capture on a copy of production's data (FORGE_HEAP_CAPTURE_DIR).

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs