feat: cache derived TUI view data to avoid per-frame sorting and cloning#141
Merged
Conversation
Introduce ViewCache that holds pre-computed sorted GPU indices, per-host filtered device subsets, and GPU-filtered process lists. Cache entries are keyed by data_version, current_tab, sort_criteria, and gpu_filter_enabled, and are only recomputed when those inputs change. This eliminates redundant filtering, sorting, and cloning on every render pass, particularly beneficial for large remote deployments with many GPUs and processes.
Replace direct indexing of snapshot.tabs[current_tab] with .get() bounds-checked access in both the ViewCache GPU list builder and the frame renderer fallback path. When current_tab exceeds tabs.len(), the code now gracefully falls back to showing all GPUs instead of panicking. Also add Default impl for ViewCache per Rust conventions.
Member
Author
Code Review SummaryReviewed the ViewCache implementation and its integration into the frame renderer and UI loop. The caching strategy is sound: indices into snapshot arrays are cached rather than cloning data, cache keys are keyed by Findings Addressed
Findings Reviewed (No Fix Needed)
Architecture AssessmentThe cache design is well-structured:
All 230 tests pass, |
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
ViewCache(src/view/view_cache.rs) that caches sorted GPU display indices, per-host filtered device subsets (chassis/CPU/memory/storage), and GPU-filtered process lists across framesFrameRendererso rendering reads from pre-computed indices instead of re-filtering/re-sorting every frame, with inline fallback when cache is unavailableUiLoopwith automatic invalidation on force-clear events (tab change, resize, mode switch) and lazy recomputation keyed bydata_version,current_tab,sort_criteria, andgpu_filter_enabledTest plan
cargo clippy -- -D warningscleancargo fmt --checkcleanCloses #137