Repository navigation
feat(code-intel): store vectors in one vecq file per project - #752
Merged
Merged
Conversation
The shared vector index let other projects crowd the current one out of the search candidates (on 176 projects the vector signal lost 11 to 29% of its MRR@10 and up to a quarter of the queries found no candidate), never freed the vectors of deleted symbols (30% of one real index) and was read into memory by every process (+148 MB at 127,400 vectors). Each project now has vectors/<project id>.<model>.vecq in the data directory. It is rebuilt from the project's symbols after every index run that changed them (or when the model changed, or the file is missing or from another dimension) and replaced atomically, and a search reads only that file, cached per process and reloaded when the file changes. The files are 4.3 times smaller, load in 0.1 ms, add no resident memory and retrieval stays at the exact ceiling. The files of the former shared index are deleted after the first index, a project's files are deleted with the project (cora findings prune, index --rebuild), the per-symbol embedding fingerprints and the shared lock are no longer used, and the usearch dependency is removed. brain.vector_store and brain.vector_bits no longer do anything: a config that still sets them loads and prints one warning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
<data dir>/vectors/<project id>.<model>.vecq(vecq residual, keyed by symbol id). It is rebuilt from the project's symbols after every index run that changed them, when the model changed, or when the file is missing or built with other dimensions, and replaced atomically (temporary file, then rename).cora_index.*) are deleted after the first successful embed; the file of a model a project no longer uses is removed; a project's files are deleted with the project (cora findings prune,index --rebuild)..keyssidecar, the global self-heal that cleared every project's fingerprints, and the per-symbol embedding fingerprints (the column stays in the schema, unused).brain.vector_storeandbrain.vector_bitsno longer do anything; a config that still sets them loads and prints one warning.Why
Measured on 176 real projects (127,400 functions, the real code model, cora's own usearch and vecq settings; spike branch
chore/spike-vector-layout): the shared index let other projects crowd the current one out of the candidates (the vector signal lost 11 to 29% of its MRR@10 and 16 to 34% of its recall depending on--limit, and up to 26% of the queries got no vector candidate), never freed the vectors of deleted symbols (30% of one real index), cost +148.5 MB resident and 195 ms to load in every process, and rewrote every project's vectors on each re-index. A per-project vecq file matches the exact ceiling at every size measured (even one project of 127k vectors, where HNSW lost 2 to 15% of the recall), is 4.3x smaller, loads in 0.1 ms and re-indexes in milliseconds. Closes #750.Testing
cora brainMRR@10 is unchanged (0.319 on 39 hand-written questions, 0.515 on 400 doc-comment queries, against 0.316 and 0.517 before). Indexing 4,492 symbols produces a 1.2 MB file instead of 5.3 MB, in 5.0 s with a 144 MB peak, as before.cargo fmt --all -- --check,cargo clippy --all-targets --features tree-sitter -- -D warnings,cargo test --features tree-sitter,cora review --base origin/develop: no issues.