perf(render): fix lazy-render and fold performance for large sessions#393
Open
jensenojs wants to merge 1 commit into
Open
perf(render): fix lazy-render and fold performance for large sessions#393jensenojs wants to merge 1 commit into
jensenojs wants to merge 1 commit into
Conversation
- Replace cursor+zc fold creation with :{from},{to}fold Ex commands
— avoids cursor-triggered screen redraws (~90ms/fold in large buffers)
- Switch to foldmethod=manual and stay there — prevents foldexpr
recalculation on every buffer line (~4.6s on 87K lines)
- Lazy-render only viewport-sized message count on initial load
- Load more messages on scroll-to-top via WinScrolled autocmd
- Fix lazy_render_count being cleared by M.reset() — read before reset,
persist back to ctx after determining limit
- Debounce WinScrolled load_more callback (150ms) to prevent rapid
re-renders during fast scrolling
- Remove debug vim.notify logging from render paths
Performance: ~36s → ~10ms render time on a 2786-msg/87K-line session.
Closes sudo-tee#392
c7a6c60 to
a05543b
Compare
Owner
|
Thanks for the PR. I will have a look at soon, I will be out for the weekend. So I will look at it at the start of the next week |
Contributor
Author
|
I want to go out and have fun too. Have a nice weekend! |
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.
Problem
2786-message sessions take ~36 seconds to render. Two root causes:
set_folds()usescursor() + normal! zc/zoper fold, each triggering a full-screen redraw (~90ms/fold × 392 folds)_render_full_session_data()renders all messages on initial loadCloses #392
Changes
Fold performance (36s → 3s)
vim.fn.cursor() + normal! zc/zowith:{from},{to}foldand:{from},{to}foldopen!— Ex commands don't move the cursor, zero screen redrawsfoldmethod=manualbefore creating folds and stay there — prevents foldexpr recalculation for every buffer line (~4.6s on 87K lines)E16: Invalid rangeerrorsLazy render (3s → ~10ms)
WinScrolledautocmdopts.lazy = trueexplicit opt-in — tests and headless environments render all messageslazy_render_countbeing cleared byM.reset(): read before reset, persist back toctxafter determining limitWinScrolledload_morecallback (150ms) to prevent rapid re-renders during fast scrollingvim.notifylogging from render pathsPerformance
Measured on a 2786-msg / 87K-line session
Testing
7 new test cases in
tests/unit/renderer_lazy_spec.lua:lazy=falsectx.lazy_render_countis setlazy_render_countincrement across render reset (exposes the core bug)load_more_messagesincrements rendered message countload_more_messagesreturns false when all/no messages loadedAll 110 existing tests pass.