internal/runtime/gc/scan: avoid -1 index when cache sizes unavailable

Fixes #74984.
Fixes #74983.

Change-Id: I011c66c2005bc4d92f1d17f1f8ce88158634f71f
Reviewed-on: https://go-review.googlesource.com/c/go/+/695476
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Michael Anthony Knyszek 2025-08-12 21:57:23 +00:00 committed by Michael Knyszek
parent 4e182db5fc
commit adbf59525c

View file

@ -100,6 +100,9 @@ func benchmarkCacheSizes(b *testing.B, fn func(b *testing.B, heapPages int)) {
fn(b, pages)
})
}
if len(cacheSizes) == 0 {
return
}
ramPages := int(cacheSizes[len(cacheSizes)-1]*3/2) / gc.PageSize
b.Run(fmt.Sprintf("cache=ram/pages=%d", ramPages), func(b *testing.B) {
fn(b, ramPages)