perf: stop the freeze on huge conversations and speed up filtering#20
Merged
Conversation
Three hot-path fixes, all measured on the real corpus: 1. Memoise HITS per query (hitCounter), keyed by SessionID. formatListItem was rescanning every message of every visible row each frame; holding a nav key at a list boundary on a 6k-message conversation queued ~65ms frames into a multi-second freeze. Cached: View drops 65ms -> 4.7ms/frame. 2. Memoise the selected conversation's preview lines (previewCache), keyed by SessionID+query, so renderPreview/maxPreviewScroll don't rebuild every frame. 3. Incremental filtering: when the new query contains the previous one, every new match already matched the old query, so updateFilter filters the previous (smaller) result set instead of rescanning all conversations. Steady-state typing of a narrowing query: ~10ms -> ~1-2ms. Caches are pointer-held so they survive the value-receiver copies View makes, and invalidate when the query/selection changes.
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.
Gets the perf fixes onto
main. #19 was stacked on #18's branch and merged into that branch instead ofmain(same stacked-PR trap as #16/#17), so the perf work never reached main and isn't in the latest release. This replays it onto current main (which already has #18's mouse-leak fix).Three hot-path optimisations, all measured on the real 314-conversation corpus:
formatListItemrescanned every message of every visible row each frame; holding a clamped nav key on a 6k-message conversation queued ~65ms frames into a multi-second freeze. Memoised per query (keyed by SessionID):View65ms → 4.7ms/frame.renderPreview/maxPreviewScrollno longer rebuild the preview every frame.updateFilterfilters the previous (smaller) result set instead of rescanning all conversations: narrowing keystroke ~10ms → ~1-2ms.Caches are pointer-held so they survive the value-receiver copies
Viewmakes, and invalidate on query/selection change.Tests:
TestHitCountCachedPerQuery,TestPreviewLinesCachedUntilSelectionOrQueryChanges,TestUpdateFilterIncrementalNarrowing.go vetclean; coverage 63.6%.