Since we store each entry 3 times the estimate of the number of
elements needs to be 3x the number of entries.

Also set the bucket size to be the optimal file system block size
instead of hard-coding to 4096.

 - todd

Index: usr.sbin/pwd_mkdb/pwd_mkdb.c
===================================================================
RCS file: /cvs/src/usr.sbin/pwd_mkdb/pwd_mkdb.c,v
retrieving revision 1.53
diff -u -p -u -r1.53 pwd_mkdb.c
--- usr.sbin/pwd_mkdb/pwd_mkdb.c        5 Nov 2015 15:10:11 -0000       1.53
+++ usr.sbin/pwd_mkdb/pwd_mkdb.c        17 Sep 2018 16:39:31 -0000
@@ -188,8 +188,13 @@ main(int argc, char **argv)
        /* Tweak openinfo values for large passwd files. */
        if (st.st_size > (off_t)100*1024)
                openinfo.cachesize = MINIMUM(st.st_size * 20, 
(off_t)12*1024*1024);
-       if (st.st_size / 128 > openinfo.nelem)
-               openinfo.nelem = st.st_size / 128;
+       /* Estimate number of elements based on a 128-byte average entry. */
+       if (st.st_size / 128 * 3 > openinfo.nelem)
+               openinfo.nelem = st.st_size / 128 * 3;
+
+       /* Use optimal filesystem block size. */
+       if (st.st_blksize > openinfo.bsize)
+               openinfo.bsize = st.st_blksize;
 
        /* If only updating a single record, stash the old uid */
        if (username) {

Reply via email to