perf: scroll-optimised flush() in cursedRenderer#1725
Open
luispabon wants to merge 2 commits into
Open
Conversation
Detect content scroll at the string level by comparing previous and current frame lines. When a vertical shift is found: 1. Strip identical leading/trailing chrome lines (status bars, padding) 2. Shift cell buffer rows in-place instead of clearing + full reparse 3. Emit terminal scroll sequences via HardScroll (DECSTBM + scroll ops) 4. Use DrawOver only on the N new/changed lines This reduces scroll frame cost from ~800us to ~260us for typical TUI layouts with fixed chrome and a scrolling content region. Falls back to the original Clear+Draw path when no scroll pattern is detected. Includes comprehensive tests (scroll detection, cell buffer shifting, prefix matching) and benchmarks (scroll, static, full-change, partial chrome, scrollbar suffix scenarios).
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.
Closes #1724
Depends on charmbracelet/ultraviolet#130.
This optimises
cursedRenderer.flush()for vertical scrolling by detecting string-level line shifts, trimming identical fixed chrome, shifting the cell buffer in place, and using ultravioletHardScrollplusDrawOveronly for newly exposed lines. When no scroll pattern is detected, it falls back to the originalClear+Drawpath.Benchstat (
sec/op)FlushStatic-16andFlushFullChange-16were regression-free insec/op(p=0.183andp=1.000, respectively).Files
New files:
cursed_renderer_bench_test.gocursed_renderer_scroll.gocursed_renderer_scroll_test.goModified files:
cursed_renderer.gogo.modgo.sum