internal/runtime/maps: hash small keys with wyhash instead of AES - #80895
internal/runtime/maps: hash small keys with wyhash instead of AES#80895mcy wants to merge 2 commits into
Conversation
|
This PR (HEAD: 7a2e155) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/815960. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from Keith Randall: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from Sunny Young de la Sota: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from Keith Randall: Patch Set 3: Auto-Submit+1 Code-Review+2 Commit-Queue+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 3: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2026-08-17T21:17:28Z","revision":"fb52a28ee042aca8cf958e4d2404ae735ee2ab9d"} Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from Keith Randall: Patch Set 3: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from Keith Randall: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from Keith Randall: Patch Set 3: -Commit-Queue (Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_5200>) Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 3: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 3: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from Sunny Young de la Sota: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
|
Message from Sunny Young de la Sota: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/815960. |
Replace UseAeshash with MinAeshashSize, which sets the smallest key size
at which we actually use AES hash. This tunable parameter can be
discovered using benchmarks, allowing for fine-tuning of a hybrid
wyhash/AES implementation to different microarchitectures.
It turns out that using AES for very small keys leaves a noticeable
amount of performance on the table, because SIMD instructions do not
like being used for one-offs. Unsurprisingly, the a block cipher wants
streaming inputs.
This CL includes a benchmark that can be used to calculate ideal cutoff
values for other targets. I've used the Zen 4 x86_64 implementtion for
this particular CL, but preparing similar changes keyed on stepping
numbers (e.g. to target Intel chips) should be a very easy and
worthwhile followup.
On my machine (Zen4, 7995WX), I selected the cutoff at 8 bytes, and
observed the following improvements across multiple linker-randomized
binaries:
The final benchmark is new, and is intended to measure hash latency
specifically; existing benchmarks look good on AES because they focus on
throughput.
All other benchmarks do not show statistically significant changes as
reported by benchstat.