Date: Fri, 04 May 2007 16:15:45 +0100 From: Gavin Atkinson <gavin.atkinson@ury.york.ac.uk> To: Giorgos Keramidas <keramida@freebsd.org> Cc: freebsd-bugs@freebsd.org Subject: Re: bin/89762: [patch] top(1) startup is very slow on system with many users Message-ID: <1178291745.61333.29.camel@buffy.york.ac.uk> In-Reply-To: <20070504150339.GA22517@kobe.laptop> References: <200705041450.l44EoAJC003185@freefall.freebsd.org> <20070504150339.GA22517@kobe.laptop>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 2007-05-04 at 18:03 +0300, Giorgos Keramidas wrote:
> Can you truss/ptrace top at the time? I think it's trying to find the
> longest username string, to align the USERNAME column, and it queries
> the NIS server for *all* users.
This is exactly what it's doing - the code in question i around line 240
of machine.c:
while ((pw = getpwent()) != NULL) {
if (strlen(pw->pw_name) > namelength)
namelength = strlen(pw->pw_name);
}
Obviously, this also generates significant network traffic. All of my
machines have this #if 0'd out and replaced with "namelength = 8"
I've just noticed another duplicate, PR bin/98693, also uses the same
hack.
> If that is the case, you should see a significant speedup when top runs
> with the -u option (but lose the functionality of seeing the username).
This code seems to still be run with the -u option.
> We could probably 'trim' long usernames in the USERNAME column and add
> a character like '>' shown below:
>
> ------------------------------------------------------------------------
> PID USERNAME THR PRI NICE SIZE RES STATE C TIME CPU COMMAND
> 4783 giorgosker> 1 96 0 294M 38244K CPU0 0 57:07 1.22% Xorg
> 22634 giorgosker> 1 96 0 11452K 9868K select 1 0:05 0.93% emacs
> 19084 giorgosker> 1 96 0 7256K 4176K select 0 2:49 0.88% xterm
> 960 root 1 96 0 3160K 864K select 0 12:51 0.00% powerd
> ------------------------------------------------------------------------
>
> and keep a fixed length for the USERNAME column, but I am not sure if
> this would be an acceptablle UI change for top(1).
This may be sensible. I don't think it's realistic to waste MAXNAMELEN
columns on everyone's display, but the current code really hurts any
setup with lots of users or slow NIS/LDAP servers.
Gavin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1178291745.61333.29.camel>
