Skip to content

perf: reduce search latency with synchronous UI-thread search and lock-free tree rebuild - #24

Merged
bosiakov merged 2 commits into
mainfrom
perf/search-latency
Mar 29, 2026
Merged

perf: reduce search latency with synchronous UI-thread search and lock-free tree rebuild#24
bosiakov merged 2 commits into
mainfrom
perf/search-latency

Conversation

@bosiakov

@bosiakov bosiakov commented Mar 29, 2026

Copy link
Copy Markdown
Contributor
  • Run search + tree rebuild synchronously on the UI thread (~1-3ms) so results appear on the same frame the user types - zero latency
  • Refactor tree rebuild into a pure computeTreeRebuild() function using snapshot-compute-swap to minimize lock hold time
  • Add Parent pointers to prefix tree nodes and TreeNode back-pointers on commands, enabling O(matches × depth) ancestor marking instead of O(total_nodes) full tree walks
  • Optimize hot path: stack-allocate Levenshtein buffers for short strings, add fast determineMatchTypeShort path for 1-2 char queries, cache TreeNodesCount at build time
  • Add dedicated SearchWorker goroutine so background data reloads don't block behind tree rebuilds

@bosiakov
bosiakov merged commit c705cb1 into main Mar 29, 2026
1 check passed
@bosiakov
bosiakov deleted the perf/search-latency branch March 29, 2026 15:28
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