]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: use searchIdx in scavengeOne
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 7 Sep 2022 20:31:00 +0000 (20:31 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 8 Sep 2022 16:06:03 +0000 (16:06 +0000)
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 <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

src/runtime/mgcscavenge.go

index bf38f87c778ced1c7086766aeec4acb640632648..c54ae3446249a5fdbd8138d98d08de999f473ccf 100644 (file)
@@ -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 {