diff options
| author | Michael Pratt <mpratt@google.com> | 2024-09-23 14:46:09 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-10-30 15:20:52 +0000 |
| commit | d95b7980aa1ef94983983cd98e005947e83d562d (patch) | |
| tree | 89fa94d8c423f82a11b83c761fb4b3a0d867b247 /src/internal/runtime/maps/table_debug.go | |
| parent | f782e161623e68e25cc3a81e55dac887afd301d5 (diff) | |
| download | go-d95b7980aa1ef94983983cd98e005947e83d562d.tar.xz | |
internal/runtime/maps: cleanup seed usage
Keep only a single seed; initialize it; and reset it when the map is
empty.
For #54766.
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap
Change-Id: Icc231f70957337a2d0dcd9c7daf9bd3cb4354d71
Reviewed-on: https://go-review.googlesource.com/c/go/+/616466
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/internal/runtime/maps/table_debug.go')
| -rw-r--r-- | src/internal/runtime/maps/table_debug.go | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/internal/runtime/maps/table_debug.go b/src/internal/runtime/maps/table_debug.go index 345f1feb6e..b1def3b85e 100644 --- a/src/internal/runtime/maps/table_debug.go +++ b/src/internal/runtime/maps/table_debug.go @@ -12,7 +12,7 @@ import ( const debugLog = false -func (t *table) checkInvariants(typ *abi.SwissMapType) { +func (t *table) checkInvariants(typ *abi.SwissMapType, m *Map) { if !debugLog { return } @@ -45,12 +45,12 @@ func (t *table) checkInvariants(typ *abi.SwissMapType) { continue } - if _, ok := t.Get(typ, key); !ok { - hash := typ.Hasher(key, t.seed) + if _, ok := t.Get(typ, m, key); !ok { + hash := typ.Hasher(key, m.seed) print("invariant failed: slot(", i, "/", j, "): key ") dump(key, typ.Key.Size_) print(" not found [hash=", hash, ", h2=", h2(hash), " h1=", h1(hash), "]\n") - t.Print(typ) + t.Print(typ, m) panic("invariant failed: slot: key not found") } } @@ -59,32 +59,30 @@ func (t *table) checkInvariants(typ *abi.SwissMapType) { if used != t.used { print("invariant failed: found ", used, " used slots, but used count is ", t.used, "\n") - t.Print(typ) + t.Print(typ, m) panic("invariant failed: found mismatched used slot count") } growthLeft := (t.capacity*maxAvgGroupLoad)/abi.SwissMapGroupSlots - t.used - deleted if growthLeft != t.growthLeft { print("invariant failed: found ", t.growthLeft, " growthLeft, but expected ", growthLeft, "\n") - t.Print(typ) + t.Print(typ, m) panic("invariant failed: found mismatched growthLeft") } if deleted != t.tombstones() { print("invariant failed: found ", deleted, " tombstones, but expected ", t.tombstones(), "\n") - t.Print(typ) + t.Print(typ, m) panic("invariant failed: found mismatched tombstones") } if empty == 0 { print("invariant failed: found no empty slots (violates probe invariant)\n") - t.Print(typ) + t.Print(typ, m) panic("invariant failed: found no empty slots (violates probe invariant)") } } - -func (t *table) Print(typ *abi.SwissMapType) { +func (t *table) Print(typ *abi.SwissMapType, m *Map) { print(`table{ - seed: `, t.seed, ` index: `, t.index, ` localDepth: `, t.localDepth, ` capacity: `, t.capacity, ` |
