Skip to content

Fix: Add caching for _ZvecClient._load_collection_entries#70

Open
mikewaters wants to merge 1 commit into
masterfrom
cursor/zvec-index-file-caching-3914
Open

Fix: Add caching for _ZvecClient._load_collection_entries#70
mikewaters wants to merge 1 commit into
masterfrom
cursor/zvec-index-file-caching-3914

Conversation

@mikewaters
Copy link
Copy Markdown
Owner

The _load_collection_entries method was reading and JSON-parsing the full index file from disk on every invocation. During _PayloadEmbeddingIdentityStrategy.query, get_embedding_identities() triggers one read, and each subsequent per-identity _query_zvec() call triggers another. With K stored identities this resulted in K+1 full file reads and parses per search operation.

Added file modification time based caching to avoid redundant I/O and JSON parsing. The cache is invalidated when the file's mtime changes, ensuring data consistency when the file is updated.

The _load_collection_entries method was reading and JSON-parsing the full
index file from disk on every invocation. During _PayloadEmbeddingIdentityStrategy.query,
get_embedding_identities() triggers one read, and each subsequent per-identity
_query_zvec() call triggers another. With K stored identities this resulted in
K+1 full file reads and parses per search operation.

Added file modification time based caching to avoid redundant I/O and JSON
parsing. The cache is invalidated when the file's mtime changes, ensuring
data consistency when the file is updated.
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