]> Cypherpunks repositories - gostls13.git/commit
runtime: only shrink stacks at synchronous safe points
authorAustin Clements <austin@google.com>
Fri, 27 Sep 2019 18:34:05 +0000 (14:34 -0400)
committerAustin Clements <austin@google.com>
Fri, 25 Oct 2019 23:25:35 +0000 (23:25 +0000)
commit60586034713cc94477868fb6911f34cfcc6a1ba4
tree7f118bc0095a63692341562dcf46ad7761916b04
parent36a432f27bbcc65fb03845ebe5e4a3db6f4cc189
runtime: only shrink stacks at synchronous safe points

We're about to introduce asynchronous safe points, where we won't have
precise pointer maps for all stack frames. That's okay for scanning
the stack (conservatively), but not for shrinking the stack.

Hence, this CL prepares for this by only shrinking the stack as part
of the stack scan if the goroutine is stopped at a synchronous safe
point. Otherwise, it queues up the stack shrink for the next
synchronous safe point.

We already have one condition under which we can't shrink the stack
for very similar reasons: syscalls. Currently, we just give up on
shrinking the stack if it's in a syscall. But with this mechanism, we
defer that stack shrink until the next synchronous safe point.

For #10958, #24543.

Change-Id: Ifa1dec6f33fdf30f9067be2ce3f7ab8a7f62ce38
Reviewed-on: https://go-review.googlesource.com/c/go/+/201438
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/runtime/mgcmark.go
src/runtime/runtime2.go
src/runtime/stack.go