feat: reduce TUI idle CPU with event-driven UI wakeups#139
Merged
Conversation
Replace the 100ms event::poll() cadence with a tokio::select!-based coordinator that sleeps fully when idle. The UI now wakes only for terminal input, resize, fresh collector data, or animation ticks. - Add UiEventCoordinator with dedicated blocking terminal reader task - Add Notify channel from data collectors to UI loop for prompt refresh - Isolate animation ticks to fire only when animated elements are visible - Keyboard/mouse input is now independent of the polling interval Closes #135
Move the mpsc sender into the spawned blocking task instead of cloning it, so the channel closes naturally when the terminal reader exits. Add a TerminalClosed event variant to detect this in the select loop and shut down gracefully, preventing a potential hang when the terminal is lost and animations are inactive.
Member
Author
Code Review Summary: PR #139Overall AssessmentThis PR implements a well-designed transition from a fixed 100ms poll loop to an event-driven Architecture ReviewWhat works well:
No deadlock risk: The Findings Addressed
Fix Applied (commit
|
Cover all UiEvent variants (DataReady, AnimationTick, TerminalClosed, Resize, TerminalInput), UiEventCoordinator construction and toggle methods, the data-ready notification path end-to-end with DataCollector, and sanity checks for the new ANIMATION_TICK_MS / TERMINAL_READER_POLL_MS AppConfig constants.
Member
Author
PR Finalization CompleteSummary
All 193 tests passing (179 lib + 14 new view::ui_events). Ready for merge. |
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
event::poll()loop withtokio::select!-based event coordinator that sleeps fully when idleUiEventCoordinatorwith dedicated blocking terminal reader task,Notifychannel from data collectors, and isolated animation ticksArc<Notify>, eliminating polling-interval latency for screen refreshTest plan
all-smi) starts up, renders GPU/CPU/memory info, and responds to keyboard navigationall-smi view) starts up, renders multi-host data, and tab switching workscargo test --features cliand confirm all existing tests passcargo clippy --features cli -- -D warningswith no warningsCloses #135