New Bare Hash Map: 2X-3X Speedup over SOTA
github.com
github.com
It’s not clear to me that that probability of collision assumptions hold. It’s basically assuming that the hashing is perfect and distributes any inputs to the full 64-bit space with uniform probability. That’s the usual hash map / randomized algorithm hope, but does BigCrush or similar avalanche testing really prove that? (Presumably not, otherwise there wouldn’t be image attacks for things like md5).
[1] https://github.com/wangyi-fudan/wyhash/blob/d2a305811972f391...
Big crush and smhasher give a good indication of uniform distribution, but nothing can guarantee no collisions because you're always going to have collisions it's always a possibility. Even if you have a perfect permutation of the 64 bit space, the minute you go beyond 64 bits of keys you're going to collide within 64 bits of hash.
By all the tests they run md5 is a much poorer hash than many others. But it's a or it was a cryptographic hash. It's different.
Even without relying on the pigeonhole principle though you still have the birthday paradox. As a ballpark estimate, if you have N keys then you'd expect a 50/50 chance of at least one collision with sqrt(N) hashes -- 2^32 for this problem.
64 bit is not good enough for that claim. 128 would be good, 256 perfect for production use. Regardless of the hash function quality. wyhash is a very good hash, the best and fastest portable one.
I think that's fine if you actually use a really good hash (e.g. a 128-bit cryptographic PRF). But I wouldn't be comfortable with hashes shorter than that or which aren't crypto quality.
People already make such assumptions when assuming uniqueness v4 UUIDs.
You can get this guarantee by using a random hash function if you don't support insertion and are fine with using a relatively larger amounts of memory.
The API this presents is not really inspiring either.
And there are a bunch of other good suggestions here in the comments looking at around the same 50-60gb/sec speed
[1] https://github.com/injinj/smhasher/
[2] Section 5.4 of Introduction to Cryptography by Trappe and Washington -- It can be shown that two rounds are sufficient to obtain full diffusion, namely, each of the 128 output bits depends on each of the 128 input bits.
[3] https://github.com/raitechnology/raikv/blob/3ce2b23e0d9853fe...
https://github.com/tkaitchuck/aHash/blob/master/compare/read...
Did anything change?
https://github.com/tkaitchuck/aHash/tree/master/smhasher
There are also ahash's own benchmarks here:
https://github.com/tkaitchuck/aHash/blob/master/compare/test...
They use the wyhash Rust crate, so if wyhash itself was updated doing a head to head comparison would boil down to updating the wyhash crate and rerunning ahash's benchmark suite.
1kb string:
- ahash: 23.0ns
- wyhash (rust crate): 54.2ns
- wyhash (new): 34.8ns
u64:
- ahash: 0.69ns
- wyhash (rust crate): 1.6ns
- wyhash (new): 0.97ns
So the new version is faster, but it looks like ahash is still state-of-the-art when it comes to speed.Very interesting is his claim to create wyhash collisions at will. Even with bad keys, not bad seeds!
It may be the fastest rust hash, but certainly not faster than other fast hashes. More like 2x slower.
xxh3, t1ha0, wyhash are all much faster on the 2 machines I tested it on, an old 7 years old Intel i5-2300, and a new Ryzen 3200U.
If it's so much slower then most likely something is wrong.
1) Did you enable the AES instruction when compiling? (IIRC it's disabled by default) 2) When compiling the benchmark did you have cross-language inlining enabled? (IIRC you need to compile your C++ code with a specific version of Clang to get it to inline between Rust and C++)
A what now? https://github.com/wangyi-fudan/wyhash/blob/master/wyhash.h#...
extra protection against entropy loss
A little brogramming and some google translate and here we are.