1
0
mirror of https://github.com/golang/go synced 2024-11-05 22:46:12 -07:00

runtime: fix the miscalculation of memoryLimitGoal in gcPaceScavenger

The goal is supposed to be (100-reduceExtraPercent) / 100 * memoryLimit,
as stated in the original design.

Fixes #62449

Change-Id: Ia33acadc3320aa3625814595a24b9631ae8896d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/525555
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: 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>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
This commit is contained in:
Andy Pan 2023-09-05 17:12:24 +08:00 committed by Michael Knyszek
parent 4be921d888
commit 729f214e3a

View File

@ -172,7 +172,7 @@ func gcPaceScavenger(memoryLimit int64, heapGoal, lastHeapGoal uint64) {
// it's simpler. // it's simpler.
// We want to target retaining (100-reduceExtraPercent)% of the heap. // We want to target retaining (100-reduceExtraPercent)% of the heap.
memoryLimitGoal := uint64(float64(memoryLimit) * (100.0 - reduceExtraPercent)) memoryLimitGoal := uint64(float64(memoryLimit) * (1 - reduceExtraPercent/100.0))
// mappedReady is comparable to memoryLimit, and represents how much total memory // mappedReady is comparable to memoryLimit, and represents how much total memory
// the Go runtime has committed now (estimated). // the Go runtime has committed now (estimated).
@ -1297,7 +1297,7 @@ const (
scavChunkHasFree scavChunkFlags = 1 << iota scavChunkHasFree scavChunkFlags = 1 << iota
// scavChunkNoHugePage indicates whether this chunk has had any huge // scavChunkNoHugePage indicates whether this chunk has had any huge
// pages broken by the scavenger. // pages broken by the scavenger.
//. //
// The negative here is unfortunate, but necessary to make it so that // The negative here is unfortunate, but necessary to make it so that
// the zero value of scavChunkData accurately represents the state of // the zero value of scavChunkData accurately represents the state of
// a newly-grown chunk. (New memory is marked as backed by huge pages.) // a newly-grown chunk. (New memory is marked as backed by huge pages.)