fix(cli): speed up local recall searches - #12726
Merged
Merged
Conversation
marius-kilocode
enabled auto-merge (squash)
July 31, 2026 11:02
Contributor
Code Review SummaryStatus: 4 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Resolved since the previous review
Files Reviewed (5 files)
Notes and assumptions
Fix these issues in Kilo Cloud Previous Review Summary (commit 15ad465)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 15ad465)Status: 6 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (10 files)
Notes and assumptions
Reviewed by claude-opus-5 · Input: 64 · Output: 25.1K · Cached: 2.7M Review guidance: REVIEW.md from base branch |
marius-kilocode
disabled auto-merge
July 31, 2026 12:12
…rmance' into optimize-kilo-local-recall-performance
marius-kilocode
enabled auto-merge (squash)
July 31, 2026 12:30
chrarnoldus
approved these changes
Aug 3, 2026
This was referenced Aug 5, 2026
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
* fix(cli): speed up local recall searches * fix(cli): bound local recall scans * fix(cli): make recall index initialization lazy
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.
Problem
Large local session histories made
kilo_local_recallrepeatedly scan and JSON-parse parts that can never match: reasoning parts, successful tool output, synthetic text, and ignored text. The old search also paged through the same SQLite session ranges and joined message metadata before knowing whether a part matched.What Changed
part_session_idxpath and paged through all part rangesrecall_part_search_idx, a covering index over searchable fields onlyCREATE INDEX IF NOT EXISTS; failure is logged, search falls back, and the next search retriesINDEXED BYjson_validexcludes malformed rows from the derived index without modifying or deleting themBenchmark Corpus
The corpus-count difference reflects additional sessions and parts written between the baseline and final clone.
Search Performance
Timings are wall-clock seconds. Baseline timings were captured before the optimization. Final timings were captured three times after bounded pagination and removal of the duplicate count pass; the reported final value is the median.
kilo_local_recallrecall-searchzyx-no-match-987654Final repeated searches ranged from 0.540s to 0.991s while keeping candidate memory bounded to 1,024 rows.
Write Path
Legacy text parts are written at text start and text completion; token deltas use
message.part.deltaand do not upsert the full legacypartrow per token. The benchmark below writes 100 separate completed 20 KB text parts, with an empty start row followed by one completed row.The index intentionally trades this measured write overhead for the 11.7x to 50.3x search improvement.
Failure Behavior
Result
The reviewed, bounded recall path is 11.7x to 50.3x faster on the measured large-session corpus. It keeps peak candidate materialization at 1,024 rows, preserves exact Unicode matching and ranking, avoids fatal startup work, and uses a sub-60 MB derived index rather than a tokenized full-session search index.