Skip to content

Commit edba986

Browse files
Prithvi-Webclaude
andcommitted
test(facts): the subtree count's deep-chain test builds its 20,000-deep chain on the packed store, as a scan does - the reference store keeps every node's whole path, about 1.2 GB of the 2 GB heap GitHub's macOS runner gives Node, for a count that reads none of them (CI4 sweep)
Found by the CI4 sweep for tests that could run a 2 GB heap out. "a deep chain does not overflow the stack" built its chain with ObjectScanStore (the oracle), whose addNode joins each node's path from its parent's and keeps it - endsWith copies the parent's whole path, so every node held its own, the depth squared: the file's peak was 1,427 MB resident, and under a 1 GB heap it died with the same "Reached heap limit" in String.prototype.endsWith -> StringSlowFlatten as CI run 39095045009. Under CI's 2 GB it passed with a little over half the heap to spare. buildCountTable reads only isDir, forEachChild and count, the same on either store, so the property is unchanged: 20,000 folders deep, the one file and every folder counted, no stack frame per level. Now 258 MB peak, and the whole file passes under a 1 GB heap. The reference store's own deep build is not what this test is about, and production keeps it only to wrap trees that already carry a path on every node. Mutant: buildCountTable made recursive - RED, "RangeError: Maximum call stack size exceeded", before and after the change; restored and checked by SHA-256. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent b4e514e commit edba986

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎tests/subtreeCount.test.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ test('an empty folder is 0 files — and a file is 1, never 0', () => {
8080
test('a deep chain does not overflow the stack', () => {
8181
// Recursion is the obvious implementation and it dies on real input: a
8282
// node_modules chain or a Time Machine backup nests far deeper than this.
83-
const store = new ObjectScanStore('/root', '/', dirIn('root'));
83+
// Built on the packed store, as a scan is (CI4): the reference store keeps
84+
// every node's whole path, about 1.2 GB down a 20,000-deep chain — over
85+
// half the 2 GB heap GitHub's macOS runner gives Node, and nothing to do
86+
// with the count, which reads only isDir and forEachChild.
87+
const store = new PackedScanStore('/root', '/', dirIn('root'));
8488
let cursor = store.rootId;
8589
const DEPTH = 20_000;
8690
for (let i = 0; i < DEPTH; i++) cursor = store.addNode(cursor, dirIn(`d${String(i)}`));

0 commit comments

Comments
 (0)