Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Jul 2011 09:40:06 +0200
From:      =?iso-8859-2?Q?Edward_Tomasz_Napiera=B3a?= <trasz@freebsd.org>
To:        Alexander Best <arundel@freebsd.org>
Cc:        Test Rat <ttsestt@gmail.com>, freebsd-hackers@freebsd.org
Subject:   Re: Autosizing column widths in ps(1).
Message-ID:  <A2C6B016-9DF3-42C5-BCCF-1661201770CE@freebsd.org>
In-Reply-To: <20110724222224.GA64487@freebsd.org>
References:  <0CEA161B-6767-4379-B923-585B3D4EA74E@freebsd.org> <86hb6e1bau.fsf@gmail.com> <589EB85A-1902-4643-A1FD-3C98445127DB@freebsd.org> <20110724222224.GA64487@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <trasz@freebsd.org> 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?




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A2C6B016-9DF3-42C5-BCCF-1661201770CE>