perf(docs): persist the doc-search BM25 index across sessions - #55
Open
pradeepmouli wants to merge 4 commits into
Open
perf(docs): persist the doc-search BM25 index across sessions#55pradeepmouli wants to merge 4 commits into
pradeepmouli wants to merge 4 commits into
Conversation
added 4 commits
August 7, 2026 16:32
… docs_embeddings.bin
pradeepmouli
requested review from
WinterQuant,
johnintuit,
murari316 and
sandeep-mewara
as code owners
August 7, 2026 20:36
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
Doc search (
hybrid_doc_search_in_dir) currently rebuilds its entireDocBM25Indexin memory on every query — loading all chunks from the store and re-tokenizing the whole corpus — while code search already persists its BM25 index to.infigraph/bm25_cache.bin. This PR gives doc search the same treatment:DocBM25Indexgainssave/load/docs(). The on-disk format mirrors code search'sBM25Index::saveidiom (leading version byte + length-prefixed LE binary).hybrid_doc_search_in_dirloadsdocs_bm25_cache.binwhen it is at least as new asdocs_embeddings.bin— the same mtime freshness anchor code search uses, so a doc reindex invalidates the cache automatically. On a cache hit thestore.get_all_chunks()DB read is skipped too (the cache carries the chunk texts).Two deliberate hardenings over the idiom being mirrored:
loadis fully bounds-checked and returnsErr(never panics) on truncated/corrupt input, since a bad cache must degrade to a rebuild.Group/combined doc stores get their own cache automatically (keyed off the store's artifact dir; combined stores publish per-generation directories, so no cross-generation staleness is possible).
Testing
DocStore: first search writes the cache and repeat results are identical; corrupt cache falls back silently and is rewritten; stale cache (newer embeddings) is rebuilt.infigraph-docssuite: 93/93 passing on this branch (rebased on currentmain);cargo fmt/clippy -D warnings/cargo check --workspaceclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01SjmvwHuwV5r7ZeZpJLp5oR