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