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

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

opened this

Merged 28h 29m ago, live in production

Every few minutes, the stream pass that backs up each hosted forge now keeps the bucket's chunk keys in memory once between forges instead of twice. This is a likely cause of the main heap growth in this finding, but not a proven one: it is measured on a local benchmark, not on production's data. Why this spot.

Notes

opened this

Every few minutes, the stream pass that backs up each hosted forge now keeps the bucket's chunk keys in memory once between forges instead of twice. This is a likely cause of the main heap growth in this finding, but not a proven one: it is measured on a local benchmark, not on production's data.

Why this spot. The finding has snapshot-stream open across the trip, which also happened in #17434, #17493, #17558 and #17760. The release it came from (bdc702efdbe1) already had all four fixes. The main heap went from 431 MiB in the first hour to 1685 MiB at the trip, and every held count stayed flat. Earlier fixes all made garbage get collected sooner while chunks are being sent. They did nothing for the check before each forge's manifest, which sends nothing. That check built a Set from a fresh listing of the whole bucket while the pass's own view, a Set of the same keys, was still held. So every key was in memory twice, plus the listing's array, and nothing triggered a collection.

What changed (src/snapshot/snapshot.ts):

  • missingChunks builds a small Map of only the keys the manifest names and goes through the listing deleting them. It no longer makes a Set of the listing. Its unused listed callback is gone. The other two callers, verify.ts and mirror.ts, get the same answer in the same order.
  • takeSnapshot hands on the Set it worked from: what it started with plus every chunk it sent. Before, it handed on the fresh listing.
  • The check before each manifest is still a fresh listing. If the view claims a chunk the store has lost, the forge skips sending it, the check fails, no manifest is written and the view is dropped, so the next forge lists afresh.

Measured off production. I ran four snapshots in a row against a store listing a million chunk keys. Peak main heap was 281 MiB, against 323–575 MiB before. Either way, 146 MiB is held afterwards (the one view). The next finding's memory heap main line at the trip will show whether this was all of it. That note is added to docs/features/memory-growth.md, following the earlier entries.

Tests (test/snapshot-stream.test.ts):

  • The view a forge hands on is the same Set it started from, grown by what it sent. This test fails without the change.
  • A view that names a chunk the store has lost writes no manifest and leaves the old one in place, drops the view, and the next take sends the chunk again and restores.

Checks. The type check passes, and the gate passes all 32 rules. I ran the snapshot, drill and repo-wide rule tests: 326 pass. scripts/fast.ts named 553 files (about 40 minutes), too broad to run here, so the rest is left to the forge's check.

Not done.

  • No paged list on the Store interface. That would keep even the listing's array from being built in one piece, but it changes every store implementation.
  • No change to the collection thresholds.
  • No page or terminal changes, so the commit says No door.

Review steps (nothing visible changes; this is for reading the next sentinel finding):

[{"go":"/system","look":"Forge memory: the memory-growth need and the main heap figure","expect":"Across a day with stream passes, memory-growth stays out of the degraded list, or the main heap at a trip no longer climbs past ~2x its first hour while snapshot-stream is open"}]

🤖 Generated with Claude Code

Closes #17851

commented

Every few minutes, the stream pass that backs up each hosted forge now keeps the bucket's chunk keys in memory once between forges instead of twice. This is a likely cause of the main heap growth in this finding, but not a proven one: it is measured on a local benchmark, not on production's data.

Why this spot. The finding has snapshot-stream open across the trip, which also happened in #17434, #17493, #17558 and #17760. The release it came from (bdc702efdbe1) already had all four fixes. The main heap went from 431 MiB in the first hour to 1685 MiB at the trip, and every held count stayed flat. Earlier fixes all made garbage get collected sooner while chunks are being sent. They did nothing for the check before each forge's manifest, which sends nothing. That check built a Set from a fresh listing of the whole bucket while the pass's own view, a Set of the same keys, was still held. So every key was in memory twice, plus the listing's array, and nothing triggered a collection.

What changed (src/snapshot/snapshot.ts):

  • missingChunks builds a small Map of only the keys the manifest names and goes through the listing deleting them. It no longer makes a Set of the listing. Its unused listed callback is gone. The other two callers, verify.ts and mirror.ts, get the same answer in the same order.
  • takeSnapshot hands on the Set it worked from: what it started with plus every chunk it sent. Before, it handed on the fresh listing.
  • The check before each manifest is still a fresh listing. If the view claims a chunk the store has lost, the forge skips sending it, the check fails, no manifest is written and the view is dropped, so the next forge lists afresh.

Measured off production. I ran four snapshots in a row against a store listing a million chunk keys. Peak main heap was 281 MiB, against 323–575 MiB before. Either way, 146 MiB is held afterwards (the one view). The next finding's memory heap main line at the trip will show whether this was all of it. That note is added to docs/features/memory-growth.md, following the earlier entries.

Tests (test/snapshot-stream.test.ts):

  • The view a forge hands on is the same Set it started from, grown by what it sent. This test fails without the change.
  • A view that names a chunk the store has lost writes no manifest and leaves the old one in place, drops the view, and the next take sends the chunk again and restores.

Checks. The type check passes, and the gate passes all 32 rules. I ran the snapshot, drill and repo-wide rule tests: 326 pass. scripts/fast.ts named 553 files (about 40 minutes), too broad to run here, so the rest is left to the forge's check.

Not done.

  • No paged list on the Store interface. That would keep even the listing's array from being built in one piece, but it changes every store implementation.
  • No change to the collection thresholds.
  • No page or terminal changes, so the commit says No door.

Review steps (nothing visible changes; this is for reading the next sentinel finding):

[{"go":"/system","look":"Forge memory: the memory-growth need and the main heap figure","expect":"Across a day with stream passes, memory-growth stays out of the degraded list, or the main heap at a trip no longer climbs past ~2x its first hour while snapshot-stream is open"}]

🤖 Generated with Claude Code

Sign in to join this conversation.

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

Keyboard shortcuts

Docs