Improve Expert Panel wheel scroll performance#68
Merged
Conversation
- Coalesce contiguous wheel events at the same cursor position in handle_events so a burst of N ticks produces a single terminal.draw. - Replace per-render self.content.clone() with a shallow borrow_lines view that allocates only Vec<Line>/Vec<Span> wrappers and shares span content via Cow::Borrowed. - Make WHEEL_SCROLL_LINES height-proportional (inner / 4, clamped to [3, 8]) so large panels scroll ~quarter-page per notch while small panels preserve the prior 3-line feel. Covered by new unit tests for wheel_scroll_lines, coalesce_wheel_events, borrow_lines, and a render-parity integration test. make ci green (839 tests passed; clippy and fmt clean).
The scroll indicator printed scroll_offset+1 (the 1-based top-visible visual line), so at full scroll it read max_scroll+1/visual_line_count (e.g. 2039/2121 on an 83-row panel) even though the last content line was already rendered. The wording made it look like scrolling stopped short of the bottom. Render the bottom-visible line instead: (scroll_offset + visible_height).min(visual_line_count) / total so the fully-scrolled state reads 2121/2121. Applied in both the primary render path and the cfg(test) parity helper used by render_shallow_view_matches_cloned_view so parity holds.
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.
Summary
Follow-up perf pass on PR #67. Three changes localized to
src/tower/app.rsandsrc/tower/widgets/expert_panel_display.rs:handle_events: drain contiguous wheel events at the same cursor position within a single main-loop iteration, producing exactly oneterminal.draw()per wheel burst instead of N.borrow_linesview inExpertPanelDisplay::render: replace per-renderself.content.clone()(O(total_bytes) memcpy) with aVec<Line<'_>>ofCow::Borrowedspans, allocating only wrapper structs.WHEEL_SCROLL_LINES = 3withwheel_scroll_lines(panel_height) = clamp(inner/4, 3..=8)so large panels scroll ~quarter-page per notch while small panels preserve the prior 3-line feel.Design:
.macot/specs/expert-panel-wheel-scroll-performance-design.mdTasks:
.macot/specs/expert-panel-wheel-scroll-performance-tasks.mdTest plan
make ci— 842 tests passed, clippy clean under-D warnings, fmt-check cleanwheel_scroll_lines_*(4),handle_mouse_wheel_*(ticks + direction, 4),coalesce_wheel_events_*(P1–P4, 5),borrow_lines_*(P5–P7, 4),render_shallow_view_matches_cloned_view(render parity, 2)(WheelDirection, col, row, ticks)signature andwheel_scroll_lines(height)expected value