Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin Make the scaling of the "bytes written" sticky, so t...
details: https://anonhg.NetBSD.org/src/rev/d2d7879fc547
branches: trunk
changeset: 842408:d2d7879fc547
user: he <he%NetBSD.org@localhost>
date: Sun Jun 30 19:57:23 2019 +0000
description:
Make the scaling of the "bytes written" sticky, so that if we go
to K, we don't return to unscaled, and similar for higher scales
(though it takes some effort, due to the wide field...)
Fixes PR#54334.
diffstat:
usr.bin/systat/vmstat.c | 34 ++++++++++++++++++++++++++++------
usr.bin/systat/vmstat.h | 4 +++-
usr.bin/vmstat/drvstats.c | 3 ++-
usr.bin/vmstat/drvstats.h | 3 ++-
4 files changed, 35 insertions(+), 9 deletions(-)
diffs (128 lines):
diff -r 1a989fd6b8c1 -r d2d7879fc547 usr.bin/systat/vmstat.c
--- a/usr.bin/systat/vmstat.c Sun Jun 30 17:33:59 2019 +0000
+++ b/usr.bin/systat/vmstat.c Sun Jun 30 19:57:23 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.86 2019/01/25 15:34:22 christos Exp $ */
+/* $NetBSD: vmstat.c,v 1.87 2019/06/30 19:57:23 he Exp $ */
/*-
* Copyright (c) 1983, 1989, 1992, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94";
#endif
-__RCSID("$NetBSD: vmstat.c,v 1.86 2019/01/25 15:34:22 christos Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.87 2019/06/30 19:57:23 he Exp $");
#endif /* not lint */
/*
@@ -756,7 +756,7 @@
}
void
-puthumanint(u_int64_t n, int l, int c, int w)
+puthumanint_scale(u_int64_t n, int l, int c, int w, int scale)
{
char b[128];
@@ -766,7 +766,7 @@
hline(' ', w);
return;
}
- if (humanize_number(b, w, n, "", HN_AUTOSCALE, HN_NOSPACE) == -1 ) {
+ if (humanize_number(b, w, n, "", scale, HN_NOSPACE) == -1 ) {
hline('*', w);
return;
}
@@ -774,6 +774,28 @@
}
void
+puthumanint_sticky(u_int64_t n, int l, int c, int w, int *scale)
+{
+ char b[128];
+ int sc;
+
+ sc = humanize_number(b, w, n, "", HN_GETSCALE, HN_NOSPACE);
+ if (sc > *scale)
+ *scale = sc;
+ else
+ sc = *scale;
+
+ puthumanint_scale(n, l, c, w, sc);
+}
+
+void
+puthumanint(u_int64_t n, int l, int c, int w)
+{
+
+ puthumanint_scale(n, l, c, w, HN_AUTOSCALE);
+}
+
+void
putint(int n, int l, int c, int w)
{
char b[128];
@@ -899,8 +921,8 @@
putint((int)((cur.rxfer[dn]+cur.wxfer[dn])/dtime+0.5),
r, c, DISKCOLWIDTH);
ADV;
- puthumanint((cur.rbytes[dn] + cur.wbytes[dn]) / dtime + 0.5,
- r, c, DISKCOLWIDTH);
+ puthumanint_sticky((cur.rbytes[dn] + cur.wbytes[dn]) / dtime + 0.5,
+ r, c, DISKCOLWIDTH, &cur.scale[dn]);
ADV;
/* time busy in disk activity */
diff -r 1a989fd6b8c1 -r d2d7879fc547 usr.bin/systat/vmstat.h
--- a/usr.bin/systat/vmstat.h Sun Jun 30 17:33:59 2019 +0000
+++ b/usr.bin/systat/vmstat.h Sun Jun 30 19:57:23 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.h,v 1.1 2006/03/18 14:58:49 dsl Exp $ */
+/* $NetBSD: vmstat.h,v 1.2 2019/06/30 19:57:23 he Exp $ */
/*-
* Copyright (c) 1983, 1989, 1992, 1993
@@ -35,6 +35,8 @@
void putfloat(double, int, int, int, int, int);
void putint(int, int, int, int);
+void puthumanint_scale(u_int64_t, int, int, int, int);
+void puthumanint_sticky(u_int64_t, int, int, int, int*);
void puthumanint(u_int64_t, int, int, int);
typedef struct uvmexp_sysctl uvmexp_sysctl_t;
diff -r 1a989fd6b8c1 -r d2d7879fc547 usr.bin/vmstat/drvstats.c
--- a/usr.bin/vmstat/drvstats.c Sun Jun 30 17:33:59 2019 +0000
+++ b/usr.bin/vmstat/drvstats.c Sun Jun 30 19:57:23 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drvstats.c,v 1.12 2018/02/08 09:05:21 dholland Exp $ */
+/* $NetBSD: drvstats.c,v 1.13 2019/06/30 19:57:24 he Exp $ */
/*
* Copyright (c) 1996 John M. Vinopal
@@ -346,6 +346,7 @@
cur.seek = calloc(ndrive, sizeof(u_int64_t));
cur.rbytes = calloc(ndrive, sizeof(u_int64_t));
cur.wbytes = calloc(ndrive, sizeof(u_int64_t));
+ cur.scale = calloc(ndrive, sizeof(int));
last.time = calloc(ndrive, sizeof(struct timeval));
last.wait = calloc(ndrive, sizeof(struct timeval));
last.waitsum = calloc(ndrive, sizeof(struct timeval));
diff -r 1a989fd6b8c1 -r d2d7879fc547 usr.bin/vmstat/drvstats.h
--- a/usr.bin/vmstat/drvstats.h Sun Jun 30 17:33:59 2019 +0000
+++ b/usr.bin/vmstat/drvstats.h Sun Jun 30 19:57:23 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: drvstats.h,v 1.5 2017/07/04 21:19:33 mlelstv Exp $ */
+/* $NetBSD: drvstats.h,v 1.6 2019/06/30 19:57:24 he Exp $ */
/*
* Copyright (c) 1996 John M. Vinopal
@@ -45,6 +45,7 @@
u_int64_t *seek; /* # of seeks (currently unused). */
u_int64_t *rbytes; /* # of bytes read. */
u_int64_t *wbytes; /* # of bytes written. */
+ int *scale; /* Sticky scale for bytes */
struct timeval *time; /* Time spent in disk i/o. */
struct timeval *wait; /* Time spent in queue waiting. */
struct timeval *busysum; /* Time busy * queue length */
Home |
Main Index |
Thread Index |
Old Index