Subject: Performance problems with many "guestgroup" and "upload" statements

From: Alexey Lef <[email-masked]>
Date: Thu, 12 Jun 1997 17:25:18 +22324502

We are running wu-ftpd beta 13 on a fairly fast machine which has 1200+ users 
in /etc/passwd, 160 groups in /etc/group, 90 "guestgroup" and 100+ "upload" 
statements in ftpaccess file.

Ftp login times on that machine were between 1 and 2 minutes (!) even with 
hardly 20 users connected. During peak hours "uptime" was showing 40+ load 
average, sometimes going upto 170 (no, this is not a typo).

While looking through the source code, I found that acl_guestgroup() and 
expand_id() had getgrnam() and getpwnam() inside a loop. This means that in 
our case expand_id() calls getpwnam() and getgrnam() 100 times. Both 
getgrnam() and getpwnam() are very expensive calls, especially when /etc/group 
and /etc/passwd are big.

I changed acl_guestgroup() to use getuserattr() which returns the list of 
groups an id belongs to (looks like this function is AIX-specific, so I put 
"#ifdef AIX" around it). It improved performance, but only slightly.

Then I changed expand_id() code to store pointers to "upload" aclmember 
structures in a hash table and then go through /etc/passwd and /etc/group only 
once using getpwent() and getgrent(). The results were amazing. Login times 
went from 2 minutes to under 3 seconds even during peak hours, and load 
average never goes above 1.

If anyone is interested in the code,  ftp://ftp.raleigh.ibm.com/igs/wu-ftpd.big
passwd.tar.gz contains the following files:

  access.c
  extensions.h
  extensions.c
  hash.c       (this is an additional file implementing hash functions)
  Makefile     (had to add hash.c to SRCS and hash.o to OBJS
  README
  
The changes are marked with "[email-masked]".

Of course if you deem these changes worth being incorporated into official 
distribution, I will be delighted to remove these files from our ftp server :-)

I am yet to figure out why setpriv() is used in place of seteuid() and why 
process titles show up twice in "ps -ef" output.

Alexey Lef
UNIX Sysadmin, IBM Global Services