]> Cypherpunks repositories - gostls13.git/commit
runtime: measure stack usage; start stacks larger if needed
authorKeith Randall <khr@golang.org>
Sat, 28 Aug 2021 22:50:52 +0000 (15:50 -0700)
committerKeith Randall <khr@google.com>
Thu, 12 May 2022 22:32:42 +0000 (22:32 +0000)
commit016d7552138077741a9c3fdadc73c0179f5d3ff7
treecfe978bcbb00bb7e67a610af16fe5706cd181723
parentda0a6f4b57fc9eb4779c295bc9620c5ed271a641
runtime: measure stack usage; start stacks larger if needed

Measure the average stack size used by goroutines at every GC. When
starting a new goroutine, allocate an initial goroutine stack of that
average size. Intuition is that we'll waste at most 2x in stack space
because only half the goroutines can be below average. In turn, we
avoid some of the early stack growth / copying needed in the average
case.

More details in the design doc at: https://docs.google.com/document/d/1YDlGIdVTPnmUiTAavlZxBI1d9pwGQgZT7IKFKlIXohQ/edit?usp=sharing

name        old time/op  new time/op  delta
Issue18138  95.3µs ± 0%  67.3µs ±13%  -29.35%  (p=0.000 n=9+10)

Fixes #18138

Change-Id: Iba34d22ed04279da7e718bbd569bbf2734922eaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/345889
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
12 files changed:
src/runtime/export_test.go
src/runtime/metrics.go
src/runtime/metrics/description.go
src/runtime/metrics/doc.go
src/runtime/mgc.go
src/runtime/mgcmark.go
src/runtime/mgcpacer.go
src/runtime/proc.go
src/runtime/runtime1.go
src/runtime/runtime2.go
src/runtime/stack.go
src/runtime/stack_test.go