]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: don't hold worldsema across mark phase
authorMichael Anthony Knyszek <mknyszek@google.com>
Mon, 17 Jun 2019 19:03:09 +0000 (19:03 +0000)
committerMichael Knyszek <mknyszek@google.com>
Wed, 4 Sep 2019 15:53:59 +0000 (15:53 +0000)
commit7b294cdd8df0a9523010f6ffc80c59e64578f34b
treede99a04805ee03f4db41c3e011e085779bcaaf15
parent033299fab66b08d434be30e05d11f7db63efa71c
runtime: don't hold worldsema across mark phase

This change makes it so that worldsema isn't held across the mark phase.
This means that various operations like ReadMemStats may now stop the
world during the mark phase, reducing latency on such operations.

Only three such operations are still no longer allowed to occur during
marking: GOMAXPROCS, StartTrace, and StopTrace.

For the former it's because any change to GOMAXPROCS impacts GC mark
background worker scheduling and the details there are tricky.

For the latter two it's because tracing needs to observe consistent GC
start and GC end events, and if StartTrace or StopTrace may stop the
world during marking, then it's possible for it to see a GC end event
without a start or GC start event without an end, respectively.

To ensure that GOMAXPROCS and StartTrace/StopTrace cannot proceed until
marking is complete, the runtime now holds a new semaphore, gcsema,
across the mark phase just like it used to with worldsema.

Fixes #19812.

Change-Id: I15d43ed184f711b3d104e8f267fb86e335f86bf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/182657
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/runtime/debug.go
src/runtime/mgc.go
src/runtime/proc.go
src/runtime/trace.go
src/runtime/trace/trace_stack_test.go