From owner-freebsd-hackers@FreeBSD.ORG Wed Jul 27 07:40:11 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8AFD9106566B; Wed, 27 Jul 2011 07:40:11 +0000 (UTC) (envelope-from etnapierala@googlemail.com) Received: from mail-fx0-f44.google.com (mail-fx0-f44.google.com [209.85.161.44]) by mx1.freebsd.org (Postfix) with ESMTP id DA1CE8FC08; Wed, 27 Jul 2011 07:40:10 +0000 (UTC) Received: by fxe6 with SMTP id 6so12231fxe.17 for ; Wed, 27 Jul 2011 00:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=sender:subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=NGWMyM9T4zHOUSEB4fOeh1SNjQ26JsS59QTz/vfWUy0=; b=UwnhNBhAoPS80jw6jRF88u18L7s79tjcHh4JbuqUN6MUcEzEfu57Wz7IzLVo9iFO/F 9vDh5Xy8/jDMDQtaGOIj2p5zFyhLWdwd0/34LiFPamVHn7FIDboGC8kgFpe/M/xNQ511 r1rReI1DGxsp8hC3dKio3d/V3rhY+FmIBmaJE= Received: by 10.223.160.65 with SMTP id m1mr7912586fax.28.1311752409081; Wed, 27 Jul 2011 00:40:09 -0700 (PDT) Received: from enapierala.whl (58.wheelsystems.com [83.12.187.58]) by mx.google.com with ESMTPS id o17sm189934fal.2.2011.07.27.00.40.07 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 27 Jul 2011 00:40:08 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Mime-Version: 1.0 (Apple Message framework v1244.3) Content-Type: text/plain; charset=iso-8859-2 From: =?iso-8859-2?Q?Edward_Tomasz_Napiera=B3a?= In-Reply-To: <20110724222224.GA64487@freebsd.org> Date: Wed, 27 Jul 2011 09:40:06 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: References: <0CEA161B-6767-4379-B923-585B3D4EA74E@freebsd.org> <86hb6e1bau.fsf@gmail.com> <589EB85A-1902-4643-A1FD-3C98445127DB@freebsd.org> <20110724222224.GA64487@freebsd.org> To: Alexander Best X-Mailer: Apple Mail (2.1244.3) Cc: Test Rat , freebsd-hackers@freebsd.org Subject: Re: Autosizing column widths in ps(1). X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2011 07:40:11 -0000 Wiadomo=B6=E6 napisana przez Alexander Best w dniu 25 lip 2011, o godz. = 00:22: > On Sun Jul 24 11, Edward Tomasz Napiera?a wrote: >> Wiadomo?? napisana przez Test Rat w dniu 22 lip 2011, o godz. 19:21: >>> Edward Tomasz Napiera?a writes: >>>=20 >>>> Patch below changes ps(1) to automatically size column widths = according to their >>>> contents. =46rom the user point of view, it prevents breaking = layout with too wide values >>>> and in most cases makes output narrower. =46rom the developer = point of view, it removes >>>> the need to specify widths. Testing is welcome - the patch = shouldn't change ps(1) >>>> behaviour except slightly changing the widths, but the code changes = are pretty large >>>> and it's quite possible I've missed something. >>>=20 >>> STAT column seems to be right-aligned when it was previously = left-aligned. >>> This makes sorting it harder, e.g. >>>=20 >>> $ ps ax | (IFS=3D; read h; echo $h; sort -k3) | less >>=20 >> Good catch, thanks! Updated patch, which also fixes two issues = affecting TTY column, >> is at http://people.freebsd.org/~trasz/ps-9.diff. >=20 > working great here. have you experienced any performance issues, due = to ps > having to iterate through all columns before constructing the output = in > comparison to the previous design? It had to iterate through them before; what has changed is that now it = stores the strings before printing them out. This means increased memory usage - if you = have thousands of processes, the new ps(1) will use tens of kilobytes of memory. = Hardly a showstopper, imho. > P.S.: one utility which would also benefit from auto column sizing is = top, for > sure! ;) The problem with top(1) is that you don't want your column widths to = change at every refresh. This is somewhat similar to the situation with = vmstat(8). -- If you cut off my head, what would I say? Me and my head, or me and my = body?