perf: optimize command palette ranking, slim index, and lazy-load preview content #47

Merged
clanker merged 3 commits from perf/command-palette-optimizations into main 2026-08-30 17:31:09 +00:00
Member

Summary of Changes

  1. Search Index Size Optimization:

    • Reduced public/search-index.json from ~25 MB to ~4.9 MB by omitting giant HTML bodies on talents, feats, drawbacks, and rules while keeping search metadata, snippets, and prerequisites.
    • Retained structured quick-stats and progression table HTML for the 56 class hubs directly in SearchItem.talent.
  2. Zero-Allocation Hot-Path Search Scoring:

    • Removed singularizeTag and inner-loop regexes from searchRank.ts and tagStyles.ts.
    • Introduced pre-normalized field caching (_nameClean, _tagsJoined, _groupClean, _snippetLower, _prereqsClean) to execute queries with pure native substring and string comparisons in ~1.6ms across 10,411 items.
  3. Smooth Command Palette Input & Lazy Loading:

    • Integrated useDeferredValue for search query handling so text entry is never blocked by filtering/ranking.
    • Removed duplicate rankItems execution inside handleQueryChange.
    • Added on-demand loading of full rules HTML from public/preview-content/<page>.json for preview drawer.
    • Added 1-second debounce prefetcher: when typing pauses for 1 second, all unique preview files for visible entries in the list are fetched in the background so navigating results is instantaneous.
### Summary of Changes 1. **Search Index Size Optimization**: - Reduced `public/search-index.json` from ~25 MB to ~4.9 MB by omitting giant HTML bodies on talents, feats, drawbacks, and rules while keeping search metadata, snippets, and prerequisites. - Retained structured quick-stats and progression table HTML for the 56 class hubs directly in `SearchItem.talent`. 2. **Zero-Allocation Hot-Path Search Scoring**: - Removed `singularizeTag` and inner-loop regexes from `searchRank.ts` and `tagStyles.ts`. - Introduced pre-normalized field caching (`_nameClean`, `_tagsJoined`, `_groupClean`, `_snippetLower`, `_prereqsClean`) to execute queries with pure native substring and string comparisons in ~1.6ms across 10,411 items. 3. **Smooth Command Palette Input & Lazy Loading**: - Integrated `useDeferredValue` for search query handling so text entry is never blocked by filtering/ranking. - Removed duplicate `rankItems` execution inside `handleQueryChange`. - Added on-demand loading of full rules HTML from `public/preview-content/<page>.json` for preview drawer. - Added 1-second debounce prefetcher: when typing pauses for 1 second, all unique preview files for visible entries in the list are fetched in the background so navigating results is instantaneous.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Home/Spheres4Dummies!47
No description provided.