go-vector v1.2.1
Search performance — backward compatible, zero dependencies.
Performance
- Store.Search: replaced the full reflection-based
sort.Sliceover all
ncandidates with a bounded top-k max-heap — O(n·log k) selection instead
of O(n·log n), and O(k) scratch memory instead of O(n). - Cosine search: the query's self dot-product is now computed once per
search rather than re-derived for every stored vector. - Manhattan: branchless float32 abs, dropping the per-element float64
round-trip (still zero-allocation). - RandomProjections: preallocate sparse projection rows and tokenizer
output to cut append churn during Fit/Embed.
Measured (k=10): StoreSearch10000 25.6ms → 22.0ms with scratch memory down
185KB → 62KB; SearchCosine 1.10ms → 0.99ms. Distance results are identical.