News for hackers. Stuff that matters.
Re:A Simple Hash for Perlin Noise by vlmutolo on Tuesday May 10, 2022 @10:32PM (#31335212)
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-comparis...

Re:A Simple Hash for Perlin Noise by ot on Tuesday May 10, 2022 @11:01PM (#31335400)
For integer-size keys, a simple integer mixer will perform better than anything.
Re:A Simple Hash for Perlin Noise by johndough on Wednesday May 11, 2022 @12:56AM (#31335977)
What is an integer mixer?
Re:A Simple Hash for Perlin Noise by ot on Wednesday May 11, 2022 @01:23AM (#31336106)
A 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

When the input is an integer, they're very good hash functions on their own.