New FreeBSD 5.3 e-mail server extremely slow - traced to
getpwnam maybe ?
Bruce Campbell
bruce at engmail.uwaterloo.ca
Wed Jan 5 05:47:48 PST 2005
Quoting Kris Kennaway <kris at obsecurity.org>:
> On Tue, Jan 04, 2005 at 09:27:27PM -0500, Bruce Campbell wrote:
>
> > I wrote a small program:
> >
> > #include <sys/types.h>
> > #include <pwd.h>
> >
> > main( int argc, char *argv[] )
> > {
> > getpwuid( 13076 );
> > }
> >
> > and ran it under truss on 5.x and it generated 178,711 lines of output.
> > (the bulk of which is those lseek/read calls as above)
> > ...
>
> Try tuning the pwd_mkdb parameters (see hash(3)) in
> /usr/src/usr.sbin/pwd_mkdb/pwd_mkdb.c and recompile:
>
> HASHINFO openinfo = {
> 4096, /* bsize */
> 32, /* ffactor */
> 256, /* nelem */
> 2048 * 1024, /* cachesize */
> NULL, /* hash() */
> 0 /* lorder */
> };
>
> e.g. adjust nelem to 12000 to accomodate your
> significantly-larger-than-average password database. If this helps,
> please submit a PR requesting that someone make an option to pwd_mkdb
> to tune this at runtime (or better yet, submit the patch to do this
> yourself - it's straightforward to modify the source to do this).
Thanks. That had no effect on the large number of seeks/reads
to do a getpwuid of a specific uid. I tried boosting that
number further, still no change. I suspect the problem is related
to some change to the hash functions between 4.7 and 5.2.1 and I
hope to get to the bottom of it today.
I tried two getpwnam (as opposed to getpwuid) calls on 2 different userids, one
took 1000 seek/reads, the other 16,000, so it's all
pretty random, no doubt related to how stuff gets hashed. On
4.7 it takes just one or two reads/seeks.
As each login via ipop, imap, and each sendmail, and just about everything
will be doing getpwnam's I think this is our problem.
--
Bruce Campbell
Engineering Computing
CPH-2374B
University of Waterloo
(519)888-4567 ext 5889
----------------------------------------
This mail sent through www.mywaterloo.ca
More information about the freebsd-questions
mailing list