From owner-svn-src-all@FreeBSD.ORG Fri Nov 6 23:52:38 2009 Return-Path: Delivered-To: svn-src-all@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2F881065676; Fri, 6 Nov 2009 23:52:38 +0000 (UTC) (envelope-from delphij@delphij.net) Received: from tarsier.geekcn.org (delphij-pt.tunnel.tserv2.fmt.ipv6.he.net [IPv6:2001:470:1f03:2c9::2]) by mx1.freebsd.org (Postfix) with ESMTP id 7D96E8FC16; Fri, 6 Nov 2009 23:52:36 +0000 (UTC) Received: from localhost (tarsier.geekcn.org [211.166.10.233]) by tarsier.geekcn.org (Postfix) with ESMTP id EE39D55CD6A1; Sat, 7 Nov 2009 07:52:32 +0800 (CST) X-Virus-Scanned: amavisd-new at geekcn.org Received: from tarsier.geekcn.org ([211.166.10.233]) by localhost (mail.geekcn.org [211.166.10.233]) (amavisd-new, port 10024) with ESMTP id NYgym4a96Lvf; Sat, 7 Nov 2009 07:52:25 +0800 (CST) Received: from delta.delphij.net (unknown [206.40.55.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tarsier.geekcn.org (Postfix) with ESMTPSA id F39EF55CD4D1; Sat, 7 Nov 2009 07:52:22 +0800 (CST) DomainKey-Signature: a=rsa-sha1; s=default; d=delphij.net; c=nofws; q=dns; h=message-id:date:from:reply-to:organization:user-agent: mime-version:to:cc:subject:references:in-reply-to: x-enigmail-version:openpgp:content-type; b=iVzDQRmId8y2my54txdG5HEFoGWTIn9iUUvwXgaJpdaVmgO7W3Kf6k81nPytmt2gf CRrBiKnKMyKRzSovHmcIw== Message-ID: <4AF4B6B2.3090706@delphij.net> Date: Fri, 06 Nov 2009 15:52:18 -0800 From: Xin LI Organization: The Geek China Organization User-Agent: Thunderbird 2.0.0.23 (X11/20091022) MIME-Version: 1.0 To: Bruce Evans References: <200911030928.nA39SjLx085597@svn.freebsd.org> <20091103214231.H23957@delplex.bde.org> In-Reply-To: <20091103214231.H23957@delplex.bde.org> X-Enigmail-Version: 0.95.7 OpenPGP: id=18EDEBA0; url=http://www.delphij.net/delphij.asc Content-Type: multipart/mixed; boundary="------------000600040007090308040408" Cc: svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG, Xin LI Subject: Re: svn commit: r198848 - head/bin/ps X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: d@delphij.net List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Nov 2009 23:52:38 -0000 This is a multi-part message in MIME format. --------------000600040007090308040408 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Bruce Evans wrote: > On Tue, 3 Nov 2009, Xin LI wrote: > >> Log: >> Increase width for %CPU, RSS and VSZ columns for now. Modern systems >> tend to have larger memory, larger process, and more CPU. > > This uses space that is not available. Command names(+args) are now > truncated to 9 columns in "ps l" output :-(. They used to be truncated to > 11 columns recently (down from 12 columns in FreeBSD-5.2). I think we may have to live with this, even if we can cut down CPU percentage part, the memory column's width is still too narrow for modern systems. I have actually thought about having the numbers humanized but I'm afraid it would break some existing scripts :( [...] > There seems to be no better fix than to further granulate and dehumanize > the numbers so that they fit in the available space. E.g., a %CPU of >> = 100 and < 9999 should be displayed in %4.0f format; this only > involvues granulation, but above 9999 it needs to be dehumanized as > well and displayed in k or M or larger granularity (it can be > 9999 > with 100 CPUs and > 999k with 10000 CPUs). A VSZ of >= 10000 (k > implicit) needs to be displayed in M or larger granularity (M explicit). Will it sound reasonable to divide pcpu by ncpu and cap the number at 100? Cheers, - -- Xin LI http://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (FreeBSD) iEYEARECAAYFAkr0trIACgkQi+vbBBjt66CxkwCeLjSGhfB438LAsqFcK6vCgdmY 0OIAn2OmQLRttIhvMYVjqQvYviLzgVBc =C87q -----END PGP SIGNATURE----- --------------000600040007090308040408 Content-Type: text/plain; name="ps.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ps.diff" Index: keyword.c =================================================================== --- keyword.c (revision 199006) +++ keyword.c (working copy) @@ -70,7 +70,7 @@ /* PLEASE KEEP THE TABLE BELOW SORTED ALPHABETICALLY!!! */ static VAR var[] = { - {"%cpu", "%CPU", NULL, 0, pcpu, NULL, 5, 0, CHAR, NULL, 0}, + {"%cpu", "%CPU", NULL, 0, pcpu, NULL, 4, 0, CHAR, NULL, 0}, {"%mem", "%MEM", NULL, 0, pmem, NULL, 4, 0, CHAR, NULL, 0}, {"acflag", "ACFLG", NULL, 0, kvar, NULL, 3, KOFF(ki_acflag), USHORT, "x", 0}, Index: nlist.c =================================================================== --- nlist.c (revision 199006) +++ nlist.c (working copy) @@ -47,6 +47,7 @@ int nlistread; /* if nlist already read. */ unsigned long mempages; /* number of pages of phys. memory */ int fscale; /* kernel _fscale variable */ +int ncpu; /* number of cpus */ int donlist(void) @@ -62,6 +63,9 @@ oldlen = sizeof(mempages); if (sysctlbyname("hw.availpages", &mempages, &oldlen, NULL, 0) == -1) return (1); + oldlen = sizeof(ncpu); + if (sysctlbyname("hw.ncpu", &ncpu, &oldlen, NULL, 0) == -1) + return (1); nlistread = 1; return (0); } Index: extern.h =================================================================== --- extern.h (revision 199006) +++ extern.h (working copy) @@ -36,7 +36,7 @@ struct varent; extern fixpt_t ccpu; -extern int cflag, eval, fscale, nlistread, rawcpu; +extern int cflag, eval, fscale, ncpu, nlistread, rawcpu; extern unsigned long mempages; extern time_t now; extern int showthreads, sumrusage, termwidth, totwidth; Index: print.c =================================================================== --- print.c (revision 199006) +++ print.c (working copy) @@ -642,10 +642,13 @@ void pcpu(KINFO *k, VARENT *ve) { - VAR *v; + VAR *v = ve->var; + double pctcpu = getpcpu(k); - v = ve->var; - (void)printf("%*.1f", v->width, getpcpu(k)); + if (pctcpu / ncpu >= 100.0) + (void)printf(" 100"); + else + (void)printf("%*.1f", v->width, pctcpu / ncpu); } static double --------------000600040007090308040408--