Expand description
Disk and network I/O throughput sampling.
Both fields report a rate, which a one-shot process cannot read directly: the
kernel exposes cumulative counters, so a rate needs two samples and a known interval.
fastfetch solves this with a dedicated ~1 s sleep (measured: fastfetch -s NetIO
takes 1.00 s against 0.00 s for a counter-only module). retch cannot afford that —
--long targets ~500 ms end to end, and being slower than fastfetch is treated as a
blocking regression (NOTES.md §3, “Performance Regression Vigilance”).
So this module follows the v0.3.49 cpu-usage pattern instead: fetch samples the
counters before the concurrent probe scope and diffs them after, making the
existing collection window the sampling interval. A floor is applied only when the
window came out too short to measure anything (an isolated --fields disk-io), which
is the sole case where these fields add any wall-clock at all.
The consequence, stated plainly because it is the honest reading of the number: the
window varies by mode — roughly 0.4 s in --long, seconds in --full — so the value
is the average rate over the run, not an instantaneous one. That is the right
trade for a fetcher; a stable window would cost a sleep on every invocation.
Structs§
- IoCounters
- Cumulative byte counters for one device at a point in time.
- IoRate
- A device’s throughput over the sampling window, in bytes per second.
Functions§
- compute_
rates - Computes per-device rates between two samples taken
elapsed_secsapart. - format_
io_ line - Renders one device’s rates as a display line, e.g.
"nvme0n1 R: 1.2 MB/s W: 0 B/s". - format_
rate - Formats a byte-per-second rate for display (
"1.2 MB/s"). - parse_
diskstats - Parses
/proc/diskstatsinto per-device byte counters. - sample_
disk_ io - Samples cumulative disk byte counters for physical whole disks.
- sample_
net_ io - Samples cumulative network byte counters per interface.
- select_
net_ rates - Chooses which interfaces the
net-iofield reports.