From owner-freebsd-current Fri Sep 7 7:34:16 2001 Delivered-To: freebsd-current@freebsd.org Received: from melchior.cuivre.fr.eu.org (melchior.enst.fr [137.194.161.6]) by hub.freebsd.org (Postfix) with ESMTP id EBD1E37B407 for ; Fri, 7 Sep 2001 07:34:12 -0700 (PDT) Received: from melusine.cuivre.fr.eu.org (melusine.enst.fr [137.194.160.34]) by melchior.cuivre.fr.eu.org (Postfix) with ESMTP id D77177B33 for ; Fri, 7 Sep 2001 16:34:07 +0200 (CEST) Received: by melusine.cuivre.fr.eu.org (Postfix, from userid 1000) id E517724D45; Fri, 7 Sep 2001 16:34:06 +0200 (CEST) Date: Fri, 7 Sep 2001 16:34:06 +0200 From: Thomas Quinot To: current@freebsd.org Subject: top(1) takes ages to start up Message-ID: <20010907163406.A18904@melusine.cuivre.fr.eu.org> Reply-To: thomas@cuivre.fr.eu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG ... because it walks through the entire NIS db just to find out what the longest user name is (/src/usr.bin/top/machine.c 1.5). At this site, this means 2800 RPC calls and dozens of seconds when the network and/or NIS server are busy. What do others think of the following patch? Thomas. --- machine.c.dist Fri Jun 1 00:36:51 2001 +++ machine.c Fri Sep 7 16:31:45 2001 @@ -212,7 +212,7 @@ sysctlbyname("kern.smp.active", &smpmode, &modelen, NULL, 0) < 0) || modelen != sizeof(smpmode)) smpmode = 0; - +#ifndef NO_GETPWENT while ((pw = getpwent()) != NULL) { if (strlen(pw->pw_name) > namelength) namelength = strlen(pw->pw_name); @@ -223,6 +223,9 @@ namelength = 13; else if (namelength > 15) namelength = 15; +#else + namelength = 8; +#endif if ((kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open")) == NULL) return -1; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message