-
Notifications
You must be signed in to change notification settings - Fork 190
Commit d508627
committed
scxtop: Refactor scheduler rendering into separate module (Phase 4)
Extract all scheduler rendering logic from app.rs into a dedicated
SchedulerRenderer module, continuing the refactoring effort to improve
code organization and maintainability.
This phase extracts 9 methods related to DSQ (Dispatch Queue)
visualization and scheduler statistics rendering.
Changes:
- Extract scheduler rendering methods into render::SchedulerRenderer
- Create stateless static methods with clear public API
- Add comprehensive test suite (8 tests, 100% pass rate)
- Remove old methods from app.rs and delegate to new module
- Fix borrowing issues with theme access in render methods
Modified Files:
tools/scxtop/src/app.rs
- Remove dsq_sparkline, dsq_sparklines, dsq_bar, dsq_bars methods
- Remove render_scheduler_stats, render_scheduler_sparklines,
render_scheduler_barchart, render_scheduler methods
- Remove unused resize_sched_events helper
- Add SchedulerRenderer import and delegation
- Fix theme borrowing by calling self.theme() directly
tools/scxtop/src/render/mod.rs
- Add scheduler module declaration
- Export SchedulerRenderer
New Files:
tools/scxtop/src/render/scheduler.rs
- SchedulerRenderer struct with static methods
- Public API: render_scheduler_view(), render_scheduler_stats()
- Private helpers: dsq_sparkline, dsq_sparklines, dsq_bar, dsq_bars
- Utility methods: gradient5_color, render_error_msg
- Support for all view states: Sparkline, BarChart, LineGauge
- Handle all DSQ metrics: lat_us, slice_consumed, vtime, nr_queued
tools/scxtop/tests/render_scheduler_tests.rs
- 8 comprehensive tests covering all rendering paths
- Tests for sparkline/barchart views, edge cases, localization
- Theme compatibility tests (Default, MidnightGreen, SolarizedDark)
- Helper function: create_test_dsq_data()
API Design:
render_scheduler_view() - Main rendering entry point
- Returns Result<usize> with new max_sched_events value
- Handles dynamic terminal resizing
- Supports localization and multiple themes
render_scheduler_stats() - Render scheduler statistics panel
- Displays scheduler name, tick rate, dispatch settings
- Returns Result<()>
Technical Details:
- Fixed type mismatch: dispatch_keep_last/select_cpu_fallback i64→i64
- Fixed borrowing conflict by removing theme variable caching
- Updated all call sites in render() and render_mangoapp()
- Gracefully handle edge cases (missing scheduler, empty DSQ data)
- All methods return Result<T> for proper error handling
Signed-off-by: Daniel Hodges <[email protected]>1 parent 58049ad commit d508627Copy full SHA for d508627
File tree
Expand file treeCollapse file tree
4 files changed
+908
-359
lines changedOpen diff view settings
Filter options
- tools/scxtop
- src
- render
- tests
Expand file treeCollapse file tree
4 files changed
+908
-359
lines changedOpen diff view settings
0 commit comments