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
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
2 files
changed +22
−0
src/snapshot/snapshot.ts +9
| @@ -367,6 +367,8 @@ export interface Snapshotter { | ||
| 367 | 367 | * Default: a `settler()` every 64 MiB. |
| 368 | 368 | */ |
| 369 | 369 | readonly settle?: (() => void) | undefined; |
| 370 | /** The same, run after each whole listing of the store's chunks (#18278). */ | |
| 371 | readonly settleListing?: (() => void) | undefined; | |
| 370 | 372 | readonly settleBytes?: number | undefined; |
| 371 | 373 | /** Test seam: the cutter (`cut.ts`); by default one worker for this snapshot, closed with it. */ |
| 372 | 374 | readonly cutter?: Cutter | undefined; |
| @@ -533,6 +535,7 @@ export async function takeSnapshot( | ||
| 533 | 535 | // only when they must go; undefined when what it reads now is not that chunk (the file changed). |
| 534 | 536 | const settleAt = forge.settleBytes ?? SETTLE_BYTES; |
| 535 | 537 | const settle = forge.settle ?? settler(); |
| 538 | const settleList = forge.settleListing ?? settler(); | |
| 536 | 539 | let heldBytes = 0; |
| 537 | 540 | let settledAt = 0; |
| 538 | 541 | const sendNamed = async (id: string, length: number, read: () => Uint8Array): Promise<boolean> => { |
| @@ -644,6 +647,10 @@ export async function takeSnapshot( | ||
| 644 | 647 | const viewed = forge.chunks?.keys; |
| 645 | 648 | if (forge.chunks !== undefined) forge.chunks.keys = undefined; |
| 646 | 649 | 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(); | |
| 647 | 654 | const heldBefore = there.size; |
| 648 | 655 | // The database, consistently, from the live connection. |
| 649 | 656 | if (!streaming) { |
| @@ -878,6 +885,8 @@ export async function takeSnapshot( | ||
| 878 | 885 | // Announced only when whole: every chunk it names, seen in the store now. |
| 879 | 886 | const named = chunksNamed(manifest); |
| 880 | 887 | 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(); | |
| 881 | 890 | if (missing.length > 0) |
| 882 | 891 | throw new Error(`${missing.length} of the ${named.length} chunks this snapshot names are not in ${store.where} (first ${missing[0]}); no manifest written`); |
| 883 | 892 | await store.put( |
test/snapshot-stream.test.ts +13
| @@ -150,6 +150,19 @@ describe("the stream of hosted forges", () => { | ||
| 150 | 150 | } |
| 151 | 151 | }); |
| 152 | 152 | |
| 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 | ||
| 153 | 166 | test("a forge's pass collects as it reads, not only when it ends (#17493)", async () => { |
| 154 | 167 | const store = dirStore(join(root, `store-${n++}`)); |
| 155 | 168 | let ran = 0; |
new above
offline
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.