bin/89762: [patch] top(1) startup is very slow on system with many users

Giorgos Keramidas keramida at freebsd.org
Fri May 4 15:17:44 UTC 2007


On 2007-05-04 14:50, Gavin Atkinson <gavin.atkinson at ury.york.ac.uk> wrote:
> This is still a problem with 6.2-STABLE.  On a 2.2GHz amd64 machine
> with ~20,000 NIS users, "top -b" takes 74 seconds before displaying
> any output and generates significant load on the NIS servers.
> 
> wiggum# time top -b
> last pid: 1742; load averages: 0.00, 0.00, 0.00 up 36+03:20:25  15:39:47
> 32 processes:  1 running, 31 sleeping
> 
> Mem: 82M Active, 191M Inact, 108M Wired, 213M Buf, 1498M Free
> Swap: 3072M Total, 3072M Free
> [process list snipped]

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.

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).

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).



More information about the freebsd-bugs mailing list