diff options
| author | Michael Anthony Knyszek <mknyszek@google.com> | 2021-04-12 22:33:54 +0000 |
|---|---|---|
| committer | Michael Knyszek <mknyszek@google.com> | 2021-10-29 18:35:20 +0000 |
| commit | 9ac1ee2d464eff73077afda83677f155bd69c6b8 (patch) | |
| tree | cd0191a02db49cd17f5d95f9f9b81a35889718d9 /src/runtime/runtime2.go | |
| parent | 8e112a7c2a814de9156f68dc8b167e4ef8c98c52 (diff) | |
| download | go-9ac1ee2d464eff73077afda83677f155bd69c6b8.tar.xz | |
runtime: track the amount of scannable allocated stack for the GC pacer
This change adds two fields to gcControllerState: stackScan, used for
pacing decisions, and scannableStackSize, which directly tracks the
amount of space allocated for inuse stacks that will be scanned.
scannableStackSize is not updated directly, but is instead flushed from
each P when at an least 8 KiB delta has accumulated. This helps reduce
issues with atomics contention for newly created goroutines. Stack
growth paths are largely unaffected.
StackGrowth-48 51.4ns ± 0% 51.4ns ± 0% ~ (p=0.927 n=10+10)
StackGrowthDeep-48 6.14µs ± 3% 6.25µs ± 4% ~ (p=0.090 n=10+9)
CreateGoroutines-48 273ns ± 1% 273ns ± 1% ~ (p=0.676 n=9+10)
CreateGoroutinesParallel-48 65.5ns ± 5% 66.6ns ± 7% ~ (p=0.340 n=9+9)
CreateGoroutinesCapture-48 2.06µs ± 1% 2.07µs ± 4% ~ (p=0.217 n=10+10)
CreateGoroutinesSingle-48 550ns ± 3% 563ns ± 4% +2.41% (p=0.034 n=8+10)
For #44167.
Change-Id: Id1800d41d3a6c211b43aeb5681c57c0dc8880daf
Reviewed-on: https://go-review.googlesource.com/c/go/+/309589
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/runtime2.go')
| -rw-r--r-- | src/runtime/runtime2.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index db1c6e307b..bfd857e8d5 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -734,6 +734,12 @@ type p struct { // Race context used while executing timer functions. timerRaceCtx uintptr + // scannableStackSizeDelta accumulates the amount of stack space held by + // live goroutines (i.e. those eligible for stack scanning). + // Flushed to gcController.scannableStackSize once scannableStackSizeSlack + // or -scannableStackSizeSlack is reached. + scannableStackSizeDelta int64 + // preempt is set to indicate that this P should be enter the // scheduler ASAP (regardless of what G is running on it). preempt bool |
