From 3390d4701e9fec1df68bbfff42cca215b4bfee05 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 6 Jul 2011 00:44:43 -0400 Subject: [PATCH] rculfhash: use threshold and target Accept to target bucket len greater than 1 to diminish the memory consumption without too much performance impact. Signed-off-by: Mathieu Desnoyers --- rculfhash.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rculfhash.c b/rculfhash.c index 497a9ea..450b286 100644 --- a/rculfhash.c +++ b/rculfhash.c @@ -46,7 +46,8 @@ #define dbg_printf(args...) #endif -#define BUCKET_SIZE_RESIZE_THRESHOLD 4 +#define CHAIN_LEN_TARGET 4 +#define CHAIN_LEN_RESIZE_THRESHOLD 16 #ifndef max #define max(a, b) ((a) > (b) ? (a) : (b)) @@ -165,8 +166,9 @@ static void check_resize(struct rcu_ht *ht, struct rcu_table *t, uint32_t chain_len) { - if (chain_len >= BUCKET_SIZE_RESIZE_THRESHOLD) - ht_resize_lazy(ht, t, log2_u32(chain_len)); + if (chain_len >= CHAIN_LEN_RESIZE_THRESHOLD) + ht_resize_lazy(ht, t, + log2_u32(chain_len - CHAIN_LEN_TARGET)); } static -- 2.34.1