Repository navigation
hnsw: fill-once int16 vector cache - #37
Open
tomas-villagesql wants to merge 2 commits into
Open
tomas-villagesql wants to merge 2 commits into
tomas-villagesql wants to merge 2 commits into
Conversation
|
Please add a kind label with /kind. |
|
Please add an area label with /area. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Needs approval from an approver in each of these files:Approvers can indicate their approval by writing |
tomas-villagesql
force-pushed
the
tomas/vector-cache-fill-once
branch
from
November 7, 2026 15:36
360ed50 to
1bae0cc
Compare
tomas-villagesql
changed the base branch from
main
to
tomas/svector-from-binary-dispatch
November 7, 2026 15:36
tomas-villagesql
force-pushed
the
tomas/vector-cache-fill-once
branch
from
November 15, 2026 10:39
1bae0cc to
76fff30
Compare
An insert compares its new node against the neighbours whose lists it overflows. If that fetched the new node back by VID, the cache would admit it and insert()'s VID-reuse invalidate would retire it: one dead slot per insert, never reclaimed. create_node() seeds the per-insert vectors with the new node instead. 300 inserts with M = 2 (so nearly every insert takes the shrink path): the cache is used and cache_tombstones stays 0. Without the seed it records 295.
tomas-villagesql
force-pushed
the
tomas/vector-cache-fill-once
branch
from
November 17, 2026 20:21
76fff30 to
4c5acff
Compare
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.
A per-index cache of vectors in the form the distance kernel consumes: decoded and quantized to int16 (MariaDB MHNSW's recipe: per-vector scale, int16 components, precomputed
abs2), read in place by the kernel with no copy. Squared L2 only; cosine and inner-product kernels follow in #36, stacked on this.Design
create_node()seeds the per-insertDecodedVectorCache(hnsw: decode each node's vector once per graph call #31) with the new node, so the insert never fetches its own node back by VID, never admits it to the cache, andinsert()'s VID-reuse invalidate has no just-admitted entry to retire (otherwise one dead slot per insert, which a fill-once cache never reclaims).vsql_vector.cache_mode(0 = off, 1 = vectors) andvsql_vector.max_cache_size. Off by default.vsql_vector.cache_hits,cache_misses,cache_admissions_refused,cache_tombstones,cache_bytes,cache_limit_changes,cache_limit_slots.Testing
Unit tests
vector_cache_testanddecoded_vector_cache_test;make test6/6 pass.MTR
hnsw_vector_cache_insert: 300 inserts with the cache on and M = 2, so nearly every insert overflows a neighbour and takes the shrink path. The cache is used andcache_tombstonesstays 0; without thecreate_node()seed it records 295.Known:
bin_to_svectorfails on current main independently of this PR (the server rejects binary values for SVECTOR).🤖 Generated with Claude Code