-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.help wanted
Milestone
Description
According to lines 33 & 34 of hash/maphash/maphash_purego.go
:
// This is a port of wyhash implementation in runtime/hash64.go,
// without using unsafe for purego.
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:
- In the
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. - On April 2024 (6 months ago), hash64.go implementation has been updated, in commits ef2f339 and 35c6193, now the global hashkey variable is used even more (should we add an equivalent in maphash too? Related to point 1) and 4 out of 5 constants have been removed, these changes are currently missing from the
hashmap_purego.go
implementation. - Although the comments says the the code afterward is just a porting from
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?
mengzhuo and apocelipes
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.help wanted