Search index: lowercased once, stored per batch, dropped a thousand at a time #267

Merged
littlefox merged 2 commits from issue-232-search-index into main 2026-10-22 05:45:10 +00:00
Owner

Closes #232

  • Each entry keeps a lower-case copy made when it is added; a search no longer lowercases every post (up to 20 000 × 4 000 characters) on every keystroke.
  • Bodies are cut at 1 500 characters (4 000 made a full index ~80 MB).
  • Over 20 000 posts, the oldest 1 000 go at once: the desktop rewrote its whole index file on the UI thread for every post shown once the index was full.
  • The posts one go of the indexing effect adds are stored together (search_view::flush): one IndexedDB transaction, not a database opened per post. (A two-second timer was tried first; a timer started from inside the effect never fired, which the search spec caught.)

Measured with tools/perf.sh (an index of ~700 posts): hits 25 → 16 ms. The difference grows with the index.

Verified: search and mentions specs on three profiles (incl. "kept on the device after a reload"); unit tests incl. the thousand-at-once drop; lint three ways.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XJW2ocwLunyaLiUwCBHEP8

Closes #232 - Each entry keeps a lower-case copy made when it is added; a search no longer lowercases every post (up to 20 000 × 4 000 characters) on every keystroke. - Bodies are cut at 1 500 characters (4 000 made a full index ~80 MB). - Over 20 000 posts, the oldest 1 000 go at once: the desktop rewrote its whole index file on the UI thread for every post shown once the index was full. - The posts one go of the indexing effect adds are stored together (`search_view::flush`): one IndexedDB transaction, not a database opened per post. (A two-second timer was tried first; a timer started from inside the effect never fired, which the search spec caught.) Measured with `tools/perf.sh` (an index of ~700 posts): hits 25 → 16 ms. The difference grows with the index. Verified: search and mentions specs on three profiles (incl. "kept on the device after a reload"); unit tests incl. the thousand-at-once drop; lint three ways. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XJW2ocwLunyaLiUwCBHEP8
Every search lowercased every indexed post again (up to 20 000 posts of
4 000 characters, on each keystroke); once the index was full, each new
post dropped the oldest and the desktop rewrote its whole index file on
the UI thread; and in the browser each post opened the database for its
own transaction. Now each entry keeps a lower-case copy made when it is
added, bodies are cut at 1 500 characters, the oldest 1 000 go at once,
and the posts a go of the indexing effect adds are stored together.

Closes #232

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XJW2ocwLunyaLiUwCBHEP8
Merge remote-tracking branch 'origin/main' into issue-232-search-index
All checks were successful
ci / check (push) Successful in 8m29s
ci / desktop (push) Successful in 15m37s
ci / e2e (push) Successful in 31m0s
ca2cb1fc34
littlefox referenced this pull request from a commit 2026-10-22 14:11:06 +00:00
Sign in to join this conversation.
No description provided.