From owner-freebsd-bugs@FreeBSD.ORG Fri May 4 15:46:05 2007 Return-Path: X-Original-To: freebsd-bugs@freebsd.org Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A675316A406; Fri, 4 May 2007 15:46:05 +0000 (UTC) (envelope-from gavin.atkinson@ury.york.ac.uk) Received: from mail-gw4.york.ac.uk (mail-gw4.york.ac.uk [144.32.128.249]) by mx1.freebsd.org (Postfix) with ESMTP id 404C613C4DA; Fri, 4 May 2007 15:46:05 +0000 (UTC) (envelope-from gavin.atkinson@ury.york.ac.uk) Received: from buffy.york.ac.uk (buffy-128.york.ac.uk [144.32.128.160]) by mail-gw4.york.ac.uk (8.13.6/8.13.6) with ESMTP id l44FFjup005099; Fri, 4 May 2007 16:15:45 +0100 (BST) Received: from buffy.york.ac.uk (localhost [127.0.0.1]) by buffy.york.ac.uk (8.13.8/8.13.6) with ESMTP id l44FFjRU062669; Fri, 4 May 2007 16:15:45 +0100 (BST) (envelope-from gavin.atkinson@ury.york.ac.uk) Received: (from ga9@localhost) by buffy.york.ac.uk (8.13.8/8.13.6/Submit) id l44FFj6N062668; Fri, 4 May 2007 16:15:45 +0100 (BST) (envelope-from gavin.atkinson@ury.york.ac.uk) X-Authentication-Warning: buffy.york.ac.uk: ga9 set sender to gavin.atkinson@ury.york.ac.uk using -f From: Gavin Atkinson To: Giorgos Keramidas In-Reply-To: <20070504150339.GA22517@kobe.laptop> References: <200705041450.l44EoAJC003185@freefall.freebsd.org> <20070504150339.GA22517@kobe.laptop> Content-Type: text/plain Content-Transfer-Encoding: 7bit Date: Fri, 04 May 2007 16:15:45 +0100 Message-Id: <1178291745.61333.29.camel@buffy.york.ac.uk> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 FreeBSD GNOME Team Port X-York-MailScanner: Found to be clean X-York-MailScanner-From: gavin.atkinson@ury.york.ac.uk Cc: freebsd-bugs@freebsd.org Subject: Re: bin/89762: [patch] top(1) startup is very slow on system with many users X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2007 15:46:05 -0000 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