Increase 64-bit rotation from 20 to 26 bits on finalizer #56
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.
The current finalizer consisting of a right-rotation of 20 bits can create fairly catastrophic results if the bottom input bits are low-entropy and the hash table grows beyond 2^20 elements, see rust-lang/rust#135477 (comment).
In this PR I bumped the number of bits to 26 from 20 in order to allow for bigger hash tables. This is a palliative solution because it increases the chance of collisions from what I can gather. The proper solution that would render the whole rotention irrelevant would be to fix the hashbrown implementation in a way I could not describe here but @orlp and @Noratrieb definitely could if you ask them haha.
Further, I changed the tests in an ad-hoc manner because I couldn't do it otherwise, so if it makes sense to do it in another way please let me know.
Also, I changed the version number to 2.1.1 because the only change was a private constant that should not implicate anything anywhere, but of course if 2.2.0 makes more sense I'll change it right away.
If any other change is required, please let me know!