From 14962ce3e69e452a2447c12cde3369759365fda9 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Wed, 28 Oct 2009 04:46:25 +0000 Subject: performance/io-cache: change the hash function used for rbtree based hash table. - the earlier hash function does not distribute pages uniformly for offsets that fit into 32 bits. The reason is that the hash function just xors the contents of the key 4 bytes at a time with the current value of hash. Hence for keys that fit into 32 bits, the hash will be the key itself. Since we are using the rounded_offset (which is a multiple of 128KB) as the key, the key will be exactly divisible by the number of buckets configured (4096) resolving all the pages into the first bucket. Signed-off-by: Anand V. Avati BUG: 335 (Io-cache optimization) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=335 --- libglusterfs/src/common-utils.c | 15 +++++++++++++++ libglusterfs/src/common-utils.h | 1 + 2 files changed, 16 insertions(+) (limited to 'libglusterfs/src') diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index de0cb774b74..3f52a90a010 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -56,6 +56,21 @@ struct dnscache6 { struct addrinfo *next; }; + +int +gf_log2 (unsigned long x) +{ + int val = 0; + + while (x != 1) { + x /= 2; + val++; + } + + return val; +} + + int32_t gf_resolve_ip6 (const char *hostname, uint16_t port, diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index c5869f4a424..48788d29545 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -330,6 +330,7 @@ int gf_lockfd (int fd); int gf_unlockfd (int fd); int get_checksum_for_file (int fd, uint32_t *checksum); +int gf_log2 (unsigned long x); #endif /* _COMMON_UTILS_H */ -- cgit