]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: detailed debug output of controller state
authorAustin Clements <austin@google.com>
Mon, 6 Apr 2015 18:30:03 +0000 (14:30 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 1 May 2015 19:39:43 +0000 (19:39 +0000)
This adds a detailed debug dump of the state of the GC controller and
a GODEBUG flag to enable it.

Change-Id: I562fed7981691a84ddf0f9e6fcd9f089f497ac13
Reviewed-on: https://go-review.googlesource.com/9640
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/mgc.go
src/runtime/runtime1.go

index f56527b1066f82d065e4d3748530c0e5df9981ec..1f4f549c0151e5beefa4e3553d75de4ff5d82eb3 100644 (file)
@@ -434,6 +434,8 @@ func (c *gcControllerState) revise() {
 // endCycle updates the GC controller state at the end of the
 // concurrent part of the GC cycle.
 func (c *gcControllerState) endCycle() {
+       h_t := c.triggerRatio // For debugging
+
        // Proportional response gain for the trigger controller. Must
        // be in [0, 1]. Lower values smooth out transient effects but
        // take longer to respond to phase changes. Higher values
@@ -487,6 +489,32 @@ func (c *gcControllerState) endCycle() {
 
        // Update EWMA of recent scan work ratios.
        c.workRatioAvg = workRatioWeight*workRatio + (1-workRatioWeight)*c.workRatioAvg
+
+       if debug.gcpacertrace > 0 {
+               // Print controller state in terms of the design
+               // document.
+               H_m_prev := memstats.heap_marked
+               H_T := memstats.next_gc
+               h_a := actualGrowthRatio
+               H_a := memstats.heap_live
+               h_g := goalGrowthRatio
+               H_g := int64(float64(H_m_prev) * (1 + h_g))
+               u_a := utilization
+               u_g := gcGoalUtilization
+               W_a := c.scanWork
+               w_a := workRatio
+               w_ewma := c.workRatioAvg
+               print("pacer: H_m_prev=", H_m_prev,
+                       " h_t=", h_t, " H_T=", H_T,
+                       " h_a=", h_a, " H_a=", H_a,
+                       " h_g=", h_g, " H_g=", H_g,
+                       " u_a=", u_a, " u_g=", u_g,
+                       " W_a=", W_a, " w_a=", w_a, " w_ewma=", w_ewma,
+                       " goalΔ=", goalGrowthRatio-h_t,
+                       " actualΔ=", h_a-h_t,
+                       " u_a/u_g=", u_a/u_g,
+                       "\n")
+       }
 }
 
 // findRunnableGCWorker returns the background mark worker for _p_ if it
index 404d8f0653aad938ddd9f5f0164eec279562a074..2151be59f999274a76f1dcaaf4b9c2b2a87395f8 100644 (file)
@@ -317,6 +317,7 @@ var debug struct {
        wbshadow       int32
        gccheckmark    int32
        sbrk           int32
+       gcpacertrace   int32
 }
 
 var dbgvars = []dbgVar{
@@ -331,6 +332,7 @@ var dbgvars = []dbgVar{
        {"wbshadow", &debug.wbshadow},
        {"gccheckmark", &debug.gccheckmark},
        {"sbrk", &debug.sbrk},
+       {"gcpacertrace", &debug.gcpacertrace},
 }
 
 func parsedebugvars() {