YAVP (Yet Another Vmstat Patch)

Giorgos Keramidas keramida at ceid.upatras.gr
Tue Nov 4 16:05:56 PST 2008


On Tue, 04 Nov 2008 23:13:19 +0100, Ivan Voras <ivoras at freebsd.org> wrote:
> Hi,
>
> I'm working on something that tends to generate a lot of context
> switches and I don't like the way values in "vmstat 1" are printed
> practically unbounded, causing wrapping, etc.
>
> Here's a patch against -CURRENT that uses humanize_number() to keep the
> formatting of memory and context switches tabular in the common case:
>
> http://people.freebsd.org/~ivoras/diffs/vmstat.c.patch.txt
>
> The following people might not like it:
>
> * Those who really need to distinguish between 185400 context switches
> and 185499 context switches
> * Those who have scripts that parse the output
> * Those who thought the previous chaotic behaviour is cute :)
>
> Example of new output is:
>
>  procs   memory      page                    disks     faults          cpu
>  r b w  avm free   flt  re  pi  po    fr  sr ad4 ad8   in   sy   cs  us  sy id
>  3 0 0 112M 3.7G     0   0   0   0     0   0   0   0    2 373K 267K   4  37 59
>  2 0 0 112M 3.7G     0   0   0   0     0   0   0   0    0 366K 271K   4  37 59
>  3 0 0 112M 3.7G     0   0   0   0     0   0   0   0    0 370K 267K   4  36 59
>  4 0 0 112M 3.7G     0   0   0   0     0   0   0   0    0 378K 278K   5  36 60
>  3 0 0 112M 3.7G     0   0   0   0     0   0   0   0   69 366K 268K   4  39 58
>  2 0 0 112M 3.7G     0   0   0   0     0   0   0   0   65 372K 271K   5  41 54
>  4 0 0 112M 3.7G     0   0   0   0     0   0   0   0   71 374K 271K   5  40 55
>  2 0 0 112M 3.7G     0   0   0   0     0   0   0   0    6 375K 276K   4  39 57
>
> Any objections to the patch?

Can we convince you to make it an option and default to off at first?

vmstat's current output format has the useful property that fault
columns align nicely when they are ``small enough'', and seeing them
misaligned is something that triggers a ``we have considerable load''
double-check.

Right now my backup script is running, and I see:

: $ vmstat -w 1
:  procs      memory      page                    disks     faults         cpu
:  r b w     avm    fre   flt  re  pi  po    fr  sr ad0 md0   in   sy   cs us sy id
:  3 0 0   1071M   211M   903   0   0   0  1176 388   0   0  661 16032 5783 12  9 79
:  3 0 0   1071M   210M     1   0   0   0    30   0  74   0 1356 3062 7927  7 15 78
:  0 0 0   1071M   209M    20   0   0   0    32   0  79   0 1509 3139 8629  4 16 80
:  0 0 0   1071M   207M     0   0   0   0    30   0  74   0 1306 2988 7653  4 14 82
:  0 0 0   1071M   206M     0   0   0   0    31   0  63   0 1315 2787 7302  6 17 77
:  1 0 0   1071M   205M     0   0   0   0    30   0  49   0 1787 2786 8750  4 20 76
:  0 0 0   1071M   204M     0   0   0   0    30   0  49   0 1974 2465 9480  5 19 76
:  0 0 0   1071M   202M     0   0   0   0    30   0  89   0 1388 3588 8432  6 16 78
:  0 0 0   1071M   200M     1   0   0   0    30   0  87   0 1358 3338 8199  6 17 77
:  3 0 0   1071M   199M     0   0   0   0    30   0  80   0 1367 4142 8216  9 16 75
:  1 0 0   1071M   198M     0   0   0   0    30   0  76   0 1339 3175 8133  6 18 76
:  1 0 0   1071M   241M     0   0   0   0 11354   0  73   0 1361 3055 7839  8 24 68
:  3 0 0   1057M   253M     0   0   0   0  3426   0  82   0 1398 3548 8273 10 17 73
:  2 0 0   1057M   247M     0   0   0   0    31   0 123   0 1357 4377 8113  4 14 82
:  1 0 0   1057M   240M    36   0   1   0    47   0 150   0 1394 4597 8526  6 16 78
:  1 0 0   1057M   233M     0   0   0   0    30   0 146   0 1298 4496 7970  4 15 81
: ^C

Only the first line is misaligned by _one_ character, and I *like* the
extra granularity of the rest.

Your patched version has a shorter `avm' and `fre' too.  Do we really
have to trim them?  They seem to be doing fine with physmem >= 3 GB.



More information about the freebsd-hackers mailing list