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

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

opened this

Merged 6h 12m ago, live in production

mason/forge:mason/18278-sentinel-memory-growth-was-degraded-10-m → main 0 commits fork 1 thread · 1 unresolved

  • Merged. mason/18278-sentinel-memory-growth-was-degraded-10-m was merged into main as 05811f5.

Review

Sign in to review this change.
2 files changed +22 −0
src/snapshot/snapshot.ts +9
@@ -367,6 +367,8 @@ export interface Snapshotter {
367367 * Default: a `settler()` every 64 MiB.
368368 */
369369 readonly settle?: (() => void) | undefined;
370 /** The same, run after each whole listing of the store's chunks (#18278). */
371 readonly settleListing?: (() => void) | undefined;
370372 readonly settleBytes?: number | undefined;
371373 /** Test seam: the cutter (`cut.ts`); by default one worker for this snapshot, closed with it. */
372374 readonly cutter?: Cutter | undefined;
@@ -533,6 +535,7 @@ export async function takeSnapshot(
533535 // only when they must go; undefined when what it reads now is not that chunk (the file changed).
534536 const settleAt = forge.settleBytes ?? SETTLE_BYTES;
535537 const settle = forge.settle ?? settler();
538 const settleList = forge.settleListing ?? settler();

Nit: this makes a second settler() per pass, and it reads the heap floor when created. That is fine here. If it is ever tuned, check that the two settlers' floors do not drift apart.

536539 let heldBytes = 0;
537540 let settledAt = 0;
538541 const sendNamed = async (id: string, length: number, read: () => Uint8Array): Promise<boolean> => {
@@ -644,6 +647,10 @@ export async function takeSnapshot(
644647 const viewed = forge.chunks?.keys;
645648 if (forge.chunks !== undefined) forge.chunks.keys = undefined;
646649 there = viewed ?? new Set(await store.list(CHUNK_PREFIX));
650 // The listing's pages and its array are garbage once the Set is built; let them go before the
651 // pass reads on (#18278: the main heap 356 to 1907 MiB in a stream pass that mostly found
652 // chunks).
653 if (viewed === undefined) settleList();
647654 const heldBefore = there.size;
648655 // The database, consistently, from the live connection.
649656 if (!streaming) {
@@ -878,6 +885,8 @@ export async function takeSnapshot(
878885 // Announced only when whole: every chunk it names, seen in the store now.
879886 const named = chunksNamed(manifest);
880887 const missing = await missingChunks(store, named);
888 // That second listing is a whole bucket's keys, read to find a few; it too is let go at once.
889 settleList();
881890 if (missing.length > 0)
882891 throw new Error(`${missing.length} of the ${named.length} chunks this snapshot names are not in ${store.where} (first ${missing[0]}); no manifest written`);
883892 await store.put(
test/snapshot-stream.test.ts +13
@@ -150,6 +150,19 @@ describe("the stream of hosted forges", () => {
150150 }
151151 });
152152
153 test("a pass lets go of each whole listing of the store's chunks: the one it starts from and the one that checks it (#18278)", async () => {
154 const store = dirStore(join(root, `store-${n++}`));
155 let listed = 0;
156 await takeSnapshot({ ...shape(), stream: "kid", settleListing: () => void listed++ }, store);
157 expect(listed).toBe(2);
158 // A pass handed the pass's view starts from it: no first listing, so one release.
159 const chunks = { keys: undefined as Set<string> | undefined };
160 await takeSnapshot({ ...shape(), stream: "kid", chunks }, store);
161 let again = 0;
162 await takeSnapshot({ ...shape(), stream: "kid", chunks, settleListing: () => void again++ }, store);
163 expect(again).toBe(1);
164 });
165
153166 test("a forge's pass collects as it reads, not only when it ends (#17493)", async () => {
154167 const store = dirStore(join(root, `store-${n++}`));
155168 let ran = 0;

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

Keyboard shortcuts

Docs