Skip to content

Remove vector cache; read vectors directly from disk#260

Merged
vindwid merged 1 commit into
endee-io:masterfrom
vindwi:vector-cache
Jun 29, 2026
Merged

Remove vector cache; read vectors directly from disk#260
vindwid merged 1 commit into
endee-io:masterfrom
vindwi:vector-cache

Conversation

@vindwi

@vindwi vindwi commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes the in-memory VectorCache layer from HierarchicalNSW. 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 old CacheReadView helper is renamed to ZeroCopyView since it no longer has anything to do with a cache.

Changes

  • Delete src/hnsw/vector_cache.h and all VectorCache usage in hnswalg.h:
    • cache init in both constructors and the load path
    • cache lookup/insert in getDataByInternalId and getDataByInternalIdBatch
    • the 1024 striped cache locks (vectorCacheLocks_, getCacheMutex)
    • slot invalidation on the update path
    • cache memory in getApproxSizeGB
    • getCache() accessor
  • Remove settings NDD_VECTOR_CACHE_PERCENTAGE / NDD_VECTOR_CACHE_MIN_BITS (and their DEFAULT_*)
  • Docs: drop the vector-cache description from memory_management.md

Net: −369 lines.

Verification

  • clang++ -std=c++20 -fsyntax-only of hnswalg.h (and all transitive includes) passes cleanly.
  • Confirmed no remaining references to VectorCache / vector_cache_ / VECTOR_CACHE_* anywhere outside third_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

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>
@vindwid
vindwid merged commit 16610ee into endee-io:master Jun 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants