Remove vector cache; read vectors directly from disk#260
Merged
Conversation
Drop the in-memory VectorCache layer from HierarchicalNSW. Layer-0 vectors are now always fetched from disk via the vector fetcher; in-memory upper-layer vectors are still served zero-copy (the former CacheReadView is renamed to ZeroCopyView to reflect that it no longer involves a cache). - Delete src/hnsw/vector_cache.h and all VectorCache usage in hnswalg.h (init, lookup/insert, striped cache locks, slot invalidation on update, and cache memory accounting) - Remove NDD_VECTOR_CACHE_PERCENTAGE / NDD_VECTOR_CACHE_MIN_BITS settings - Update memory_management.md to drop the vector-cache description Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Removes the in-memory
VectorCachelayer fromHierarchicalNSW. Layer-0 vectors are now always fetched directly from disk through the existing vector fetcher; the cache that previously sat in front of those reads is gone.In-memory upper-layer vectors (
dataUpperLayer_) are unaffected — they're still served zero-copy. The oldCacheReadViewhelper is renamed toZeroCopyViewsince it no longer has anything to do with a cache.Changes
src/hnsw/vector_cache.hand allVectorCacheusage inhnswalg.h:getDataByInternalIdandgetDataByInternalIdBatchvectorCacheLocks_,getCacheMutex)getApproxSizeGBgetCache()accessorNDD_VECTOR_CACHE_PERCENTAGE/NDD_VECTOR_CACHE_MIN_BITS(and theirDEFAULT_*)memory_management.mdNet: −369 lines.
Verification
clang++ -std=c++20 -fsyntax-onlyofhnswalg.h(and all transitive includes) passes cleanly.VectorCache/vector_cache_/VECTOR_CACHE_*anywhere outsidethird_party/.Note / trade-off
This trades memory for I/O: every layer-0 distance computation that previously hit the cache now performs a disk fetch (single or batched MDBX read). Search-heavy workloads on large indices will do more disk reads per query. Flagging in case a benchmark pass is wanted before merge.
🤖 Generated with Claude Code