NetBSD Problem Report #54334

From he@smistad.uninett.no  Sun Jun 30 10:04:15 2019
Return-Path: <he@smistad.uninett.no>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 54E557A17C
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 30 Jun 2019 10:04:15 +0000 (UTC)
Message-Id: <20190630100406.8F5AF43F5AF@smistad.uninett.no>
Date: Sun, 30 Jun 2019 12:04:06 +0200 (CEST)
From: he@NetBSD.org
Reply-To: he@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: Scale for i/o bytes in "systat vm" jumps around
X-Send-Pr-Version: 3.95

>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:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 30 10:05:00 +0000 2019
>Closed-Date:    Sun Jun 30 20:01:34 +0000 2019
>Last-Modified:  Sun Jun 30 20:01:34 +0000 2019
>Originator:     he@NetBSD.org
>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:/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 */

>Release-Note:

>Audit-Trail:
From: "Havard Eidnes" <he@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/54334 CVS commit: src/usr.bin
Date: Sun, 30 Jun 2019 19:57:24 +0000

 Module Name:	src
 Committed By:	he
 Date:		Sun Jun 30 19:57:24 UTC 2019

 Modified Files:
 	src/usr.bin/systat: vmstat.c vmstat.h
 	src/usr.bin/vmstat: drvstats.c drvstats.h

 Log Message:
 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.


 To generate a diff of this commit:
 cvs rdiff -u -r1.86 -r1.87 src/usr.bin/systat/vmstat.c
 cvs rdiff -u -r1.1 -r1.2 src/usr.bin/systat/vmstat.h
 cvs rdiff -u -r1.12 -r1.13 src/usr.bin/vmstat/drvstats.c
 cvs rdiff -u -r1.5 -r1.6 src/usr.bin/vmstat/drvstats.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: he@NetBSD.org
State-Changed-When: Sun, 30 Jun 2019 20:01:34 +0000
State-Changed-Why:
Suggested patch committed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.