From 63f762bcdea96889d8ffa406804665b84bda63ab Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Thu, 14 Nov 2024 16:58:07 -0800 Subject: internal/runtime/maps: eliminate a load from the hot path typ.Group.Size involves two loads. Instead cache GroupSize as a separate fields of the map type so we can get to it in just one load. Change-Id: I10ffdce1c7f75dcf448da14040fda78f0d75fd1d Reviewed-on: https://go-review.googlesource.com/c/go/+/627716 Reviewed-by: Cherry Mui Reviewed-by: Michael Pratt LUCI-TryBot-Result: Go LUCI --- src/internal/runtime/maps/map_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/internal/runtime/maps/map_test.go') diff --git a/src/internal/runtime/maps/map_test.go b/src/internal/runtime/maps/map_test.go index 42db55c6a4..160450ebb2 100644 --- a/src/internal/runtime/maps/map_test.go +++ b/src/internal/runtime/maps/map_test.go @@ -517,8 +517,8 @@ func testTableIterationGrowDuplicate(t *testing.T, grow int) { key := *(*uint32)(keyPtr) elem := *(*uint64)(elemPtr) - if elem != 256 + uint64(key) { - t.Errorf("iteration got key %d elem %d want elem %d", key, elem, 256 + uint64(key)) + if elem != 256+uint64(key) { + t.Errorf("iteration got key %d elem %d want elem %d", key, elem, 256+uint64(key)) } if _, ok := got[key]; ok { t.Errorf("iteration got key %d more than once", key) @@ -623,7 +623,7 @@ func TestMapZeroSizeSlot(t *testing.T) { tab := m.TableFor(typ, unsafe.Pointer(&key)) start := tab.GroupsStart() length := tab.GroupsLength() - end := unsafe.Pointer(uintptr(start) + length*typ.Group.Size() - 1) // inclusive to ensure we have a valid pointer + end := unsafe.Pointer(uintptr(start) + length*typ.GroupSize - 1) // inclusive to ensure we have a valid pointer if uintptr(got) < uintptr(start) || uintptr(got) > uintptr(end) { t.Errorf("elem address outside groups allocation; got %p want [%p, %p]", got, start, end) } -- cgit v1.3