Will Go 1.9 have entirely concurrent Garbage Collection?

768 views
Skip to first unread message

ken.kof...@gmail.com

unread,
Jul 6, 2017, 3:42:24 PM7/6/17
to golang-nuts
Within the release notes for Go 1.9 it is stated:
"Library functions that used to trigger stop-the-world garbage collection now trigger concurrent garbage collection. Specifically, runtime.GCdebug.SetGCPercent, and debug.FreeOSMemory, now trigger concurrent garbage collection, blocking only the calling goroutine until the garbage collection is done."
Does this mean that the automatic Garbage Collector, which I am guessing, calls these library functions, always triggers concurrent Garbage collection? And that STW pauses have been eliminated from golang entirely?


Caleb Spare

unread,
Jul 6, 2017, 4:04:21 PM7/6/17
to ken.kof...@gmail.com, golang-nuts
On Thu, Jul 6, 2017 at 12:41 PM, <ken.kof...@gmail.com> wrote:
> Within the release notes for Go 1.9 it is stated:
> "Library functions that used to trigger stop-the-world garbage collection
> now trigger concurrent garbage collection. Specifically, runtime.GC,
> debug.SetGCPercent, and debug.FreeOSMemory, now trigger concurrent garbage
> collection, blocking only the calling goroutine until the garbage collection
> is done."
> Does this mean that the automatic Garbage Collector, which I am guessing,
> calls these library functions,

The GC does not call these library functions. The GC has been
concurrent since Go 1.5[0] and has seen a bunch of improvements in
subsequent releases as well.

> always triggers concurrent Garbage
> collection? And that STW pauses have been eliminated from golang entirely?

Most of the work the GC does is concurrent with user code, but there
is still a STW phase. It has been shortened considerably in the last
few releases; the Go 1.8 release notes say[1]:

> Garbage collection pauses should be significantly shorter than they were in Go 1.7, usually under 100 microseconds and often as low as 10 microseconds.

[0] https://golang.org/doc/go1.5#gc
[1] https://golang.org/doc/go1.8#gc

T L

unread,
Jul 7, 2017, 1:38:16 AM7/7/17
to golang-nuts, ken.kof...@gmail.com


On Friday, July 7, 2017 at 4:04:21 AM UTC+8, Caleb Spare wrote:
On Thu, Jul 6, 2017 at 12:41 PM,  <ken.kof...@gmail.com> wrote:
> Within the release notes for Go 1.9 it is stated:
> "Library functions that used to trigger stop-the-world garbage collection
> now trigger concurrent garbage collection. Specifically, runtime.GC,
> debug.SetGCPercent, and debug.FreeOSMemory, now trigger concurrent garbage
> collection, blocking only the calling goroutine until the garbage collection
> is done."

"Library functions that used to trigger stop-the-world garbage collection now trigger concurrent garbage collection"

So, before 1.9, a garbage collection triggered by those library functions will stop all user goroutines until the collection is finished?
 

voidlogic

unread,
Jul 7, 2017, 8:31:01 PM7/7/17
to golang-nuts, ken.kof...@gmail.com
>"Library functions that used to trigger stop-the-world garbage collection now trigger concurrent garbage collection"

I wonder if there is still a way to manually trigger a complete GC pass? I have hundreds of unit benches in my code bases that call runtime.GC() before t.ResetTimer() (and t.ReportAllocs()) with the intent of reducing GC related deviation between runs.
Reply all
Reply to author
Forward
0 new messages