Debian Codegraph @

trace/testdata/generators/go122-syscall-steal-proc-ambiguous.go

raw symbols SCIP
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.
4
5 // Code generated by "gen.bash" from internal/trace; DO NOT EDIT.
6
7 //go:build go1.23
8
9 // Tests syscall P stealing.
10 //
11 // Specifically, it tests a scenario wherein, without a
12 // P sequence number of GoSyscallBegin, the syscall that
13 // a ProcSteal applies to is ambiguous. This only happens in
14 // practice when the events aren't already properly ordered
15 // by timestamp, since the ProcSteal won't be seen until after
16 // the correct GoSyscallBegin appears on the frontier.
17
18 package main
19
20 import (
21 "golang.org/x/exp/trace"
22 "golang.org/x/exp/trace/internal/testgen"
23 "golang.org/x/exp/trace/internal/tracev2"
24 "golang.org/x/exp/trace/internal/version"
25 )
26
27 func main() {
28 testgen.Main(version.Go122, gen)
29 }
30
31 func gen(t *testgen.Trace) {
32 t.DisableTimestamps()
33
34 g := t.Generation(1)
35
36 // One goroutine does a syscall without blocking, then another one where
37 // it's P gets stolen.
38 b0 := g.Batch(trace.ThreadID(0), 0)
39 b0.Event("ProcStatus", trace.ProcID(0), tracev2.ProcRunning)
40 b0.Event("GoStatus", trace.GoID(1), trace.ThreadID(0), tracev2.GoRunning)
41 b0.Event("GoSyscallBegin", testgen.Seq(1), testgen.NoStack)
42 b0.Event("GoSyscallEnd")
43 b0.Event("GoSyscallBegin", testgen.Seq(2), testgen.NoStack)
44 b0.Event("GoSyscallEndBlocked")
45
46 // A running goroutine steals proc 0.
47 b1 := g.Batch(trace.ThreadID(1), 0)
48 b1.Event("ProcStatus", trace.ProcID(2), tracev2.ProcRunning)
49 b1.Event("GoStatus", trace.GoID(2), trace.ThreadID(1), tracev2.GoRunning)
50 b1.Event("ProcSteal", trace.ProcID(0), testgen.Seq(3), trace.ThreadID(0))
51 }