New FreeBSD 5.3 e-mail server extremely slow - traced to getpwnam maybe ?

Kris Kennaway kris at obsecurity.org
Tue Jan 4 20:53:06 PST 2005


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)
> 
> 4.7 (with same master.passwd file) gave 59 lines of output, which seems
> normal.
> 
> I'm speculating that imap and sendmail and just about everything use
> getpwuid and getpwuid is misbehaving on 5.x especially with a large
> master.passwd file.

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).

Kris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20050104/ae222fed/attachment.bin


More information about the freebsd-questions mailing list