Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.c

As you can see no rocket science there.



Really 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-b...)


Good advice, thanks, taking note


Reading this code made my day, thank you.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: