IMPROVE: increased redistribute bucket count.
@@ -136,6 +136,11 @@ static void redistribute(void)
hash_item *it;
uint32_t tabidx;
+ /* How many buckets should redistribute at a time?
+ * If it is too few, it will longer hashtable expansion and decrease average throughput.
+ * If it is too many, it will shorten hashtable expansion but it can result a throughput drop.
+ */
+ for (uint32_t rdbcnt = 0; rdbcnt < 4; rdbcnt++) {
prev = &assocp->roottable[assocp->exp_tabidx].hashtable[assocp->exp_bucket];
while ((it = *prev) != NULL) {
tabidx = (it->khash >> assocp->hashpower) & assocp->rootmask;
@@ -148,8 +153,10 @@ static void redistribute(void)
assocp->roottable[tabidx].hashtable[assocp->exp_bucket] = it;
}
}
-
assocp->exp_tabidx += 1;
+ if (assocp->exp_tabidx >= assocp->prevsize) break;
+ }
+
if (assocp->exp_tabidx >= assocp->prevsize) {
assocp->exp_tabidx = 0;
/* set the next bucket in backward */
