Hashing 4-byte keys fast
- Hash functions not specialised to 4-byte data take at least 10 nanoseconds—way too long!
- The
crc32
instruction from SSE4.2 (2008) is as fast as a multiply
- Other platforms support similar instructions
- With a power-of-two hash table size, turning a hash into an index is just bitwise and (
∧
) with a mask
- This might weaken the hash slightly, but there are good fallbacks and we haven't seen problems yet
- When a CRC isn't available, we use a more complicated function based on shifts, xors, and multiplies (the Murmur3 mixing function)