]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make sysmon-triggered GC concurrent
authorAustin Clements <austin@google.com>
Wed, 8 Jul 2015 21:18:33 +0000 (14:18 -0700)
committerAustin Clements <austin@google.com>
Thu, 9 Jul 2015 05:53:21 +0000 (05:53 +0000)
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 <r@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/proc.go
src/runtime/proc1.go

index 805b96e627bcddb0b6c5c6115f68815fca06014e..1a4c6c109f4315ae7906ab4d7481c50543130076 100644 (file)
@@ -154,7 +154,7 @@ func forcegchelper() {
                if debug.gctrace > 0 {
                        println("GC forced")
                }
-               startGC(gcForceMode)
+               startGC(gcBackgroundMode)
        }
 }
 
index 6a163c62a0741feb07d1df98de1d75488db68978..a048ded94cc82d69d519d9914ece9ba9c332f8f0 100644 (file)
@@ -3004,7 +3004,7 @@ func sysmon() {
                }
                // check if we need to force a GC
                lastgc := int64(atomicload64(&memstats.last_gc))
-               if lastgc != 0 && unixnow-lastgc > forcegcperiod && atomicload(&forcegc.idle) != 0 {
+               if lastgc != 0 && unixnow-lastgc > forcegcperiod && atomicload(&forcegc.idle) != 0 && atomicloaduint(&bggc.working) == 0 {
                        lock(&forcegc.lock)
                        forcegc.idle = 0
                        forcegc.g.schedlink = 0