java-topology/docs
russell@unturf.com a150602100
wave6 follow-up: gatsby-0001 — three filter-cache builders nodeTypeNames.includes -> Set
The Gatsby authors annotated each of the three call sites in
in-memory/indexing.ts with 'expensive at scale' comments. Their
diagnosis is correct: nodeTypeNames.includes(node.internal.type)
inside iterateNodes().forEach is O(N*T) per cache build.

For N=100k+ nodes typical of mature content sites and T=10-30
declared types per query, this fires on every type-filtered query.
gatsby develop in particular rebuilds caches per page render.

Fix: hoist Set<string> once at the top of each function. O(1) per
node lookup. Total cost O(N+T). Bench shows 8.4x at N=100k T=50;
2.7-4.7x at smaller scales.

Three call sites patched: ensureIndexByElemMatch (line 326),
ensureEmptyFilterCache (378), ensureIndexByElemMatchValue (504).
Author 'expensive at scale' comments updated to record the fix.
2026-04-25 10:15:32 -04:00
..
tickets wave6 follow-up: gatsby-0001 — three filter-cache builders nodeTypeNames.includes -> Set 2026-04-25 10:15:32 -04:00
blast-radius.md chore: update blast-radius docs, remove merged linux tickets, patch update 2026-04-10 12:47:28 -04:00
timeline.md undefect. CWE-407 — 92 sites, 42 ecosystems 2026-03-26 19:48:18 -04:00