brainy/tests/benchmarks
David Snelling b5bc73fb17 perf(8.0): allocation-free distance loops (6x cosine) — evidence-revised Fork X
Rewrite the four open-core distance functions (cosine / euclidean / manhattan /
dot-product) from object-accumulating `reduce` to single-pass allocation-free
indexed loops. cosine's per-element `{dotProduct,normA,normB}` object was the
hot-path GC lever.

MEASURED (tests/benchmarks/distance-microbench.mjs, dim=384, N=20000, median of
41): cosine 44.3ms -> 7.4ms (~6x), euclidean 9.2ms -> 6.6ms (~1.4x); the built
cosineDistance drops ~44ms -> ~9ms. Numerically identical (same ops, same order)
so recall is unchanged; full suite green (1753/1753).

Also drop the unfounded perf JSDoc ("faster than GPU", "Node.js 23.11+") and the
`new Function(distanceFn.toString())` eval in calculateDistancesBatch — with the
functions now tight loops, the batch is a thin JIT-inlined map (no worker, no
stringify/reconstruct).

Evidence-revised scope: the Float32Array resident-storage half of the original
Fork X is DROPPED. The same microbench shows Float32Array is ~1.7x SLOWER for
this compute (V8 widens f32 -> f64 on every element read), so it would regress
the hot path for a RAM win the open-core JS path does not need — billion-scale
vector RAM is the native provider's SIMD/mmap/quantized domain. The resident
representation stays number[]; no type-chain or cache changes.
2026-07-01 10:55:04 -07:00
..
lib test(8.0): A/B benchmark harness (open leg) — generic corpus+metrics lib, brainy-alone scaling bench, boundary guard, real-embedding recall guard 2026-06-15 15:51:17 -07:00
benchmark-real-world.js refactor: remove augmentation system and semantic type matching 2026-02-01 10:48:56 -08:00
benchmark-vs-industry.js refactor: remove augmentation system and semantic type matching 2026-02-01 10:48:56 -08:00
brainy-scale.js test(8.0): A/B benchmark harness (open leg) — generic corpus+metrics lib, brainy-alone scaling bench, boundary guard, real-embedding recall guard 2026-06-15 15:51:17 -07:00
distance-microbench.mjs perf(8.0): allocation-free distance loops (6x cosine) — evidence-revised Fork X 2026-07-01 10:55:04 -07:00
find-composition-scale.js test(8.0): asOf() error-path spot-checks + find() triple-composition correctness + scale-bench harness 2026-06-15 11:55:26 -07:00
model-b-scalability.spike.ts feat(8.0): Model-B per-write generation-stamping + adaptive retention knob 2026-06-22 15:19:58 -07:00
model-b-write-perf.spike.ts test(8.0): Model-B write-perf + scalability spike harnesses 2026-06-22 13:47:46 -07:00
perf-final.js chore(8.0): final pre-RC1 sweep — API consistency, named errors, orphans, zero-cast codebase 2026-06-11 14:51:00 -07:00
perf-simple.js refactor: remove augmentation system and semantic type matching 2026-02-01 10:48:56 -08:00
performance-comprehensive.js feat(8.0): API simplification — remove neural()/Db.search, one storage path key, integration→0 2026-06-20 13:31:11 -07:00
performance-profile.js refactor: remove augmentation system and semantic type matching 2026-02-01 10:48:56 -08:00
performance-v3.js feat(8.0): API simplification — remove neural()/Db.search, one storage path key, integration→0 2026-06-20 13:31:11 -07:00
quick-benchmark-v3.js feat(8.0): API simplification — remove neural()/Db.search, one storage path key, integration→0 2026-06-20 13:31:11 -07:00
quick-perf.js refactor: remove augmentation system and semantic type matching 2026-02-01 10:48:56 -08:00
quick-verify.js refactor: remove augmentation system and semantic type matching 2026-02-01 10:48:56 -08:00
scale-test.js refactor: remove augmentation system and semantic type matching 2026-02-01 10:48:56 -08:00