From owner-freebsd-current@FreeBSD.ORG Thu Jul 8 22:24:12 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2686716A4CE; Thu, 8 Jul 2004 22:24:12 +0000 (GMT) Received: from smtp.des.no (flood.des.no [217.116.83.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id D19CD43D1D; Thu, 8 Jul 2004 22:24:11 +0000 (GMT) (envelope-from des@des.no) Received: by smtp.des.no (Pony Express, from userid 666) id C1BE75312; Fri, 9 Jul 2004 00:24:10 +0200 (CEST) Received: from dwp.des.no (des.no [80.203.228.37]) by smtp.des.no (Pony Express) with ESMTP id 9661B530D; Fri, 9 Jul 2004 00:24:01 +0200 (CEST) Received: by dwp.des.no (Postfix, from userid 2602) id 10DE9B886; Fri, 9 Jul 2004 00:24:00 +0200 (CEST) To: Giorgos Keramidas References: <20040707124751.GA66588@orion.daedalusnetworks.priv> From: des@des.no (=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=) Date: Fri, 09 Jul 2004 00:24:00 +0200 In-Reply-To: <20040707124751.GA66588@orion.daedalusnetworks.priv> (Giorgos Keramidas's message of "Wed, 7 Jul 2004 15:47:51 +0300") Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on flood.des.no X-Spam-Level: X-Spam-Status: No, hits=0.0 required=5.0 tests=AWL autolearn=no version=2.63 cc: Alfred Perlstein cc: current@freebsd.org Subject: Re: RFC: Sorting in top -m io X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Jul 2004 22:24:12 -0000 Giorgos Keramidas writes: > What do you all think of this patch to top(1)? extremely inefficient; get_io_stats() is an expensive function and you really don't want to call it approximately log(n) per process while sorting, especially when it returns the same values every time. an ugly trick to get around this is to have get_process_info() store io stats in ki_spare[] or some other unused kinfo_proc field, so you never need to call get_io_stats() outside get_process_info(). you should also do secondary sort orders like the existing compare_*() functions do, since qsort() is unstable, so processes with identical stats will jump around if they aren't also sorted by name or some other secondary criterion. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no