-
Notifications
You must be signed in to change notification settings - Fork 42
Integer hashing functions that compile to optimal assembly #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Actually, this needs some more preprocessor logic per |
5cd114c to
4150b43
Compare
|
While I don't think this is an inelegant solution, I am a bit leery of relying on the optimizer to consolidate two byteswaps down to a no-op. I'm putting together an alternative take at this that uses a new EDIT: I made a pull request with my alternative approach, linked just below. Although I feel a bit silly "solving a solved problem", dissecting how rapidhash works on these small inputs was a fun exercise. |
|
@hoxxep This PR is not bad. Concerns are:
|
|
In response to 1,2,3:
I have no skin in the game here though, totally understand if it's not deemed necessary. |
4150b43 to
c2a86d0
Compare
c2a86d0 to
9d742d7
Compare
This is unsuitable for many use cases, with and without hashmaps. A concrete example... in procedural generation we often use multi-dimensional coordinate packed into an integer, which may differ by just a single bit between cells. This makes the avalanche effect highly desirable: hashes of contiguous coordinates are used as a pseudorandom noise function. These coordinates will often differ from their neighbors by power-of-two increments, which will produce many collisions in an identity hashmap. |
@Nicoshev totally up to you whether you want to include these or not. I'm also happy to adjust docs or rename things per your preference. I wrote them for the godbolt example, so figured it's worth at least having a PR to refer back to if someone needs it in future.
I assume we'll leave it up to the end user to write their own integer-tuple hash functions, as they should simply be using
rapidhash_to_le_*and building a byte array to then be hashed with a constant length.