Description
It's crucial that our secure hash maps are as fast as we possibly can make them, and there's more we can do yet. This is worth dropping down to assembly or even C for.
The best candidate is https://github.com/google/highwayhash. Unfortunately, it is apache2 only. We would need to get them to dual-license, but let's not bug them until we're sure we have a patch that's acceptable on our end.
This implementation requires AVX2, which we can not count on any of our shipping targets to support. But it seems relatively simple to me to do cpu feature detection dynamically in some strategic place, then drop to the fast version.
So the steps here:
- Out of tree, create a SipHash13/24 implementation in Rust, backed by the highwaysh implementation
- Benchmark it to prove its fast enough to be worth the effort
- Add the highwayhash siphash implementation to src/rt, and add it to the build system(s)
- Add the optimized SipHash13/24 implementation to std, alongside the existing
- Create another SipHash13/24 definition that delegates to one of the others. During construction detect AVX2 and set a flag. Dispatch based on flag.
An obvious concern is the overhead of that flag, and of the FFI crossing.
cc @alexcrichton what you think?
cc @briansmith