Article View: comp.sources.bugs
Article #2336Speeding up top in a large YP environment
From: George M. Jones
Date: Tue, 13 Feb 1990 21:08
Date: Tue, 13 Feb 1990 21:08
36 lines
1589 bytes
1589 bytes
The following are the diffs to a change that I made to top.c that had
the effect of changing the startup time from 45-90 seconds to 6.
The problem was that top was using getpwent(3) to spin through most or
all of the 2000+ entries in our YP passsword file rather than simply
reading those entries that are needed via a call to getpwuid(3).
Enjoy. You millage may vary.
---George Jones
OSU Computer & Inf. Science 2036 Neil Ave.,Columbus,Ohio 43210. 614-292-7325
george@cis.ohio-state.edu or ...!osu-cis!george
X windows. You'd better sit down.
-----------------------------top.c.diff-----------------------------
138c138
< struct passwd *getpwuid();
---
> struct passwd *getpwent();
1174,1180c1174,1182
< if ((pwd = getpwuid(uid)) == NULL)
< {
< fprintf(stderr, "getpwuid(%d) failed\n", uid);
< quit(11);
< }
<
< return(enter_user(pwd->pw_uid, pwd->pw_name));
---
> while ((pwd = getpwent()) != NULL)
> {
> last_index = enter_user(pwd->pw_uid, pwd->pw_name);
> if (pwd->pw_uid == uid)
> {
> return(last_index);
> }
> }
> return(enter_user(uid, itoa7(uid)));
Technical Details
Message-ID:
<9002132108.AA02791@jones.cis.ohio-state.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!CIS.OHIO-STATE.EDU!georgeShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!CIS.OHIO-STATE.EDU!george From: george@CIS.OHIO-STATE.EDU (George M. Jones) Newsgroups: comp.sources.bugs Subject: Speeding up top in a large YP environment Message-ID: <9002132108.AA02791@jones.cis.ohio-state.edu> Date: 13 Feb 90 21:08:45 GMT Sender: george@tut.cis.ohio-state.edu Reply-To: george@cis.ohio-state.edu Lines: 36