Get the latest tech news
ChibiHash: Small, Fast 64 bit hash function
If you need a small and fast 64 bit hash function that can be copy-pasted easily, then here's one that I cooked up in an hour or so: chibihash64.h. Some key features: Here's some benchmark against other similar hash functions: It's the fastest of the bunch for large string throughput.
Small: ~60 loc in C Fast: See benchmark table below Portable: Doesn't use hardware specific instructions (e.g SSE) Good Quality: Passes smhasher, so should be good quality (I think) Unencumbered: Released into the public domain Free of undefined behavior and gives same result regardless of host system's endianness. It's also fast, gcc and clang recognize this pattern and optimize it into a single mov instruction on x86 targets. I started writing this because all the 64 bit hash functions I came across were either too slow (FNV-1a, one byte at a time processing), or too large spanning hundreds of lines of code, or non-portable due to using hardware specific instructions.
Or read this on Hacker News