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.
9 "internal/trace/v2/event"
13 EvNone event.Type = iota // unused
16 EvEventBatch // start of per-M batch of events [generation, M ID, timestamp, batch length]
17 EvStacks // start of a section of the stack table [...EvStack]
18 EvStack // stack table entry [ID, ...{PC, func string ID, file string ID, line #}]
19 EvStrings // start of a section of the string dictionary [...EvString]
20 EvString // string dictionary entry [ID, length, string]
21 EvCPUSamples // start of a section of CPU samples [...EvCPUSample]
22 EvCPUSample // CPU profiling sample [timestamp, M ID, P ID, goroutine ID, stack ID]
23 EvFrequency // timestamp units per sec [freq]
26 EvProcsChange // current value of GOMAXPROCS [timestamp, GOMAXPROCS, stack ID]
27 EvProcStart // start of P [timestamp, P ID, P seq]
28 EvProcStop // stop of P [timestamp]
29 EvProcSteal // P was stolen [timestamp, P ID, P seq, M ID]
30 EvProcStatus // P status at the start of a generation [timestamp, P ID, status]
33 EvGoCreate // goroutine creation [timestamp, new goroutine ID, new stack ID, stack ID]
34 EvGoCreateSyscall // goroutine appears in syscall (cgo callback) [timestamp, new goroutine ID]
35 EvGoStart // goroutine starts running [timestamp, goroutine ID, goroutine seq]
36 EvGoDestroy // goroutine ends [timestamp]
37 EvGoDestroySyscall // goroutine ends in syscall (cgo callback) [timestamp]
38 EvGoStop // goroutine yields its time, but is runnable [timestamp, reason, stack ID]
39 EvGoBlock // goroutine blocks [timestamp, reason, stack ID]
40 EvGoUnblock // goroutine is unblocked [timestamp, goroutine ID, goroutine seq, stack ID]
41 EvGoSyscallBegin // syscall enter [timestamp, stack ID]
42 EvGoSyscallEnd // syscall exit [timestamp]
43 EvGoSyscallEndBlocked // syscall exit and it blocked at some point [timestamp]
44 EvGoStatus // goroutine status at the start of a generation [timestamp, goroutine ID, status]
47 EvSTWBegin // STW start [timestamp, kind]
48 EvSTWEnd // STW done [timestamp]
51 EvGCActive // GC active [timestamp, seq]
52 EvGCBegin // GC start [timestamp, seq, stack ID]
53 EvGCEnd // GC done [timestamp, seq]
54 EvGCSweepActive // GC sweep active [timestamp, P ID]
55 EvGCSweepBegin // GC sweep start [timestamp, stack ID]
56 EvGCSweepEnd // GC sweep done [timestamp, swept bytes, reclaimed bytes]
57 EvGCMarkAssistActive // GC mark assist active [timestamp, goroutine ID]
58 EvGCMarkAssistBegin // GC mark assist start [timestamp, stack ID]
59 EvGCMarkAssistEnd // GC mark assist done [timestamp]
60 EvHeapAlloc // gcController.heapLive change [timestamp, heap alloc in bytes]
61 EvHeapGoal // gcController.heapGoal() change [timestamp, heap goal in bytes]
64 EvGoLabel // apply string label to current running goroutine [timestamp, label string ID]
65 EvUserTaskBegin // trace.NewTask [timestamp, internal task ID, internal parent task ID, name string ID, stack ID]
66 EvUserTaskEnd // end of a task [timestamp, internal task ID, stack ID]
67 EvUserRegionBegin // trace.{Start,With}Region [timestamp, internal task ID, name string ID, stack ID]
68 EvUserRegionEnd // trace.{End,With}Region [timestamp, internal task ID, name string ID, stack ID]
69 EvUserLog // trace.Log [timestamp, internal task ID, key string ID, stack, value string ID]
72 // EventString returns the name of a Go 1.22 event.
73 func EventString(typ event.Type) string {
74 if int(typ) < len(specs) {
75 return specs[typ].Name
77 return fmt.Sprintf("Invalid(%d)", typ)
80 func Specs() []event.Spec {
84 var specs = [...]event.Spec{
85 // "Structural" Events.
86 EvEventBatch: event.Spec{
88 Args: []string{"gen", "m", "time", "size"},
95 Args: []string{"id", "nframes"},
98 EvStrings: event.Spec{
101 EvString: event.Spec{
103 Args: []string{"id"},
106 EvCPUSamples: event.Spec{
109 EvCPUSample: event.Spec{
111 Args: []string{"time", "p", "g", "m", "stack"},
112 // N.B. There's clearly a timestamp here, but these Events
113 // are special in that they don't appear in the regular
116 EvFrequency: event.Spec{
118 Args: []string{"freq"},
122 EvProcsChange: event.Spec{
124 Args: []string{"dt", "procs_value", "stack"},
128 EvProcStart: event.Spec{
130 Args: []string{"dt", "p", "p_seq"},
133 EvProcStop: event.Spec{
135 Args: []string{"dt"},
138 EvProcSteal: event.Spec{
140 Args: []string{"dt", "p", "p_seq", "m"},
143 EvProcStatus: event.Spec{
145 Args: []string{"dt", "p", "pstatus"},
148 EvGoCreate: event.Spec{
150 Args: []string{"dt", "new_g", "new_stack", "stack"},
152 StackIDs: []int{3, 2},
154 EvGoCreateSyscall: event.Spec{
155 Name: "GoCreateSyscall",
156 Args: []string{"dt", "new_g"},
159 EvGoStart: event.Spec{
161 Args: []string{"dt", "g", "g_seq"},
164 EvGoDestroy: event.Spec{
166 Args: []string{"dt"},
169 EvGoDestroySyscall: event.Spec{
170 Name: "GoDestroySyscall",
171 Args: []string{"dt"},
174 EvGoStop: event.Spec{
176 Args: []string{"dt", "reason_string", "stack"},
181 EvGoBlock: event.Spec{
183 Args: []string{"dt", "reason_string", "stack"},
188 EvGoUnblock: event.Spec{
190 Args: []string{"dt", "g", "g_seq", "stack"},
194 EvGoSyscallBegin: event.Spec{
195 Name: "GoSyscallBegin",
196 Args: []string{"dt", "stack"},
200 EvGoSyscallEnd: event.Spec{
201 Name: "GoSyscallEnd",
202 Args: []string{"dt"},
203 StartEv: EvGoSyscallBegin,
206 EvGoSyscallEndBlocked: event.Spec{
207 Name: "GoSyscallEndBlocked",
208 Args: []string{"dt"},
209 StartEv: EvGoSyscallBegin,
212 EvGoStatus: event.Spec{
214 Args: []string{"dt", "g", "m", "gstatus"},
217 EvSTWBegin: event.Spec{
219 Args: []string{"dt", "kind_string", "stack"},
224 EvSTWEnd: event.Spec{
226 Args: []string{"dt"},
230 EvGCActive: event.Spec{
232 Args: []string{"dt", "gc_seq"},
236 EvGCBegin: event.Spec{
238 Args: []string{"dt", "gc_seq", "stack"},
244 Args: []string{"dt", "gc_seq"},
248 EvGCSweepActive: event.Spec{
249 Name: "GCSweepActive",
250 Args: []string{"dt", "p"},
251 StartEv: EvGCSweepBegin,
254 EvGCSweepBegin: event.Spec{
255 Name: "GCSweepBegin",
256 Args: []string{"dt", "stack"},
260 EvGCSweepEnd: event.Spec{
262 Args: []string{"dt", "swept_value", "reclaimed_value"},
263 StartEv: EvGCSweepBegin,
266 EvGCMarkAssistActive: event.Spec{
267 Name: "GCMarkAssistActive",
268 Args: []string{"dt", "g"},
269 StartEv: EvGCMarkAssistBegin,
272 EvGCMarkAssistBegin: event.Spec{
273 Name: "GCMarkAssistBegin",
274 Args: []string{"dt", "stack"},
278 EvGCMarkAssistEnd: event.Spec{
279 Name: "GCMarkAssistEnd",
280 Args: []string{"dt"},
281 StartEv: EvGCMarkAssistBegin,
284 EvHeapAlloc: event.Spec{
286 Args: []string{"dt", "heapalloc_value"},
289 EvHeapGoal: event.Spec{
291 Args: []string{"dt", "heapgoal_value"},
294 EvGoLabel: event.Spec{
296 Args: []string{"dt", "label_string"},
300 EvUserTaskBegin: event.Spec{
301 Name: "UserTaskBegin",
302 Args: []string{"dt", "task", "parent_task", "name_string", "stack"},
307 EvUserTaskEnd: event.Spec{
309 Args: []string{"dt", "task", "stack"},
313 EvUserRegionBegin: event.Spec{
314 Name: "UserRegionBegin",
315 Args: []string{"dt", "task", "name_string", "stack"},
320 EvUserRegionEnd: event.Spec{
321 Name: "UserRegionEnd",
322 Args: []string{"dt", "task", "name_string", "stack"},
323 StartEv: EvUserRegionBegin,
328 EvUserLog: event.Spec{
330 Args: []string{"dt", "task", "key_string", "value_string", "stack"},
333 StringIDs: []int{2, 3},
340 GoBad GoStatus = iota
347 func (s GoStatus) String() string {
361 type ProcStatus uint8
364 ProcBad ProcStatus = iota
371 func (s ProcStatus) String() string {
384 // Various format-specific constants.
385 MaxBatchSize = 64 << 10
386 MaxFramesPerStack = 128
387 MaxStringSize = 1 << 10