Currently we shrink stacks during STW mark termination because it used
to be unsafe to shrink them concurrently. For some programs, this
significantly increases pause time: stack shrinking costs ~5ms/MB
copied plus 2µs/shrink.
Now that we've made it safe to shrink a stack without the world being
stopped, shrink them during the concurrent mark phase.
This reduces the STW time in the program from issue #12967 by an order
of magnitude and brings it from over the 10ms goal to well under:
name old 95%ile-markTerm-time new 95%ile-markTerm-time delta
Stackshrink-4 23.8ms ±60% 1.80ms ±39% -92.44% (p=0.008 n=5+5)
Fixes #12967.
This slows down the go1 and garbage benchmarks overall by < 0.5%.
name old time/op new time/op delta
XBenchGarbage-12 2.48ms ± 1% 2.49ms ± 1% +0.45% (p=0.005 n=25+21)