You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Notably, BenchmarkMaphashString has one allocation per op.
What did you expect to see?
I expected to see zero allocations per iteration in any of these benchmarks because the result of hashing a string is independent of that string's address. I discussed this issue at length in #54670 (comment) (possibly at too much length!). While the current implementation deals with the issue of stack pointers by unconditionally escaping them, it doesn't currently handle the more subtle case of strings, as demonstrated by this benchmark.
Change https://go.dev/cl/632715 mentions this issue: hash/maphash, cmd/compile: make Comparable[string] not escape its argument
dmitshur
added
NeedsFix
The path to resolution is known, but the work has not been done.
and removed
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
labels
Dec 2, 2024
Discussed with @dmitshur , polishing a new feature (to make it more conformant to the proposal) is within the scope of the freeze. So we can target 1.24 for this.
Go version
go version devel go1.24-fb5fa2a839 Mon Nov 25 18:39:27 2024 +0000 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I ran the following using
go test -bench . comparable_test.go
: https://play.golang.org/p/jv23SKNWLy6What did you see happen?
I saw the following results:
Notably, BenchmarkMaphashString has one allocation per op.
What did you expect to see?
I expected to see zero allocations per iteration in any of these benchmarks because the result of hashing a string is independent of that string's address. I discussed this issue at length in #54670 (comment) (possibly at too much length!). While the current implementation deals with the issue of stack pointers by unconditionally escaping them, it doesn't currently handle the more subtle case of strings, as demonstrated by this benchmark.
cc @randall77 @golang/compiler
The text was updated successfully, but these errors were encountered: