]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: use correct heap goal in GC traces
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 18 May 2022 22:07:46 +0000 (22:07 +0000)
committerMichael Knyszek <mknyszek@google.com>
Thu, 19 May 2022 19:57:28 +0000 (19:57 +0000)
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 <mpratt@google.com>
Reviewed-by: David Chase <drchase@google.com>
src/runtime/mgc.go
src/runtime/mgcpacer.go

index 8b323c5bf790ac1703ddc2d511813038d50eb33a..ac4f5d0335534e7b5e8d4d9b671225a139f9a4e7 100644 (file)
@@ -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")
index 2487f58dc55009b8e10ddf62ed5c5d1e0a515223..87ad4b0a156b45cdf666ae2b5a963da8088582df 100644 (file)
@@ -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]")
                }