]> Cypherpunks repositories - gostls13.git/commit
runtime: only trigger forced GC if GC is not running
authorAustin Clements <austin@google.com>
Mon, 14 Dec 2015 22:25:28 +0000 (17:25 -0500)
committerAustin Clements <austin@google.com>
Tue, 15 Dec 2015 20:13:19 +0000 (20:13 +0000)
commit01baf13ba587f2caabdec8d6c58cb5c7db7812d1
tree49388215a09ea3ef252f87262a6b6768192ffb77
parent50d8d4e834039574602df287522a25bb70c101bb
runtime: only trigger forced GC if GC is not running

Currently, sysmon triggers a forced GC solely based on
memstats.last_gc. However, memstats.last_gc isn't updated until mark
termination, so once sysmon starts triggering forced GC, it will keep
triggering them until GC finishes. The first of these actually starts
a GC; the remainder up to the last print "GC forced", but gcStart
returns immediately because gcphase != _GCoff; then the last may start
another GC if the previous GC finishes (and sets last_gc) between
sysmon triggering it and gcStart checking the GC phase.

Fix this by expanding the condition for starting a forced GC to also
require that no GC is currently running. This, combined with the way
forcegchelper blocks until the GC cycle is started, ensures sysmon
only starts one GC when the time exceeds the forced GC threshold.

Fixes #13458.

Change-Id: Ie6cf841927f6085136be3f45259956cd5cf10d23
Reviewed-on: https://go-review.googlesource.com/17819
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/proc.go