From 55600733988b0d3bb708be22b5cbecd8edd83380 Mon Sep 17 00:00:00 2001 From: Jake Bailey Date: Tue, 9 Sep 2025 22:22:17 -0700 Subject: internal/runtime/maps: add GOEXPERIMENT=mapsplitgroup for KKKKVVVV slot order Map groups are currently: type group struct { ctrl uint64 slots [8]slot } type slot struct { key K elem E } If the element type is struct{}, the slot will be padded so that the address of the elem is unique rather than pointing outside the alloc. This has the effect of map[K]struct{} wasting space due to the extra byte and padding, making it no better than map[K]bool. This CL changes the group layout to instead place keys and elems together, as they used to be before swiss maps: type group struct { ctrl uint64 keys [8]K elems [8]V } This is an alternative to CL 701976, which I suspect will have better performance. Keys placed together should lead to better cache behavior, at the cost of more expensive elem lookups, since the elems are not a fixed offset from their keys. This change is locked behind GOEXPERIMENT=mapsplitgroup. Updates #70835 Updates #71368 Change-Id: Ide8d1406ae4ab636f86edc40e0640cc80653197c Reviewed-on: https://go-review.googlesource.com/c/go/+/711560 Reviewed-by: Michael Pratt Auto-Submit: Michael Pratt LUCI-TryBot-Result: Go LUCI Reviewed-by: Dmitri Shuralyov --- src/cmd/link/internal/ld/deadcode.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd/link/internal/ld/deadcode.go') diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go index 055b4efe5d..c2dead36bf 100644 --- a/src/cmd/link/internal/ld/deadcode.go +++ b/src/cmd/link/internal/ld/deadcode.go @@ -560,7 +560,7 @@ func (d *deadcodePass) decodetypeMethods(ldr *loader.Loader, arch *sys.Arch, sym case abi.Chan: // reflect.chanType off += 2 * arch.PtrSize case abi.Map: - off += 7*arch.PtrSize + 4 // internal/abi.MapType + off += 10*arch.PtrSize + 4 // internal/abi.MapType if arch.PtrSize == 8 { off += 4 // padding for final uint32 field (Flags). } -- cgit v1.3-6-g1900