8000 Vector sets: VSIM is exact brute force; Redis uses HNSW · Issue #710 · kividbio/kividb · GitHub
[go: up one dir, main page]

Skip to content

Vector sets: VSIM is exact brute force; Redis uses HNSW #710

Closed

Description

@murtazayusuf

Pointed out by @Parikalp-Bhardwaj in #697: VSIM compares the query against every element (src/commands/vset.rs), while Redis 8 vector sets keep an HNSW graph (M and EF on VADD, EF and EPSILON on VSIM). Query time therefore grows linearly with the set size; at 1M+ vectors VSIM throughput will be far below Redis's regardless of how vectors are stored.

We already have an HNSW index for FT.SEARCH vector fields; reusing it (or its design) for vector sets is the obvious first option to check. Things to settle:

  • recall@10 vs. exact search at Redis's default M/EF, and that EF / EPSILON / TRUTH (exact search on request) behave as in Redis;
  • memory per element of the graph, next to Vector sets: store vectors quantized (Q8, BIN) instead of always f32 #697's quantized vectors;
  • VREM / updates, persistence (rebuild on load vs. saving the graph), DUMP/RESTORE and replication;
  • VLINKS and VINFO reporting the graph as Redis does.

Benchmark with #627. Not started; contributors welcome.

Activity

  1. added this to the 1.3.0 milestone on Nov 13, 2026
  2. added
    redis-compat
    performance
    on Nov 13, 2026
  3. KrishPatel1905 commented on Nov 13, 2026

    @KrishPatel1905
    Contributor

    Hi @murtazayusuf,

    I'd like to take up this issue as my first contribution to KiviDB.

    I've gone through the issue description and understand that it involves improving vector search performance using HNSW indexing.

    Since this is my first contribution to the project, could you suggest a smaller, well-defined part of this issue that I can start working on?

    I'd be happy to explore the codebase, investigate the existing implementation, and contribute.

    Thanks!

  4. self-assigned this
    on Nov 13, 2026
  5. murtazayusuf commented on Nov 13, 2026

    @murtazayusuf
    ContributorAuthor

    welcome @KrishPatel1905, and thanks for offering! this one is staying with the core team though, since it's tied up with the vector-set work already under way in #697. for a first contribution, these are open and well defined: #657 (DEBUG SLEEP with a non-number gives the wrong error), #654 (a consumer created by a timed-out XREADG BD9D ROUP is missing after AOF replay) and #655 (the IDMP duplicate counter isn't restored by AOF replay). comment on whichever you pick and it's yours

  6. murtazayusuf commented on Nov 13, 2026

    @murtazayusuf
    ContributorAuthor

    Plan, decided by the maintainer after reading the code:

    • One shared HNSW index for FT vector fields and vector sets: generalize src/vector's graph rather than build a second one. It needs byte-string element names, pluggable vector storage (f32 now, Q8/BIN later), and proper deletion (VREM repairs neighbours' links instead of leaving stale in-links). Vectors are stored once, inside the index (~800 B/vector at dim 128 f32, ~450-500 B with Q8, vs 608 today and Redis's 884).

    • Build order, each step its own PR, measured with benchmarks/vector-sets (recall@10 next to throughput):
      0. benchmark: delete-and-re-add phase, FILTER phase, real datasets;

      1. generalize the HNSW with no behaviour change (FT vector benchmarks are the gate);
      2. vector sets on the graph: honour M/EF/EPSILON/TRUTH, real VINFO/VLINKS;
      3. VREM with link repair;
      4. FILTER inside the graph search;
      5. maybe save the graph in snapshots (see below);
      6. Q8/BIN inside the graph (Vector sets: store vectors quantized (Q8, BIN) instead of always f32 #697).
    • Persistence: rebuild the graph from the vectors on load at first, so the snapshot format doesn't change and 1.2.x downgrades keep working. Saving the graph comes later only if load times at 1M vectors are too slow.

    • Query planner (our own design, not Redis's fixed-EF approach): for each VSIM, choose by cost:

      • exact SIMD scan when the set is small, or when a FILTER leaves a small candidate set (recall 1.0, and fast at that size);
      • graph search when the set is large, with EF picked automatically from the set size to hit a recall target, instead of one fixed default. An explicit EF still overrides it, and TRUTH always scans exactly.

      This is the same candidate-first approach that makes our filtered FT.SEARCH faster than Redis and Dragonfly today. The filtered FT benchmark (>= 1.2x Redis) stays a gate for every step.

    Also found while reading: DUMP refuses vector-set and time-series keys (#722).

  7. added a commit that references this issue on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

performanceredis-compat

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0