Repository navigation
Conversation
… initial reindex session_start calls reindex on every attach. With a remote embedder (ollama bge-m3, 128 chunks) each call re-embedded the entire memory file — 7.3-7.8s per round on this machine — because chunkReindex embeds unconditionally and nothing tracks what was last indexed. - Add a content fingerprint (sha256 of sorted ids+contents + embedder identity) persisted in the meta table; handleReindex short-circuits on a match and returns skipped: "fingerprint_match" - Expose get/setLastReindexFingerprint on VecStore (db is private) - Make the initial reindexScheduler.runNow() in bootstrapSidecar fire-and-forget: session_start must not block on a full re-embed; preflight already falls back to MEMORY.md while the index rebuilds - Empty-document reindex never fingerprint-skips (explicit clear path) Measured: repeated reindex ~7.3-7.8s -> ~2ms; session startup cost attributable to pi-memory drops by ~7s per attach / new chat.
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
session_startcalls reindex on every attach, andchunkReindexre-embeds the entire memory file unconditionally. With a remote embedder (ollamabge-m3, 128 chunks) that measured 7.3-7.8s per round — the dominant cost of every session attach / new chat.handleReindexnow computes a content fingerprint (sha256 over sorted chunk ids + contents + embedder identity) and short-circuits on a match, returningskipped: "fingerprint_match"metatable; embedder model/provider/dim changes still trigger a full rebuild (andclearChunksIfEmbeddingMismatchstays as-is)reindexScheduler.runNow()inbootstrapSidecarbecomes fire-and-forget sosession_startnever blocks on a full re-embed (preflight already falls back to MEMORY.md while the index rebuilds)Measurements
Test plan
test/reindexFingerprint.test.ts(6 tests): fingerprint order-insensitivity, skip-on-match, rebuild-on-change, empty-set never skips, data still queryable after a skipped round.npx vitest run: 203 passed (pre-existing scheduler/status failures unchanged — they depend on the local launchd/home environment and fail on a clean checkout too).npx tsc --noEmitclean.This came out of investigating slow session attach in a pi-web-ui deployment (raw-WS attach timing dropped 7.7s → 1.0s with this fix plus a per-cwd extension cache fix on the pi side).