Skip to content

feat(code-intel): store vectors in one vecq file per project instead of one shared index #750

Closed

Description

@ajianaz

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. brain asks the whole index for max(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, what cora review asks) 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 remove call 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.

  1. <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_fingerprint and the global self-heal that clears it for all projects go away).
  2. 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.
  3. 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.
  4. Remove the usearch store and the brain.vector_store / brain.vector_bits options (a deprecation warning for old config), the shared-index lock, the sidecar .keys file and the global index files, which are deleted after the first successful per-project build.
  5. Deleting a project (stale roots, cora findings prune) deletes its vector file.
  6. cora brain and cora index report 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 and results/).

Activity

  1. added
    enhancement
    scope:code-intel
    epic:code-intelligence
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementepic:code-intelligencepriority:highscope:code-intel

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions