Reduce the size of the FpHashes by factor 4.
authorFlorian Festi <ffesti@redhat.com>
Thu, 18 Dec 2008 08:41:12 +0000 (09:41 +0100)
committerFlorian Festi <ffesti@redhat.com>
Thu, 18 Dec 2008 15:22:13 +0000 (16:22 +0100)
It turns out that large hashes leave a lot of buckets
empty without really reducing the maximum of collisions
a lot. Tests show that the collision lists are only 2.3
items on average and the maximum is only about 1.5 worse
than with a big hash table (~12 for large hashes).

lib/transaction.c

index dde7adc..d633262 100644 (file)
@@ -1128,7 +1128,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
        (void) rpmtsSetChrootDone(ts, 1);
     }
 
-    ts->ht = rpmFpHashCreate(totalFileCount * 2 + 1, fpHashFunction, fpEqual,
+    ts->ht = rpmFpHashCreate(totalFileCount/2+1, fpHashFunction, fpEqual,
                             NULL, NULL);
     fpc = fpCacheCreate(totalFileCount + 10001);
 
@@ -1165,7 +1165,7 @@ int rpmtsRun(rpmts ts, rpmps okProbs, rpmprobFilterFlags ignoreSet)
     /* ===============================================
      * Check fingerprints if they contain symlinks
      */
-    rpmFpHash newht = rpmFpHashCreate(totalFileCount * 2, fpHashFunction, fpEqual, NULL, NULL);
+    rpmFpHash newht = rpmFpHashCreate(totalFileCount/2+1, fpHashFunction, fpEqual, NULL, NULL);
 
     pi = rpmtsiInit(ts);
     while ((p = rpmtsiNext(pi, 0)) != NULL) {