Skip to content

perf: batch TUI refreshes and render only visible cards - #305

Merged
swananan merged 1 commit into
mainfrom
perf/tui-refresh-batching
Sep 10, 2026
Merged

perf: batch TUI refreshes and render only visible cards#305
swananan merged 1 commit into
mainfrom
perf/tui-refresh-batching

Conversation

@swananan

Copy link
Copy Markdown
Owner

Every incoming trace or runtime status previously triggered a redraw, and each redraw formatted the entire retained history, including when a single card was expanded. Batch incoming messages and cap redraws at 60 FPS, while flushing the final pending frame after a burst and avoiding redraws while idle.

Build cards around the visible viewport, with bounded lookahead for variable heights, and format only the selected card in expanded view. Preserve scrolling and truncation, and keep the latest or selected card visible when the panel is shorter than a full card. Add seven renderer regression tests covering bounded formatting work, resizing, scrolling, expanded views, truncation, and minimal viewports.

Local renderer benchmark: debug build, 100×40 Ratatui TestBackend, 2,000 synthetic trace events, 50 warmup draws and 500 measured draws. Median redraw times:

View Before After
Auto-refresh list 15.373 ms 1.889 ms
Manual-scroll list 15.462 ms 2.020 ms
Expanded card 12.680 ms 1.189 ms

The updated auto-refresh list takes about 1.89 ms with either 20 or 2,000 retained events.

Validation completed on the same source tree as this PR:

  • cargo fmt --all
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test -p ghostscope-ui --all-features: 157 passed
  • Standard host-to-host e2e: 373 passed, 0 failed, 0 ignored
  • PTY checks of the real TUI: final-frame flush after a burst, no idle redraws, bounded redraw frequency, and responsive shutdown during an event stream

Container-topology e2e was intentionally skipped because this change does not affect container behavior.

@swananan
swananan merged commit a45831d into main Sep 10, 2026
9 checks passed
@swananan
swananan deleted the perf/tui-refresh-batching branch September 10, 2026 15:32
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