From: Michael Anthony Knyszek Date: Wed, 18 May 2022 22:07:46 +0000 (+0000) Subject: runtime: use correct heap goal in GC traces X-Git-Tag: go1.19beta1~171 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a6c75aa5c3009e6c4179ef9429b3efbd708499bf;p=gostls13.git runtime: use correct heap goal in GC traces Currently gctrace and gcpacertrace recompute the heap goal for end-of-cycle information but this is incorrect. Because both of these traces are printing stats from the previous cycle in this case, they should print the heap goal at the end of the previous cycle. Change-Id: I967621cbaff9f331cd3e361de8850ddfe0cfc099 Reviewed-on: https://go-review.googlesource.com/c/go/+/407138 Reviewed-by: Michael Pratt Reviewed-by: David Chase --- diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 8b323c5bf7..ac4f5d0335 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -1118,7 +1118,7 @@ func gcMarkTermination() { } print(" ms cpu, ", work.heap0>>20, "->", work.heap1>>20, "->", work.heap2>>20, " MB, ", - gcController.heapGoal()>>20, " MB goal, ", + gcController.lastHeapGoal>>20, " MB goal, ", atomic.Load64(&gcController.maxStackScan)>>20, " MB stacks, ", gcController.globalsScan>>20, " MB globals, ", work.maxprocs, " P") diff --git a/src/runtime/mgcpacer.go b/src/runtime/mgcpacer.go index 2487f58dc5..87ad4b0a15 100644 --- a/src/runtime/mgcpacer.go +++ b/src/runtime/mgcpacer.go @@ -731,12 +731,11 @@ func (c *gcControllerState) endCycle(now int64, procs int, userForced bool) { } if debug.gcpacertrace > 0 { - heapGoal := c.heapGoal() printlock() goal := gcGoalUtilization * 100 print("pacer: ", int(utilization*100), "% CPU (", int(goal), " exp.) for ") print(c.heapScanWork.Load(), "+", c.stackScanWork.Load(), "+", c.globalsScanWork.Load(), " B work (", c.lastHeapScan+c.lastStackScan+c.globalsScan, " B exp.) ") - print("in ", c.triggered, " B -> ", c.heapLive, " B (∆goal ", int64(c.heapLive)-int64(heapGoal), ", cons/mark ", oldConsMark, ")") + print("in ", c.triggered, " B -> ", c.heapLive, " B (∆goal ", int64(c.heapLive)-int64(c.lastHeapGoal), ", cons/mark ", oldConsMark, ")") if !ok { print("[controller reset]") }