3 ms·
XxHash has some great benchmarks for various hash functions. FNV is still competitive for small inputs. Most hash functions are built to have high throughput fo
by vlmutolo 4y ago
XxHash has some great benchmarks for various hash functions. FNV is still competitive for small inputs. Most hash functions are built to have high throughput for hashing hundreds of bytes or more. XxHash in particular has an explicit mode switch from "small data" to "big data" sizes around a couple hundred bytes (it varies by platform and compiler).
It's hard to do both small and big data correctly, and FNV is one of the few that optimizes for small data.
For moderately small data, larger than around 4 bytes, xxh3 beats it handily. But for extremely small sizes, FNV is still the winner.
Honestly people should probably just try to switch to xxh3 if performance is a concern, but FNV is certainly competitive for integer-size keys.
https://github.com/Cyan4973/xxHash/wiki/Performance-comparison#benchmarks-concentrating-on-small-data- https://github.com/Cyan4973/xxHash/wiki/Performance-comparis...
- ot 4y agoFor integer-size keys, a simple integer mixer will perform better than anything.
- johndough 4y agoWhat is an integer mixer?
- ot 4y agoA function that mixes the bits of an integer, it's a major component in all modern hash functions (they read a few bytes from the input, add them to the state, mix the state, and continue). See for example http://jonkagstrom.com/bit-mixer-construction/index.html http://jonkagstrom.com/bit-mixer-construction/index.html When the input is an integer, they're very good hash functions on their own.