1 // Copyright 2023 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Tests to make sure the runtime doesn't generate futile wakeups. For example,
6 // it makes sure that a block on a channel send that unblocks briefly only to
7 // immediately go back to sleep (in such a way that doesn't reveal any useful
8 // information, and is purely an artifact of the runtime implementation) doesn't
9 // make it into the trace.
25 if err := trace.Start(os.Stdout); err != nil {
26 log.Fatalf("failed to start tracing: %v", err)
29 defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(8))
30 c0 := make(chan int, 1)
31 c1 := make(chan int, 1)
32 c2 := make(chan int, 1)
34 var done sync.WaitGroup
36 for p := 0; p < procs; p++ {
39 trace.WithRegion(context.Background(), "special", func() {
40 for i := 0; i < iters; i++ {
48 trace.WithRegion(context.Background(), "special", func() {
49 for i := 0; i < iters; i++ {
57 trace.WithRegion(context.Background(), "special", func() {
58 for i := 0; i < iters; i++ {
69 trace.WithRegion(context.Background(), "special", func() {
70 for i := 0; i < iters; i++ {