Skip to content

Commit 4b2774f

Browse files
committed
runtime: make sysmon-triggered GC concurrent
sysmon triggers a GC if there has been no GC for two minutes. Currently, this is a STW GC. There is no reason for this to be STW, so make it concurrent. Fixes #10261. Change-Id: I92f3ac37272d5c2a31480ff1fa897ebad08775a9 Reviewed-on: https://go-review.googlesource.com/11955 Reviewed-by: Rob Pike <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent 012917a commit 4b2774f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/runtime/proc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func forcegchelper() {
154154
if debug.gctrace > 0 {
155155
println("GC forced")
156156
}
157-
startGC(gcForceMode)
157+
startGC(gcBackgroundMode)
158158
}
159159
}
160160

src/runtime/proc1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3004,7 +3004,7 @@ func sysmon() {
30043004
}
30053005
// check if we need to force a GC
30063006
lastgc := int64(atomicload64(&memstats.last_gc))
3007-
if lastgc != 0 && unixnow-lastgc > forcegcperiod && atomicload(&forcegc.idle) != 0 {
3007+
if lastgc != 0 && unixnow-lastgc > forcegcperiod && atomicload(&forcegc.idle) != 0 && atomicloaduint(&bggc.working) == 0 {
30083008
lock(&forcegc.lock)
30093009
forcegc.idle = 0
30103010
forcegc.g.schedlink = 0

0 commit comments

Comments
 (0)