Historical reads (asOf/get) scanned the global committedGens list linearly, making them O(database-age): a read of an unchanged entity at an old pin scaled ~12x for 10x history depth. Add per-id inverted history chains (nounChains/ verbChains) so resolveAt binary-searches the id's own generation chain instead — O(log) and flat with depth. Chains build lazily under the commit mutex, maintain incrementally on commit, and invalidate on compaction. Also bound deltaCache (LRU cap 4096; getDelta re-reads evicted deltas) so a long-lived high-write process's heap is O(cap) not O(generations) on the disk-backed path, and binary-search commitTimestampAtOrBefore (O(log)). Verified: 373 unit tests green; new tests/unit/db/generation-chain.test.ts covers chain resolution, eviction re-read, and chain rebuild after compaction. |
||
|---|---|---|
| .. | ||
| db-portable-graph.test.ts | ||
| generation-chain.test.ts | ||
| generationStore.test.ts | ||
| stableEqual.test.ts | ||
| whereMatcher.test.ts | ||