Skip to content

Commit 6ec46f4

Browse files
committed
runtime/pprof: slow new goroutine launches in test
The goroutine profiler tests include one that launches a steady stream of goroutines. That creates a scheduler busy loop that can prevent forward progress in the rest of the program. Slow down the launches a bit so other goroutines have a chance to run. Fixes #52916 For #52934 Change-Id: I748557201b94918b1fa4960544a51a48d9cacc6b Reviewed-on: https://go-review.googlesource.com/c/go/+/406654 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent ab8d7dd commit 6ec46f4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/runtime/pprof/pprof_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,10 @@ func TestGoroutineProfileConcurrency(t *testing.T) {
15271527
SetGoroutineLabels(WithLabels(ctx, Labels(t.Name()+"-churn-i", fmt.Sprint(i))))
15281528
if i == 0 {
15291529
ready.Done()
1530+
} else if i%16 == 0 {
1531+
// Yield on occasion so this sequence of goroutine launches
1532+
// doesn't monopolize a P. See issue #52934.
1533+
runtime.Gosched()
15301534
}
15311535
if ctx.Err() == nil {
15321536
go churn(i + 1)

0 commit comments

Comments
 (0)