Debian Codegraph @

trace/internal/tracev2/events.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 package tracev2
10
11 // Event types in the trace, args are given in square brackets.
12 //
13 // Naming scheme:
14 // - Time range event pairs have suffixes "Begin" and "End".
15 // - "Start", "Stop", "Create", "Destroy", "Block", "Unblock"
16 // are suffixes reserved for scheduling resources.
17 //
18 // NOTE: If you add an event type, make sure you also update all
19 // tables in this file!
20 const (
21 EvNone EventType = iota // unused
22
23 // Structural events.
24 EvEventBatch // start of per-M batch of events [generation, M ID, timestamp, batch length]
25 EvStacks // start of a section of the stack table [...EvStack]
26 EvStack // stack table entry [ID, ...{PC, func string ID, file string ID, line #}]
27 EvStrings // start of a section of the string dictionary [...EvString]
28 EvString // string dictionary entry [ID, length, string]
29 EvCPUSamples // start of a section of CPU samples [...EvCPUSample]
30 EvCPUSample // CPU profiling sample [timestamp, M ID, P ID, goroutine ID, stack ID]
31 EvFrequency // timestamp units per sec [freq]
32
33 // Procs.
34 EvProcsChange // current value of GOMAXPROCS [timestamp, GOMAXPROCS, stack ID]
35 EvProcStart // start of P [timestamp, P ID, P seq]
36 EvProcStop // stop of P [timestamp]
37 EvProcSteal // P was stolen [timestamp, P ID, P seq, M ID]
38 EvProcStatus // P status at the start of a generation [timestamp, P ID, status]
39
40 // Goroutines.
41 EvGoCreate // goroutine creation [timestamp, new goroutine ID, new stack ID, stack ID]
42 EvGoCreateSyscall // goroutine appears in syscall (cgo callback) [timestamp, new goroutine ID]
43 EvGoStart // goroutine starts running [timestamp, goroutine ID, goroutine seq]
44 EvGoDestroy // goroutine ends [timestamp]
45 EvGoDestroySyscall // goroutine ends in syscall (cgo callback) [timestamp]
46 EvGoStop // goroutine yields its time, but is runnable [timestamp, reason, stack ID]
47 EvGoBlock // goroutine blocks [timestamp, reason, stack ID]
48 EvGoUnblock // goroutine is unblocked [timestamp, goroutine ID, goroutine seq, stack ID]
49 EvGoSyscallBegin // syscall enter [timestamp, P seq, stack ID]
50 EvGoSyscallEnd // syscall exit [timestamp]
51 EvGoSyscallEndBlocked // syscall exit and it blocked at some point [timestamp]
52 EvGoStatus // goroutine status at the start of a generation [timestamp, goroutine ID, M ID, status]
53
54 // STW.
55 EvSTWBegin // STW start [timestamp, kind, stack ID]
56 EvSTWEnd // STW done [timestamp]
57
58 // GC events.
59 EvGCActive // GC active [timestamp, seq]
60 EvGCBegin // GC start [timestamp, seq, stack ID]
61 EvGCEnd // GC done [timestamp, seq]
62 EvGCSweepActive // GC sweep active [timestamp, P ID]
63 EvGCSweepBegin // GC sweep start [timestamp, stack ID]
64 EvGCSweepEnd // GC sweep done [timestamp, swept bytes, reclaimed bytes]
65 EvGCMarkAssistActive // GC mark assist active [timestamp, goroutine ID]
66 EvGCMarkAssistBegin // GC mark assist start [timestamp, stack ID]
67 EvGCMarkAssistEnd // GC mark assist done [timestamp]
68 EvHeapAlloc // gcController.heapLive change [timestamp, heap alloc in bytes]
69 EvHeapGoal // gcController.heapGoal() change [timestamp, heap goal in bytes]
70
71 // Annotations.
72 EvGoLabel // apply string label to current running goroutine [timestamp, label string ID]
73 EvUserTaskBegin // trace.NewTask [timestamp, internal task ID, internal parent task ID, name string ID, stack ID]
74 EvUserTaskEnd // end of a task [timestamp, internal task ID, stack ID]
75 EvUserRegionBegin // trace.{Start,With}Region [timestamp, internal task ID, name string ID, stack ID]
76 EvUserRegionEnd // trace.{End,With}Region [timestamp, internal task ID, name string ID, stack ID]
77 EvUserLog // trace.Log [timestamp, internal task ID, key string ID, value string ID, stack]
78
79 // Coroutines. Added in Go 1.23.
80 EvGoSwitch // goroutine switch (coroswitch) [timestamp, goroutine ID, goroutine seq]
81 EvGoSwitchDestroy // goroutine switch and destroy [timestamp, goroutine ID, goroutine seq]
82 EvGoCreateBlocked // goroutine creation (starts blocked) [timestamp, new goroutine ID, new stack ID, stack ID]
83
84 // GoStatus with stack. Added in Go 1.23.
85 EvGoStatusStack // goroutine status at the start of a generation, with a stack [timestamp, goroutine ID, M ID, status, stack ID]
86
87 // Batch event for an experimental batch with a custom format. Added in Go 1.23.
88 EvExperimentalBatch // start of extra data [experiment ID, generation, M ID, timestamp, batch length, batch data...]
89
90 // Sync batch. Added in Go 1.25. Previously a lone EvFrequency event.
91 EvSync // start of a sync batch [...EvFrequency|EvClockSnapshot]
92 EvClockSnapshot // snapshot of trace, mono and wall clocks [timestamp, mono, sec, nsec]
93
94 // In-band end-of-generation signal. Added in Go 1.26.
95 // Used in Go 1.25 only internally.
96 EvEndOfGeneration
97
98 NumEvents
99 )
100
101 func (ev EventType) Experimental() bool {
102 return ev > MaxEvent && ev < MaxExperimentalEvent
103 }
104
105 // Experiments.
106 const (
107 // AllocFree is the alloc-free events experiment.
108 AllocFree Experiment = 1 + iota
109
110 NumExperiments
111 )
112
113 func Experiments() []string {
114 return experiments[:]
115 }
116
117 var experiments = [...]string{
118 NoExperiment: "None",
119 AllocFree: "AllocFree",
120 }
121
122 // Experimental events.
123 const (
124 MaxEvent EventType = 127 + iota
125
126 // Experimental events for AllocFree.
127
128 // Experimental heap span events. Added in Go 1.23.
129 EvSpan // heap span exists [timestamp, id, npages, type/class]
130 EvSpanAlloc // heap span alloc [timestamp, id, npages, type/class]
131 EvSpanFree // heap span free [timestamp, id]
132
133 // Experimental heap object events. Added in Go 1.23.
134 EvHeapObject // heap object exists [timestamp, id, type]
135 EvHeapObjectAlloc // heap object alloc [timestamp, id, type]
136 EvHeapObjectFree // heap object free [timestamp, id]
137
138 // Experimental goroutine stack events. Added in Go 1.23.
139 EvGoroutineStack // stack exists [timestamp, id, order]
140 EvGoroutineStackAlloc // stack alloc [timestamp, id, order]
141 EvGoroutineStackFree // stack free [timestamp, id]
142
143 MaxExperimentalEvent
144 )
145
146 const NumExperimentalEvents = MaxExperimentalEvent - MaxEvent
147
148 // MaxTimedEventArgs is the maximum number of arguments for timed events.
149 const MaxTimedEventArgs = 5
150
151 func Specs() []EventSpec {
152 return specs[:]
153 }
154
155 var specs = [...]EventSpec{
156 // "Structural" Events.
157 EvEventBatch: {
158 Name: "EventBatch",
159 Args: []string{"gen", "m", "time", "size"},
160 },
161 EvStacks: {
162 Name: "Stacks",
163 },
164 EvStack: {
165 Name: "Stack",
166 Args: []string{"id", "nframes"},
167 IsStack: true,
168 },
169 EvStrings: {
170 Name: "Strings",
171 },
172 EvString: {
173 Name: "String",
174 Args: []string{"id"},
175 HasData: true,
176 },
177 EvCPUSamples: {
178 Name: "CPUSamples",
179 },
180 EvCPUSample: {
181 Name: "CPUSample",
182 Args: []string{"time", "m", "p", "g", "stack"},
183 // N.B. There's clearly a timestamp here, but these Events
184 // are special in that they don't appear in the regular
185 // M streams.
186 StackIDs: []int{4},
187 },
188 EvFrequency: {
189 Name: "Frequency",
190 Args: []string{"freq"},
191 },
192 EvExperimentalBatch: {
193 Name: "ExperimentalBatch",
194 Args: []string{"exp", "gen", "m", "time"},
195 HasData: true, // Easier to represent for raw readers.
196 },
197 EvSync: {
198 Name: "Sync",
199 },
200 EvEndOfGeneration: {
201 Name: "EndOfGeneration",
202 },
203
204 // "Timed" Events.
205 EvProcsChange: {
206 Name: "ProcsChange",
207 Args: []string{"dt", "procs_value", "stack"},
208 IsTimedEvent: true,
209 StackIDs: []int{2},
210 },
211 EvProcStart: {
212 Name: "ProcStart",
213 Args: []string{"dt", "p", "p_seq"},
214 IsTimedEvent: true,
215 },
216 EvProcStop: {
217 Name: "ProcStop",
218 Args: []string{"dt"},
219 IsTimedEvent: true,
220 },
221 EvProcSteal: {
222 Name: "ProcSteal",
223 Args: []string{"dt", "p", "p_seq", "m"},
224 IsTimedEvent: true,
225 },
226 EvProcStatus: {
227 Name: "ProcStatus",
228 Args: []string{"dt", "p", "pstatus"},
229 IsTimedEvent: true,
230 },
231 EvGoCreate: {
232 Name: "GoCreate",
233 Args: []string{"dt", "new_g", "new_stack", "stack"},
234 IsTimedEvent: true,
235 StackIDs: []int{3, 2},
236 },
237 EvGoCreateSyscall: {
238 Name: "GoCreateSyscall",
239 Args: []string{"dt", "new_g"},
240 IsTimedEvent: true,
241 },
242 EvGoStart: {
243 Name: "GoStart",
244 Args: []string{"dt", "g", "g_seq"},
245 IsTimedEvent: true,
246 },
247 EvGoDestroy: {
248 Name: "GoDestroy",
249 Args: []string{"dt"},
250 IsTimedEvent: true,
251 },
252 EvGoDestroySyscall: {
253 Name: "GoDestroySyscall",
254 Args: []string{"dt"},
255 IsTimedEvent: true,
256 },
257 EvGoStop: {
258 Name: "GoStop",
259 Args: []string{"dt", "reason_string", "stack"},
260 IsTimedEvent: true,
261 StackIDs: []int{2},
262 StringIDs: []int{1},
263 },
264 EvGoBlock: {
265 Name: "GoBlock",
266 Args: []string{"dt", "reason_string", "stack"},
267 IsTimedEvent: true,
268 StackIDs: []int{2},
269 StringIDs: []int{1},
270 },
271 EvGoUnblock: {
272 Name: "GoUnblock",
273 Args: []string{"dt", "g", "g_seq", "stack"},
274 IsTimedEvent: true,
275 StackIDs: []int{3},
276 },
277 EvGoSyscallBegin: {
278 Name: "GoSyscallBegin",
279 Args: []string{"dt", "p_seq", "stack"},
280 IsTimedEvent: true,
281 StackIDs: []int{2},
282 },
283 EvGoSyscallEnd: {
284 Name: "GoSyscallEnd",
285 Args: []string{"dt"},
286 StartEv: EvGoSyscallBegin,
287 IsTimedEvent: true,
288 },
289 EvGoSyscallEndBlocked: {
290 Name: "GoSyscallEndBlocked",
291 Args: []string{"dt"},
292 StartEv: EvGoSyscallBegin,
293 IsTimedEvent: true,
294 },
295 EvGoStatus: {
296 Name: "GoStatus",
297 Args: []string{"dt", "g", "m", "gstatus"},
298 IsTimedEvent: true,
299 },
300 EvSTWBegin: {
301 Name: "STWBegin",
302 Args: []string{"dt", "kind_string", "stack"},
303 IsTimedEvent: true,
304 StackIDs: []int{2},
305 StringIDs: []int{1},
306 },
307 EvSTWEnd: {
308 Name: "STWEnd",
309 Args: []string{"dt"},
310 StartEv: EvSTWBegin,
311 IsTimedEvent: true,
312 },
313 EvGCActive: {
314 Name: "GCActive",
315 Args: []string{"dt", "gc_seq"},
316 IsTimedEvent: true,
317 StartEv: EvGCBegin,
318 },
319 EvGCBegin: {
320 Name: "GCBegin",
321 Args: []string{"dt", "gc_seq", "stack"},
322 IsTimedEvent: true,
323 StackIDs: []int{2},
324 },
325 EvGCEnd: {
326 Name: "GCEnd",
327 Args: []string{"dt", "gc_seq"},
328 StartEv: EvGCBegin,
329 IsTimedEvent: true,
330 },
331 EvGCSweepActive: {
332 Name: "GCSweepActive",
333 Args: []string{"dt", "p"},
334 StartEv: EvGCSweepBegin,
335 IsTimedEvent: true,
336 },
337 EvGCSweepBegin: {
338 Name: "GCSweepBegin",
339 Args: []string{"dt", "stack"},
340 IsTimedEvent: true,
341 StackIDs: []int{1},
342 },
343 EvGCSweepEnd: {
344 Name: "GCSweepEnd",
345 Args: []string{"dt", "swept_value", "reclaimed_value"},
346 StartEv: EvGCSweepBegin,
347 IsTimedEvent: true,
348 },
349 EvGCMarkAssistActive: {
350 Name: "GCMarkAssistActive",
351 Args: []string{"dt", "g"},
352 StartEv: EvGCMarkAssistBegin,
353 IsTimedEvent: true,
354 },
355 EvGCMarkAssistBegin: {
356 Name: "GCMarkAssistBegin",
357 Args: []string{"dt", "stack"},
358 IsTimedEvent: true,
359 StackIDs: []int{1},
360 },
361 EvGCMarkAssistEnd: {
362 Name: "GCMarkAssistEnd",
363 Args: []string{"dt"},
364 StartEv: EvGCMarkAssistBegin,
365 IsTimedEvent: true,
366 },
367 EvHeapAlloc: {
368 Name: "HeapAlloc",
369 Args: []string{"dt", "heapalloc_value"},
370 IsTimedEvent: true,
371 },
372 EvHeapGoal: {
373 Name: "HeapGoal",
374 Args: []string{"dt", "heapgoal_value"},
375 IsTimedEvent: true,
376 },
377 EvGoLabel: {
378 Name: "GoLabel",
379 Args: []string{"dt", "label_string"},
380 IsTimedEvent: true,
381 StringIDs: []int{1},
382 },
383 EvUserTaskBegin: {
384 Name: "UserTaskBegin",
385 Args: []string{"dt", "task", "parent_task", "name_string", "stack"},
386 IsTimedEvent: true,
387 StackIDs: []int{4},
388 StringIDs: []int{3},
389 },
390 EvUserTaskEnd: {
391 Name: "UserTaskEnd",
392 Args: []string{"dt", "task", "stack"},
393 IsTimedEvent: true,
394 StackIDs: []int{2},
395 },
396 EvUserRegionBegin: {
397 Name: "UserRegionBegin",
398 Args: []string{"dt", "task", "name_string", "stack"},
399 IsTimedEvent: true,
400 StackIDs: []int{3},
401 StringIDs: []int{2},
402 },
403 EvUserRegionEnd: {
404 Name: "UserRegionEnd",
405 Args: []string{"dt", "task", "name_string", "stack"},
406 StartEv: EvUserRegionBegin,
407 IsTimedEvent: true,
408 StackIDs: []int{3},
409 StringIDs: []int{2},
410 },
411 EvUserLog: {
412 Name: "UserLog",
413 Args: []string{"dt", "task", "key_string", "value_string", "stack"},
414 IsTimedEvent: true,
415 StackIDs: []int{4},
416 StringIDs: []int{2, 3},
417 },
418 EvGoSwitch: {
419 Name: "GoSwitch",
420 Args: []string{"dt", "g", "g_seq"},
421 IsTimedEvent: true,
422 },
423 EvGoSwitchDestroy: {
424 Name: "GoSwitchDestroy",
425 Args: []string{"dt", "g", "g_seq"},
426 IsTimedEvent: true,
427 },
428 EvGoCreateBlocked: {
429 Name: "GoCreateBlocked",
430 Args: []string{"dt", "new_g", "new_stack", "stack"},
431 IsTimedEvent: true,
432 StackIDs: []int{3, 2},
433 },
434 EvGoStatusStack: {
435 Name: "GoStatusStack",
436 Args: []string{"dt", "g", "m", "gstatus", "stack"},
437 IsTimedEvent: true,
438 StackIDs: []int{4},
439 },
440 EvClockSnapshot: {
441 Name: "ClockSnapshot",
442 Args: []string{"dt", "mono", "sec", "nsec"},
443 IsTimedEvent: true,
444 },
445
446 // Experimental events.
447
448 EvSpan: {
449 Name: "Span",
450 Args: []string{"dt", "id", "npages_value", "kindclass"},
451 IsTimedEvent: true,
452 Experiment: AllocFree,
453 },
454 EvSpanAlloc: {
455 Name: "SpanAlloc",
456 Args: []string{"dt", "id", "npages_value", "kindclass"},
457 IsTimedEvent: true,
458 Experiment: AllocFree,
459 },
460 EvSpanFree: {
461 Name: "SpanFree",
462 Args: []string{"dt", "id"},
463 IsTimedEvent: true,
464 Experiment: AllocFree,
465 },
466 EvHeapObject: {
467 Name: "HeapObject",
468 Args: []string{"dt", "id", "type"},
469 IsTimedEvent: true,
470 Experiment: AllocFree,
471 },
472 EvHeapObjectAlloc: {
473 Name: "HeapObjectAlloc",
474 Args: []string{"dt", "id", "type"},
475 IsTimedEvent: true,
476 Experiment: AllocFree,
477 },
478 EvHeapObjectFree: {
479 Name: "HeapObjectFree",
480 Args: []string{"dt", "id"},
481 IsTimedEvent: true,
482 Experiment: AllocFree,
483 },
484 EvGoroutineStack: {
485 Name: "GoroutineStack",
486 Args: []string{"dt", "id", "order"},
487 IsTimedEvent: true,
488 Experiment: AllocFree,
489 },
490 EvGoroutineStackAlloc: {
491 Name: "GoroutineStackAlloc",
492 Args: []string{"dt", "id", "order"},
493 IsTimedEvent: true,
494 Experiment: AllocFree,
495 },
496 EvGoroutineStackFree: {
497 Name: "GoroutineStackFree",
498 Args: []string{"dt", "id"},
499 IsTimedEvent: true,
500 Experiment: AllocFree,
501 },
502 }
503
504 // GoStatus is the status of a goroutine.
505 //
506 // They correspond directly to the various goroutine states.
507 type GoStatus uint8
508
509 const (
510 GoBad GoStatus = iota
511 GoRunnable
512 GoRunning
513 GoSyscall
514 GoWaiting
515 )
516
517 func (s GoStatus) String() string {
518 switch s {
519 case GoRunnable:
520 return "Runnable"
521 case GoRunning:
522 return "Running"
523 case GoSyscall:
524 return "Syscall"
525 case GoWaiting:
526 return "Waiting"
527 }
528 return "Bad"
529 }
530
531 // ProcStatus is the status of a P.
532 //
533 // They mostly correspond to the various P states.
534 type ProcStatus uint8
535
536 const (
537 ProcBad ProcStatus = iota
538 ProcRunning
539 ProcIdle
540 ProcSyscall
541
542 // ProcSyscallAbandoned is a special case of
543 // ProcSyscall. It's used in the very specific case
544 // where the first a P is mentioned in a generation is
545 // part of a ProcSteal event. If that's the first time
546 // it's mentioned, then there's no GoSyscallBegin to
547 // connect the P stealing back to at that point. This
548 // special state indicates this to the parser, so it
549 // doesn't try to find a GoSyscallEndBlocked that
550 // corresponds with the ProcSteal.
551 ProcSyscallAbandoned
552 )
553
554 func (s ProcStatus) String() string {
555 switch s {
556 case ProcRunning:
557 return "Running"
558 case ProcIdle:
559 return "Idle"
560 case ProcSyscall:
561 return "Syscall"
562 }
563 return "Bad"
564 }
565
566 const (
567 // MaxBatchSize sets the maximum size that a batch can be.
568 //
569 // Directly controls the trace batch size in the runtime.
570 //
571 // NOTE: If this number decreases, the trace format version must change.
572 MaxBatchSize = 64 << 10
573
574 // Maximum number of PCs in a single stack trace.
575 //
576 // Since events contain only stack ID rather than whole stack trace,
577 // we can allow quite large values here.
578 //
579 // Directly controls the maximum number of frames per stack
580 // in the runtime.
581 //
582 // NOTE: If this number decreases, the trace format version must change.
583 MaxFramesPerStack = 128
584
585 // MaxEventTrailerDataSize controls the amount of trailer data that
586 // an event can have in bytes. Must be smaller than MaxBatchSize.
587 // Controls the maximum string size in the trace.
588 //
589 // Directly controls the maximum such value in the runtime.
590 //
591 // NOTE: If this number decreases, the trace format version must change.
592 MaxEventTrailerDataSize = 1 << 10
593 )