-
Notifications
You must be signed in to change notification settings - Fork 18k
hash/maphash: purego implementation is not updated #69940
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
Comments
CC @randall77 |
I don't think the intent of these two hashes is that they match exactly. Differences are ok. Having said that, though, we should probably mirror any changes that were added for collision resistance. I'll mark this for 1.24. |
Change https://go.dev/cl/621756 mentions this issue: |
For the point 3, maybe should we check if there is any performance improvement by backporting the current |
What do you mean by "backporting the current
|
I mean, if you check the two implementations, the multiple cases in the switch that were present in runtime, in the maphash are grouped in a single one with bitwise operations, was there a purpose behind this? |
Like @randall77 said above, the runtime implementation maybe different, since these two hashes are not intended to be matched exactly. The implementation in maphash_purego follows this wyhash_final4: https://github.com/wangyi-fudan/wyhash/blob/master/old_versions/wyhash_final4.h#L118 |
According to lines 33 & 34 of
hash/maphash/maphash_purego.go
:However, when I look to the effective code inside this file, the implementation looks very different from the one in
runtime/hash64.go
, and I think it should be changed to match it accordingly.Among the differences:
runtime/hash64.go
, the variable hashkey is used often, but it's totally absent from themaphash_purego.go
implementation. This is a [4]uint64 array that contains random values, generated during the package initialization insideruntime/alg.go
. I think aninit()
function should be added to themaphash_purego.go
file to generate random uint64 in a private global variable, similar to the hashkey one.hashmap_purego.go
implementation.hash64.go
, the code structure looks very different. For example: the default case of the hash64 implementation, in this implementation is written before the whole switch, and a lot of cases are grouped under a new default case. Maybe these differences are correct, but there is no documentation to explain them, and I don't understand why they are not directly part ofruntime/hash64.go
too if the code does the same thing? Maybe they are less performant? Someone has any hint about this one?The text was updated successfully, but these errors were encountered: