From 2caaad942e15c148bfce33e06baa03d3a1557fcd Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Wed, 7 Sep 2022 20:31:00 +0000 Subject: [PATCH] runtime: use searchIdx in scavengeOne This is an optimization that prevents N^2 behavior within a chunk, but was accidentally skipped. There should be no functional change as a result of this CL. Fixes #54892. Change-Id: I861967a2268699fdc3464bd41bc56618b5628e6b Reviewed-on: https://go-review.googlesource.com/c/go/+/429255 Auto-Submit: Michael Knyszek Reviewed-by: Keith Randall Reviewed-by: Keith Randall TryBot-Result: Gopher Robot Run-TryBot: Michael Knyszek --- src/runtime/mgcscavenge.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/mgcscavenge.go b/src/runtime/mgcscavenge.go index bf38f87c77..c54ae34462 100644 --- a/src/runtime/mgcscavenge.go +++ b/src/runtime/mgcscavenge.go @@ -718,7 +718,7 @@ func (p *pageAlloc) scavengeOne(ci chunkIdx, searchIdx uint, max uintptr) uintpt if p.summary[len(p.summary)-1][ci].max() >= uint(minPages) { // We only bother looking for a candidate if there at least // minPages free pages at all. - base, npages := p.chunkOf(ci).findScavengeCandidate(pallocChunkPages-1, minPages, maxPages) + base, npages := p.chunkOf(ci).findScavengeCandidate(searchIdx, minPages, maxPages) // If we found something, scavenge it and return! if npages != 0 { -- 2.50.0