Skip to main content

Module io

Module io 

Source
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_secs apart.
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/diskstats into 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-io field reports.