Files
RedBear-OS/local/docs
vasilito 2597246908 redbear-power: v1.31 per-PID IO rate sparkline
Activates the v1.25-deferred 'persistent rate sparkline' future-use.
Each process in the Process tab now shows a 12-sample sparkline
of its IO rate history (last 78 seconds at the 6.5s process
refresh cadence).

- New App.io_history: BTreeMap<u32, VecDeque<u64>>
  Per-PID history of raw f64-bit rate samples. BTreeMap for
  stable iteration; VecDeque for O(1) push-back + pop-front.
- PROCESS_IO_HISTORY_LEN = 12 (12 samples * 6.5s = 78s of history)
- App::update_io_history() runs after sort_tree + apply_fold
  on every process refresh. Three-pass algorithm:
    1. Reap: drop history for PIDs that exited
    2. Append: push new f64-bit sample for PIDs with known rate
       (PIDs with None rate are skipped, no entry created)
    3. Normalize: divide each sample by the per-history max,
       scale to u8 0..=255. Separate pass so max is computed
       once per history, not per sample.
- render::io_rate_sparkline(&[u8]) helper maps 0..=255 to
  Unicode chars (\u2581\u2582... matches existing load sparkline)
- New 'IO-RATE' column in Process panel between RSS/VSZ and
  COMM. 12 chars wide. Empty spaces for PIDs with no history
  yet (first tick after startup).
- Why u64 storage of f64 bits: normalization needs the full
  f64 range; clamping to u8 before normalize would lose
  precision for high-rate PIDs.

Test count 117 -> 121 (+4):
- update_io_history_reaps_exited_pids
- update_io_history_normalizes_against_max (100/200*255=127.5
  rounds to 128; 200/200*255=255)
- update_io_history_handles_all_zero (no div by zero)
- update_io_history_skips_pids_without_rate (None rate \u2192
  no entry created; no panic)

Redox stripped binary: 4,201,320 bytes (+4 KiB from v1.30).
Memory: ~91 KiB for 600 PIDs (negligible).
Compile warnings: 55 (unchanged).

Notes:
- CPU% sparkline per process: defer (same pattern, separate work)
- RSS sparkline per process: defer
- Variable sparkline length: defer (header is 'IO-RATE' not
  'IO-RATE 12' so a future change to PROCESS_IO_HISTORY_LEN
  doesn't need a header update)
- Per-PID scaling (not global): each PID's max is 255. A
  long-running PID at 5 KiB/s steady shows full bars; a
  bursty PID that just started at 50 KiB/s also shows full
  bars. Global scaling would flatten the long-running one.

Docs: local/docs/redbear-power-improvement-plan.md \xC2\xA755
2026-06-21 07:19:16 +03:00
..