Stacked features 5: search optimization#416
Merged
Merged
Conversation
This was referenced Jul 13, 2026
AmagiDDmxh
marked this pull request as draft
July 13, 2026 20:48
AmagiDDmxh
force-pushed
the
feat/search-hot-path
branch
3 times, most recently
from
July 15, 2026 04:59
f565ef5 to
3fb75a7
Compare
AmagiDDmxh
marked this pull request as ready for review
July 15, 2026 05:00
Address review findings on the FTS preview plan:
- A trigram plan (any CJK in the query) ANDs its terms, but trigram
phrases never match below 3 codepoints — one short term zeroed out the
whole preview ('错误码 42', '迁移记录 v2' returned nothing). Any
sub-trigram term now sends the query to the LIKE fallback.
- Punctuation-only terms tokenize to an empty phrase under unicode61 and
AND-away every other term ('foo =>' returned nothing). Zero-token terms
now send the query to the LIKE fallback.
- Single CJK characters are meaningful queries and go back to the LIKE
path instead of being gated with ascii single chars; the pre-FTS
behavior is restored.
- Drop the renderer request-routing changes: they modified a code path
with no live callers (SearchBar is not rendered; the live typing path
is CommandPalette, which already issues one request per input change).
The perf win of this PR is entirely core-side.
Regression tests cover all three query shapes at both the plan level and
through searchSessionPreview.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
graydawnc
force-pushed
the
feat/search-hot-path
branch
from
July 15, 2026 10:48
3fb75a7 to
1cf227f
Compare
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.
Stack position
Part 5 of 7. Rebased onto
main(#412–#415 merged); the next PR is #417.Why
Home-page preview search used leading-wildcard
LIKEover denormalized full-session text on every keystroke, through synchronousbetter-sqlite3in the Electron main process — larger indexes could block input for hundreds of milliseconds.What changed
LIKEfallback for every plan whose terms cannot match their FTS table: short-CJK terms, any sub-trigram term when the query contains CJK (错误码 42), and punctuation-only terms under unicode61 (foo =>).LIKEpath.Verification
错误码 42,foo =>, and single-CJK-char shapes at both the plan level and throughsearchSessionPreview.Review notes
Search remains in the main process because the measured synchronous maximum is below 10 ms on the real index and below 2 ms on both synthetic fixtures. A worker thread would add lifecycle and consistency complexity without addressing a measured budget breach.
Known fast-follows (low severity, tracked in review): FTS candidates matched via diacritic folding can render an unhighlighted snippet anchored at offset 0.