diff options
| author | Jake Bailey <jacob.b.bailey@gmail.com> | 2025-09-09 22:22:17 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-03-24 11:17:57 -0700 |
| commit | 55600733988b0d3bb708be22b5cbecd8edd83380 (patch) | |
| tree | 8966b0c85e05e748308009ce52618eda3cf10025 /src/runtime | |
| parent | 3f057dcdbc86498e07a5744406fe92069221a92d (diff) | |
| download | go-55600733988b0d3bb708be22b5cbecd8edd83380.tar.xz | |
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 <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/runtime-gdb.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/runtime/runtime-gdb.py b/src/runtime/runtime-gdb.py index 9d2446a1eb..a56711e0bc 100644 --- a/src/runtime/runtime-gdb.py +++ b/src/runtime/runtime-gdb.py @@ -169,6 +169,10 @@ class MapTypePrinter: cnt = 0 # Yield keys and elements in group. # group is a value of type *group[K,V] + # The group layout depends on GOEXPERIMENT=mapsplitgroup: + # split: group.keys[i] / group.elems[i] + # interleaved: group.slots[i].key / group.slots[i].elem + # Detect which layout by checking for the 'keys' field. def group_slots(group): ctrl = group['ctrl'] @@ -179,8 +183,15 @@ class MapTypePrinter: continue # Full - yield str(cnt), group['slots'][i]['key'] - yield str(cnt+1), group['slots'][i]['elem'] + # The group layout depends on GOEXPERIMENT=mapsplitgroup: + # split: group.keys[i] / group.elems[i] + # interleaved: group.slots[i].key / group.slots[i].elem + try: + yield str(cnt), group['slots'][i]['key'] + yield str(cnt+1), group['slots'][i]['elem'] + except gdb.error: + yield str(cnt), group['keys'][i] + yield str(cnt+1), group['elems'][i] # The linker DWARF generation # (cmd/link/internal/ld.(*dwctxt).synthesizemaptypes) records |
