Repository navigation
Closed
Labels
enhancementNew feature or requestepic:code-intelligenceEpic: Code intelligence capabilities across toolspriority:highscope:code-intelCode intelligence — indexing, graph, impact analysis
Description
What problem does this solve?
All projects share one vector file (cora_index.*.usearch). A spike on 176 real projects (127,400 functions, real potion-code-16M-v2 embeddings, cora's own usearch and vecq settings; branch chore/spike-vector-layout) measured the cost:
- Dilution.
brainasks the whole index formax(5 x 2 x limit, 50)neighbours and only then keeps the current project's. At 176 projects the vector signal loses 11% (limit 20) to 29% (limit 3, whatcora reviewasks) of its MRR@10 and 16 to 34% of its recall; up to 26% of the queries get no vector candidate at all. - Orphans. Nothing ever removes a vector (no
removecall outside tests) and re-indexing a file gives its symbols new ids. In one development data directory 30% of the hashing index and 8% of the code-model index belonged to symbols that no longer exist. They fill the over-fetch and the file. - Memory and load. The whole index is read into every process: +148.5 MB resident and 195 ms to load at 127k vectors, whichever project is searched.
- Write amplification. Re-indexing one project of 689 functions rewrites everybody's vectors (306 ms and 149 MB written, against 8 ms and 0.3 MB for a per-project vecq file).
- One lock and one blast radius for all projects; a corrupt file makes cora clear the embedding fingerprints of every project.
Fixing the query (adaptive fetch, usearch filtered search) restores the quality but makes a query 50 to 170 times slower.
Proposed solution
One vecq file per project and model, rebuilt atomically.
<data dir>/vectors/<project id>.<model tag>.vecq, written to a temporary file and renamed. A project's file is rebuilt from its symbols after every index run that changed them (embedding is tens of thousands of symbols per second, 8 ms for 689 symbols), so there are no orphans and no per-symbol fingerprints (symbols.embed_fingerprintand the global self-heal that clears it for all projects go away).- Search loads only the current project's file (0.1 ms, about 0 MB for a typical project) and scans it, no filtering and no over-fetch.
- vecq residual is the only store: it matched the exact ceiling at every size measured (up to 127k vectors in one project, where usearch's HNSW lost 2 to 15% of the recall), files are 4.3x smaller, builds 15 to 18x faster. Latency is linear: about 0.85 ms at 9k vectors, 2 ms at 20k, 13 ms at 127k.
- Remove the usearch store and the
brain.vector_store/brain.vector_bitsoptions (a deprecation warning for old config), the shared-index lock, the sidecar.keysfile and the global index files, which are deleted after the first successful per-project build. - Deleting a project (stale roots,
cora findings prune) deletes its vector file. cora brainandcora indexreport how many vectors a project has and where they are.
Alternatives considered
Keep usearch per project: also at the ceiling for typical projects and 30 to 60 microseconds a query, but 4.3x larger and, in a monorepo, lower recall than vecq. A global file with a smarter query: fixes quality, not memory, load, write amplification or orphans.
Before submitting
- Measured: see the spike branch
chore/spike-vector-layout(README andresults/).
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestepic:code-intelligenceEpic: Code intelligence capabilities across toolspriority:highscope:code-intelCode intelligence — indexing, graph, impact analysis
Activity