NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/54334: Scale for i/o bytes in "systat vm" jumps around



>Number:         54334
>Category:       bin
>Synopsis:       Scale for i/o bytes in "systat vm" jumps around
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 30 10:05:00 +0000 2019
>Originator:     he%NetBSD.org@localhost
>Release:        NetBSD 8.99.33
>Organization:
	I Try...
>Environment:
System: NetBSD malus.urc.uninett.no 8.99.33 NetBSD 8.99.33 (MALUS) #0: Mon Feb  4 10:05:23 CET 2019  he%malus.urc.uninett.no@localhost:/usr/obj/sys/arch/macppc/compile/MALUS macppc
Architecture: powerpc
Machine: macppc
>Description:
	In the "systat vm" display, the field which displays the drive
	write stats, the scale may "jump around" from one instance to
	the next.  This, combined with the larger field, makes it
	difficult to visually gauge the values, as they may display in
	quick succession

	124334
	  3412
	 1098K
	 3092K
	341250
	 23001

	The increased update frequency (5s in -8, apparently 1s in
	-current) exacerbates the problem.

>How-To-Repeat:
	Run "systat vm", and look at the drive write values.  In all
	probability the scale will "fluctuate", making it difficult to
	visually compare the values.
	
>Fix:
	I propose this patch.
	It will cause the scale value to become sticky per drive, so
	that if it's once used the "K" scale, it will not drop back to
	showing single bytes, and similarly for the higher scales.

	Comments?

	Patch is against -current.

Index: usr.bin/systat/vmstat.c
===================================================================
RCS file: /cvsroot/src/usr.bin/systat/vmstat.c,v
retrieving revision 1.86
diff -u -p -r1.86 vmstat.c
--- usr.bin/systat/vmstat.c	25 Jan 2019 15:34:22 -0000	1.86
+++ usr.bin/systat/vmstat.c	30 Jun 2019 09:51:41 -0000
@@ -756,7 +756,7 @@ cputime(int indx)
 }
 
 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 @@ puthumanint(u_int64_t n, int l, int c, i
 		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 @@ puthumanint(u_int64_t n, int l, int c, i
 }
 
 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 @@ dinfo(int dn, int r, int c)
 	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 */
Index: usr.bin/systat/vmstat.h
===================================================================
RCS file: /cvsroot/src/usr.bin/systat/vmstat.h,v
retrieving revision 1.1
diff -u -p -r1.1 vmstat.h
--- usr.bin/systat/vmstat.h	18 Mar 2006 14:58:49 -0000	1.1
+++ usr.bin/systat/vmstat.h	30 Jun 2019 09:51:41 -0000
@@ -35,6 +35,8 @@ extern double etime;
 
 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;
Index: usr.bin/vmstat/drvstats.c
===================================================================
RCS file: /cvsroot/src/usr.bin/vmstat/drvstats.c,v
retrieving revision 1.12
diff -u -p -r1.12 drvstats.c
--- usr.bin/vmstat/drvstats.c	8 Feb 2018 09:05:21 -0000	1.12
+++ usr.bin/vmstat/drvstats.c	30 Jun 2019 09:51:41 -0000
@@ -346,6 +346,7 @@ drvinit(int selected)
 	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));
Index: usr.bin/vmstat/drvstats.h
===================================================================
RCS file: /cvsroot/src/usr.bin/vmstat/drvstats.h,v
retrieving revision 1.5
diff -u -p -r1.5 drvstats.h
--- usr.bin/vmstat/drvstats.h	4 Jul 2017 21:19:33 -0000	1.5
+++ usr.bin/vmstat/drvstats.h	30 Jun 2019 09:51:41 -0000
@@ -45,6 +45,7 @@ struct _drive {
 	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