Repository navigation
perf(store): purge a rebuild's old vectors through the hash index - #3118
Merged
Merged
Conversation
After a rebuild, purgeVectorHashes looks up each old chunk hash. Its candidates query joined on chunks.chunkable_type, and SQLite picked the (chunkable_type, chunkable_id, position) index, reading every conversation chunk for each hash instead of using chunks_by_content_hash. The delete that follows named only content_hash, while the embeddings key is (model, content_hash), so it read the whole key too. Both now use their index: `+k.chunkable_type` keeps the planner off the type index, and the delete runs per model by the full key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour
added a commit
to WireCatLabs/cli-testing
that referenced
this pull request
Nov 18, 2026
… cli-core#3118 (#384) ## Task Record the measurement behind [WireCatLabs/cli-core#3118](WireCatLabs/cli-core#3118). ## Why cli-core's linking-rules version 6 (#3107) rebuilds every user's conversations, and on a test store one forum rebuild spent most of its time dropping the old build's vectors. ## What - `performance/store/vector-purge/README.md`: why it was run, setup, results, what it showed, what was not measured. Totals only: the store is a private copy. - `performance/store/vector-purge/bench.mjs`: times the purge's two lookups read-only on any store, before and after, with their query plans. - Linked from `performance/store/README.md`. Headline: the forum rebuild went from 889 s (twice) to 52 s; the candidates lookup from about 20 ms to 0.13 ms per old chunk text. ## Testing Biome, markdownlint and `pnpm docs:check`; `bench.mjs` run on the test store. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <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.
Task
After the linking-rules version became 6 (#3107), every user's chats get rebuilt. A rebuild of one large forum group
took about 15 minutes, most of it after the new build was already in place.
Why
purgeVectorHashesruns once per chunk text of the old build. Its candidates query joined onchunks.chunkable_type, and SQLite chose the(chunkable_type, chunkable_id, position)index: every lookup read everyconversation chunk in the store instead of using
chunks_by_content_hash. The delete after it named onlycontent_hash, while theembeddingskey is(model, content_hash), so it read the whole key as well.What
+k.chunkable_typekeeps the planner onchunks_by_content_hash(checked withEXPLAIN QUERY PLAN).Testing
group of about 112,000 messages with an unchanged result, so the purge checks about 42,600 old chunk texts:
pnpm ci:quick, Biome,pnpm docs:check, vitest oversrc/storeandsrc/services/embeddings.🤖 Generated with Claude Code