aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/debug.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2019-06-17 19:03:09 +0000
committerMichael Knyszek <mknyszek@google.com>2019-09-04 15:53:59 +0000
commit7b294cdd8df0a9523010f6ffc80c59e64578f34b (patch)
treede99a04805ee03f4db41c3e011e085779bcaaf15 /src/runtime/debug.go
parent033299fab66b08d434be30e05d11f7db63efa71c (diff)
downloadgo-7b294cdd8df0a9523010f6ffc80c59e64578f34b.tar.gz
go-7b294cdd8df0a9523010f6ffc80c59e64578f34b.zip
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>
Diffstat (limited to 'src/runtime/debug.go')
-rw-r--r--src/runtime/debug.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/runtime/debug.go b/src/runtime/debug.go
index af5c3a1170..76eeb2e41a 100644
--- a/src/runtime/debug.go
+++ b/src/runtime/debug.go
@@ -26,12 +26,12 @@ func GOMAXPROCS(n int) int {
return ret
}
- stopTheWorld("GOMAXPROCS")
+ stopTheWorldGC("GOMAXPROCS")
// newprocs will be processed by startTheWorld
newprocs = int32(n)
- startTheWorld()
+ startTheWorldGC()
return ret
}