Skip to content

perf(root-search): precompile command scoring fields#557

Closed
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-root-command-score-index-pr
Closed

perf(root-search): precompile command scoring fields#557
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-root-command-score-index-pr

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added precompiled root-search query/field scoring primitives so normalized text, compact text, tokens, and camel initials are computed once and reused.
  • Added a reusable root command score index that preserves rankCommands' existing score/order contract while exposing indexed match metadata for root command candidates.
  • Memoized the command score index in useLauncherCommandModel for active root command search, recomputing when the searchable command snapshot or aliases change.
  • Added scripts/test-root-search-perf.mjs to assert exact root command signatures and report legacy, compatibility-wrapper, indexed, and compile timings.

Why

Root command ranking was rebuilding scoring fields and normalized forms for every command on every query. The indexed path moves that work to a command/alias snapshot compile step and keeps per-keystroke ranking focused on the query and precompiled field data.

Compatibility impact

  • rankCommands(commands, query, aliases) still returns the public { command, score } shape and preserves the existing ranking weights, alias exact sorting, always-on-top handling, and title tie-breaks.
  • The new indexed path reuses the same command values and second-pass root scoring weights that useLauncherCommandModel already used for matchKind and matchScore.
  • The perf harness asserts the indexed result signatures match the existing two-pass command path for all measured queries.

How tested

  • node scripts/test-root-search-ranking.mjs
  • node scripts/test-root-search-perf.mjs
    • Before implementation on this worker branch: optimized command scoring path median 1567.54ms for 6000 commands / 8 queries.
    • After on this clean PR branch: indexed command scoring path median 105.51ms, index compile median 77.94ms.
    • Clean PR harness also reported legacy median 2357.29ms, compatibility-wrapper median 936.64ms, and legacy-vs-indexed speedup 22.34x.
  • git diff --check
  • ./node_modules/.bin/tsc -p tsconfig.renderer.json --noEmit --pretty false ❌ existing renderer typecheck failures on origin/main remain outside this change, including existing errors in App.tsx, CameraExtension.tsx, LiquidGlassSurface.tsx, browser profile typing in useLauncherCommandModel.ts, and several Raycast runtime/settings files.

Stack validation

@JustYannicc

Copy link
Copy Markdown
Collaborator Author

Superseded by #535. The root command score index work from this draft is now folded into JustYannicc:codex/consolidate-search-indexing, and #535's body includes the #557 validation and performance evidence. Closing this draft so the search/root scoring cleanup stays in the consolidated upstream PR.

@JustYannicc JustYannicc closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant