I was trying to understand the redis dictionary implementation and after reading this article I tried to experiment a little bit with the code and see how things change. I run various YCSB benchmark's to see the performance of redis. I always load 15 million records into redis with ycsb and then benchmark read and write performance.
Changing line 109 of dict.h to a bigger value:
#define DICT_HT_INITIAL_EXP 24 // INITIAL SIZE = 16777216
should initialize a hash table of size 16777216.
Given that,
1.redis should never rehash and 2. the performance should not be affected in a negative way(drop) since the initial size of the dictionary is big enough. I am adding 15 million records into 16m buckets, so every key should go into empty bucket and each list should consist of 1 element.
Rehashing never happens as expected but for my surprise the performance while running the same benchmarks as previously lead to drop compared to
#define DICT_HT_INITIAL_EXP 2 // INITIAL SIZE = 2
Is it something I did not understood correctly?
Comment From: sundb
@efntallaris DICT_HT_INITIAL_EXP is not the initial size of the dictionary slot, it is a bit offset, when it is 2 means the size of slot is (1<<2), so 1<< 16777216 would be 0.
Comment From: efntallaris
@sundb DICT_HT_INITIAL_EXP is the exponent in order to make the initial size a power of 2 In the code i have #define DICT_HT_INITIAL_EXP 24 which leads to dictonary size of 16777216 correct?
Comment From: sundb
@efntallaris Yes.