29 ms·
Redis has an implementation of incrementally rehashing hash table in "dict.c" file. Very simple to understand code. https://github.com/antirez/redis/blob/unsta
by antirez 14y ago
Redis has an implementation of incrementally rehashing hash table in "dict.c" file. Very simple to understand code.
https://github.com/antirez/redis/blob/unstable/src/dict.h https://github.com/antirez/redis/blob/unstable/src/dict.h
https://github.com/antirez/redis/blob/unstable/src/dict.c https://github.com/antirez/redis/blob/unstable/src/dict.c
As you can see no rocket science there.
- cjh_ 14y agoReading this code made my day, thank you.
- matthavener 14y agoReally great C code. However, "timeInMilliseconds" should really use clock_gettime(CLOCK_MONOTIC, ..) instead of gettim eofday(..). A sudden change in time due to NTP, administrator, timezone, etc, could have the loop in "dictRehashMilliseconds" running for longer than expected. (Here's someone explaining the problem with gettimeofday http://blog.habets.pp.se/2010/09/gettimeofday-should-never-be-used-to-measure-time http://blog.habets.pp.se/2010/09/gettimeofday-should-never-b...)
- antirez 14y agoGood advice, thanks, taking note