You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The logic to trigger periodic GC is such that if GC is disabled but at least one GC cycle has ever happened (e.g., GC was disabled at runtime by SetGCPercent(-1) or runtime.GC() was called), then once the periodic GC period has elapsed (2 minutes by default), sysmon will attempt to trigger a GC every 10ms. This GC will be a no-op, but it still goes through the motions of waking the goroutine and prints a gctrace line.
The following program demonstrates this:
package main
import"runtime"funcmain() {
runtime.GC()
for {
fib(10)
}
}
funcfib(nint) int {
ifn<=2 {
return1
}
returnfib(n-1) +fib(n-2)
}
If run with GODEBUG=gctrace=1 GOGC=off ./test, then after two minutes the runtime will print GC forced every 10ms. (If you don't want to wait two minutes, add forcegcperiod = 10 * 1e9 to sysmon.)
AFAIK this isn't happening in the wild. I found this while reworking the triggering logic.
Currently sysmon triggers periodic GC if GC is not currently running
and it's been long enough since the last GC. This misses some
important conditions; for example, whether GC is enabled at all by
GOGC. As a result, if GOGC is off, once we pass the timeout for
periodic GC, sysmon will attempt to trigger a GC every 10ms. This GC
will be a no-op because gcStart will check all of the appropriate
conditions and do nothing, but it still goes through the motions of
waking the forcegc goroutine and printing a gctrace line.
Fix this by making sysmon call gcShouldStart to check *all* of the
appropriate transition conditions before attempting to trigger a
periodic GC.
Fixesgolang#19247.
Change-Id: Icee5521ce175e8419f934723849853d53773af31
Reviewed-on: https://go-review.googlesource.com/37515
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
The logic to trigger periodic GC is such that if GC is disabled but at least one GC cycle has ever happened (e.g., GC was disabled at runtime by
SetGCPercent(-1)
orruntime.GC()
was called), then once the periodic GC period has elapsed (2 minutes by default), sysmon will attempt to trigger a GC every 10ms. This GC will be a no-op, but it still goes through the motions of waking the goroutine and prints a gctrace line.The following program demonstrates this:
If run with
GODEBUG=gctrace=1 GOGC=off ./test
, then after two minutes the runtime will printGC forced
every 10ms. (If you don't want to wait two minutes, addforcegcperiod = 10 * 1e9
tosysmon
.)AFAIK this isn't happening in the wild. I found this while reworking the triggering logic.
/cc @RLH
The text was updated successfully, but these errors were encountered: