Skip to content

docs(performance): dropping a rebuild's old vectors, before and after cli-core#3118 - #384

Merged
leemour merged 1 commit into
mainfrom
perf/store-vector-purge
Nov 18, 2026
Merged

leemour merged 1 commit into
mainfrom
perf/store-vector-purge

Conversation

@leemour

@leemour leemour commented Nov 18, 2026

Copy link
Copy Markdown
Member

Task

Record the measurement behind 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

… cli-core#3118

A forum rebuild on a copy of a test store went from 889 s to 52 s once the
purge's two lookups use their index. bench.mjs times each lookup read-only
on any store and prints plans and totals only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leemour added a commit to WireCatLabs/cli-core that referenced this pull request Nov 18, 2026
)

## 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
`purgeVectorHashes` runs once per chunk text of the old build. Its
candidates query joined on
`chunks.chunkable_type`, and SQLite chose the `(chunkable_type,
chunkable_id, position)` index: every lookup read every
conversation chunk in the store instead of using
`chunks_by_content_hash`. The delete after it named only
`content_hash`, while the `embeddings` key is `(model, content_hash)`,
so it read the whole key as well.

## What
- `+k.chunkable_type` keeps the planner on `chunks_by_content_hash`
(checked with `EXPLAIN QUERY PLAN`).
- The delete runs once per stored model, by the full key. The models are
read once per purge.

## Testing
- Measured on a copy of a test store (about 220,000 conversation chunks,
two embedding models), rebuilding one forum
group of about 112,000 messages with an unchanged result, so the purge
checks about 42,600 old chunk texts:
  - before: 889 s, and 889 s again (load about 4 to 8)
  - after: 52 s (load about 4)
  - the candidates query alone: 29.5 ms per text before, 0.3 ms after.
- Full write-up and script: [cli-testing
performance/store/vector-purge](https://github.com/WireCatLabs/cli-testing/blob/perf/store-vector-purge/performance/store/vector-purge/README.md)
(WireCatLabs/cli-testing#384).
- Local: `pnpm ci:quick`, Biome, `pnpm docs:check`, vitest over
`src/store` and `src/services/embeddings`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@leemour
leemour merged commit 34fd4c7 into main Nov 18, 2026
1 check passed
@leemour
leemour deleted the perf/store-vector-purge branch November 18, 2026 18:58
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.

1 participant