Skip to content

vmstat: show si and so in the --unit size instead of pages - #871

Open
Harp404 wants to merge 1 commit into
uutils:mainfrom
Harp404:vmstat-swap-units
Open

Harp404 wants to merge 1 commit into
uutils:mainfrom
Harp404:vmstat-swap-units

Conversation

@Harp404

@Harp404 Harp404 commented Dec 1, 2026

Copy link
Copy Markdown

The si and so columns printed the number of pages swapped per second, while procps-ng prints the amount of memory, in the -S/--unit size (KiB by default). Its man page lists si and so as "affected by the --unit option". On a machine with 4 KiB pages, uutils showed a quarter of the real value, and -S had no effect:

$ vmstat -S M        # procps-ng 4.0.4
... ---swap-- ...
...   si   so ...
...    0    0 ...
$ vmstat -S M        # uutils, before
...    4   11 ...

get_swap_info now converts the page counts to bytes with the page size (sysconf(_SC_PAGESIZE), as pgrep does for the clock tick), divides by the period and scales with with_unit, like the memory columns. This needs the libc feature of uucore in uu_vmstat, which snice, top and w already enable.

On my machine, vmstat, vmstat -S k, vmstat -S K and vmstat -S M now print the same si/so as procps-ng. The unit test swap_rate_uses_unit covers the conversion with fixed numbers. cargo fmt and cargo clippy -p uu_vmstat --all-targets -- -D warnings are clean.

I used Claude Code (Opus 5.5) to help investigate and draft this change; I reproduced the bug and checked the fix myself.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 09:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 20.28%. Comparing base (67832aa) to head (9584872).
⚠️ Report is 63 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/vmstat/src/picker.rs 0.00% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #871      +/-   ##
==========================================
+ Coverage   19.20%   20.28%   +1.08%     
==========================================
  Files          68       68              
  Lines       10156    10111      -45     
  Branches      546      551       +5     
==========================================
+ Hits         1950     2051     +101     
+ Misses       8206     8060     -146     
Flag Coverage Δ
macos_latest ?
ubuntu_latest 20.69% <0.00%> (+1.13%) ⬆️
windows_latest 0.02% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants