Page MenuHomeFreeBSD

Fix various issues with systat's -vmstat screen
Needs ReviewPublic

Authored by sigsys_gmail.com on Feb 7 2020, 8:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 1, 12:08 PM
Unknown Object (File)
Tue, Apr 30, 6:04 PM
Unknown Object (File)
Tue, Apr 30, 6:04 PM
Unknown Object (File)
Tue, Apr 30, 6:04 PM
Unknown Object (File)
Tue, Apr 30, 5:53 PM
Unknown Object (File)
Tue, Apr 30, 2:04 PM
Unknown Object (File)
Mon, Apr 29, 9:03 AM
Unknown Object (File)
Fri, Apr 26, 6:01 PM
Subscribers
None

Details

Reviewers
kevans
kaktus
Summary
  1. humanize_number() was being passed a buffer size that was one byte too small than the intended usable width if you account for the NUL byte that it needs to write. This caused noticeable problems with the Csw/Trp/Sys/Int/Sof/Flt showing without units for me (when the number was big enough). An easy way to get big numbers there is "yes | cat | cat | cat > /dev/null".
  1. Another problem I noticed is that the fields under "Mem: KB" are turned into Ks before being passed to humanize_number(), which may then scale them again. So if it shows "1000K" it actually means "1000M". Pretty confusing. This patch rearranges this part of the screen to always use byte units directly. And it condenses the table a little. Looks a lot nicer I think! It's more like top(1) for this now.
  1. Make other fields that use humanize_number() narrower because it makes them easier to read I think.
  1. Relabelled "Proc:" to "Threads:" because it actually counts threads (hence why it doesn't match the numbers shown in top(1)).
  1. For fields that are just too small for humanize_number(), restore previous behavior of rendering the field as a sequence of "*" characters.

Not fixed:

Point 5).

The fields in the r/p/d/s/w columns under "Proc:" (now "Threads:") have the same problem as the Csw/Trp/Sys/Int/Sof/Flt fields, but I have no idea how to fix them without rearranging the whole screen to give them more space. They only have space for 3 characters, this isn't enough for humanize_number() to do its thing right if the number is larger than 999. The fields next to them have space for 4 characters which is the minimum for it to work correctly.

Maybe we could make this "99+", "INF" or "NaN" instead? Maybe they could be shown in an E notation with no decimal instead (e.g. "1E3" for 1000)?

Also, some functions should be renamed but I'm trying to keep this diff small.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Noticed a bug. Some calculations were sometimes being done with 32 bits integers and overflowing.

Also maybe the "REAL" should be changed to "RESIDENT"? Makes it clearer what it is. In the kernel it computes those stats by adding resident pages count.

sigsys_gmail.com edited the summary of this revision. (Show Details)

Restored the previous behavior of showing "***" when the number is too large instead of a truncated (and possibly misleading) humanize_number() output. It's not great but it's not worse than it was before.