Suggestion: use rapidhash for KeyHasher #651
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Disclosure: I am the author of rapidhash.
Hey! This PR is a suggestion to replace the use of ahash with rapidhash. Rapidhash has been used in production workloads for the last year and outperforms ahash on almost all inputs and platforms.
This makes a significant improvement on the following benchmarks:
The improvements were benchmarked on an M1 Max with and without
-C target-cpu=native. The rapidhash detailed benchmarks suggest rapidhash outperforms the ahash primary (with AES instructions) and fallback (without AES instructions) algorithms on almost all inputs on almost all platforms (1kB+ strings on x86 with AES enabled being a notable exception). I'm happy to talk through the benchmarks in more detail if that's helpful.Note that metrics is currently not randomly seeding the KeyHasher, and so the hashes are not DoS resistant. Let me know if this is a concern and I can adjust the PR?
The rapidhash MSRV is 1.71.0, which should match the current metrics MSRV too.
Let me know if you have further questions about rapidhash, or would like me to assist in further benchmarking? Cheers!