1
2
3
4
5 package tracev2
6
7
8
9
10
11
12
13
14
15
16 const (
17 EvNone EventType = iota
18
19
20 EvEventBatch
21 EvStacks
22 EvStack
23 EvStrings
24 EvString
25 EvCPUSamples
26 EvCPUSample
27 EvFrequency
28
29
30 EvProcsChange
31 EvProcStart
32 EvProcStop
33 EvProcSteal
34 EvProcStatus
35
36
37 EvGoCreate
38 EvGoCreateSyscall
39 EvGoStart
40 EvGoDestroy
41 EvGoDestroySyscall
42 EvGoStop
43 EvGoBlock
44 EvGoUnblock
45 EvGoSyscallBegin
46 EvGoSyscallEnd
47 EvGoSyscallEndBlocked
48 EvGoStatus
49
50
51 EvSTWBegin
52 EvSTWEnd
53
54
55 EvGCActive
56 EvGCBegin
57 EvGCEnd
58 EvGCSweepActive
59 EvGCSweepBegin
60 EvGCSweepEnd
61 EvGCMarkAssistActive
62 EvGCMarkAssistBegin
63 EvGCMarkAssistEnd
64 EvHeapAlloc
65 EvHeapGoal
66
67
68 EvGoLabel
69 EvUserTaskBegin
70 EvUserTaskEnd
71 EvUserRegionBegin
72 EvUserRegionEnd
73 EvUserLog
74
75
76 EvGoSwitch
77 EvGoSwitchDestroy
78 EvGoCreateBlocked
79
80
81 EvGoStatusStack
82
83
84 EvExperimentalBatch
85
86
87 EvSync
88 EvClockSnapshot
89
90
91
92 EvEndOfGeneration
93
94 NumEvents
95 )
96
97 func (ev EventType) Experimental() bool {
98 return ev > MaxEvent && ev < MaxExperimentalEvent
99 }
100
101
102 const (
103
104 AllocFree Experiment = 1 + iota
105
106 NumExperiments
107 )
108
109 func Experiments() []string {
110 return experiments[:]
111 }
112
113 var experiments = [...]string{
114 NoExperiment: "None",
115 AllocFree: "AllocFree",
116 }
117
118
119 const (
120 MaxEvent EventType = 127 + iota
121
122
123
124
125 EvSpan
126 EvSpanAlloc
127 EvSpanFree
128
129
130 EvHeapObject
131 EvHeapObjectAlloc
132 EvHeapObjectFree
133
134
135 EvGoroutineStack
136 EvGoroutineStackAlloc
137 EvGoroutineStackFree
138
139 MaxExperimentalEvent
140 )
141
142 const NumExperimentalEvents = MaxExperimentalEvent - MaxEvent
143
144
145 const MaxTimedEventArgs = 5
146
147 func Specs() []EventSpec {
148 return specs[:]
149 }
150
151 var specs = [...]EventSpec{
152
153 EvEventBatch: {
154 Name: "EventBatch",
155 Args: []string{"gen", "m", "time", "size"},
156 },
157 EvStacks: {
158 Name: "Stacks",
159 },
160 EvStack: {
161 Name: "Stack",
162 Args: []string{"id", "nframes"},
163 IsStack: true,
164 },
165 EvStrings: {
166 Name: "Strings",
167 },
168 EvString: {
169 Name: "String",
170 Args: []string{"id"},
171 HasData: true,
172 },
173 EvCPUSamples: {
174 Name: "CPUSamples",
175 },
176 EvCPUSample: {
177 Name: "CPUSample",
178 Args: []string{"time", "m", "p", "g", "stack"},
179
180
181
182 StackIDs: []int{4},
183 },
184 EvFrequency: {
185 Name: "Frequency",
186 Args: []string{"freq"},
187 },
188 EvExperimentalBatch: {
189 Name: "ExperimentalBatch",
190 Args: []string{"exp", "gen", "m", "time"},
191 HasData: true,
192 },
193 EvSync: {
194 Name: "Sync",
195 },
196 EvEndOfGeneration: {
197 Name: "EndOfGeneration",
198 },
199
200
201 EvProcsChange: {
202 Name: "ProcsChange",
203 Args: []string{"dt", "procs_value", "stack"},
204 IsTimedEvent: true,
205 StackIDs: []int{2},
206 },
207 EvProcStart: {
208 Name: "ProcStart",
209 Args: []string{"dt", "p", "p_seq"},
210 IsTimedEvent: true,
211 },
212 EvProcStop: {
213 Name: "ProcStop",
214 Args: []string{"dt"},
215 IsTimedEvent: true,
216 },
217 EvProcSteal: {
218 Name: "ProcSteal",
219 Args: []string{"dt", "p", "p_seq", "m"},
220 IsTimedEvent: true,
221 },
222 EvProcStatus: {
223 Name: "ProcStatus",
224 Args: []string{"dt", "p", "pstatus"},
225 IsTimedEvent: true,
226 },
227 EvGoCreate: {
228 Name: "GoCreate",
229 Args: []string{"dt", "new_g", "new_stack", "stack"},
230 IsTimedEvent: true,
231 StackIDs: []int{3, 2},
232 },
233 EvGoCreateSyscall: {
234 Name: "GoCreateSyscall",
235 Args: []string{"dt", "new_g"},
236 IsTimedEvent: true,
237 },
238 EvGoStart: {
239 Name: "GoStart",
240 Args: []string{"dt", "g", "g_seq"},
241 IsTimedEvent: true,
242 },
243 EvGoDestroy: {
244 Name: "GoDestroy",
245 Args: []string{"dt"},
246 IsTimedEvent: true,
247 },
248 EvGoDestroySyscall: {
249 Name: "GoDestroySyscall",
250 Args: []string{"dt"},
251 IsTimedEvent: true,
252 },
253 EvGoStop: {
254 Name: "GoStop",
255 Args: []string{"dt", "reason_string", "stack"},
256 IsTimedEvent: true,
257 StackIDs: []int{2},
258 StringIDs: []int{1},
259 },
260 EvGoBlock: {
261 Name: "GoBlock",
262 Args: []string{"dt", "reason_string", "stack"},
263 IsTimedEvent: true,
264 StackIDs: []int{2},
265 StringIDs: []int{1},
266 },
267 EvGoUnblock: {
268 Name: "GoUnblock",
269 Args: []string{"dt", "g", "g_seq", "stack"},
270 IsTimedEvent: true,
271 StackIDs: []int{3},
272 },
273 EvGoSyscallBegin: {
274 Name: "GoSyscallBegin",
275 Args: []string{"dt", "p_seq", "stack"},
276 IsTimedEvent: true,
277 StackIDs: []int{2},
278 },
279 EvGoSyscallEnd: {
280 Name: "GoSyscallEnd",
281 Args: []string{"dt"},
282 StartEv: EvGoSyscallBegin,
283 IsTimedEvent: true,
284 },
285 EvGoSyscallEndBlocked: {
286 Name: "GoSyscallEndBlocked",
287 Args: []string{"dt"},
288 StartEv: EvGoSyscallBegin,
289 IsTimedEvent: true,
290 },
291 EvGoStatus: {
292 Name: "GoStatus",
293 Args: []string{"dt", "g", "m", "gstatus"},
294 IsTimedEvent: true,
295 },
296 EvSTWBegin: {
297 Name: "STWBegin",
298 Args: []string{"dt", "kind_string", "stack"},
299 IsTimedEvent: true,
300 StackIDs: []int{2},
301 StringIDs: []int{1},
302 },
303 EvSTWEnd: {
304 Name: "STWEnd",
305 Args: []string{"dt"},
306 StartEv: EvSTWBegin,
307 IsTimedEvent: true,
308 },
309 EvGCActive: {
310 Name: "GCActive",
311 Args: []string{"dt", "gc_seq"},
312 IsTimedEvent: true,
313 StartEv: EvGCBegin,
314 },
315 EvGCBegin: {
316 Name: "GCBegin",
317 Args: []string{"dt", "gc_seq", "stack"},
318 IsTimedEvent: true,
319 StackIDs: []int{2},
320 },
321 EvGCEnd: {
322 Name: "GCEnd",
323 Args: []string{"dt", "gc_seq"},
324 StartEv: EvGCBegin,
325 IsTimedEvent: true,
326 },
327 EvGCSweepActive: {
328 Name: "GCSweepActive",
329 Args: []string{"dt", "p"},
330 StartEv: EvGCSweepBegin,
331 IsTimedEvent: true,
332 },
333 EvGCSweepBegin: {
334 Name: "GCSweepBegin",
335 Args: []string{"dt", "stack"},
336 IsTimedEvent: true,
337 StackIDs: []int{1},
338 },
339 EvGCSweepEnd: {
340 Name: "GCSweepEnd",
341 Args: []string{"dt", "swept_value", "reclaimed_value"},
342 StartEv: EvGCSweepBegin,
343 IsTimedEvent: true,
344 },
345 EvGCMarkAssistActive: {
346 Name: "GCMarkAssistActive",
347 Args: []string{"dt", "g"},
348 StartEv: EvGCMarkAssistBegin,
349 IsTimedEvent: true,
350 },
351 EvGCMarkAssistBegin: {
352 Name: "GCMarkAssistBegin",
353 Args: []string{"dt", "stack"},
354 IsTimedEvent: true,
355 StackIDs: []int{1},
356 },
357 EvGCMarkAssistEnd: {
358 Name: "GCMarkAssistEnd",
359 Args: []string{"dt"},
360 StartEv: EvGCMarkAssistBegin,
361 IsTimedEvent: true,
362 },
363 EvHeapAlloc: {
364 Name: "HeapAlloc",
365 Args: []string{"dt", "heapalloc_value"},
366 IsTimedEvent: true,
367 },
368 EvHeapGoal: {
369 Name: "HeapGoal",
370 Args: []string{"dt", "heapgoal_value"},
371 IsTimedEvent: true,
372 },
373 EvGoLabel: {
374 Name: "GoLabel",
375 Args: []string{"dt", "label_string"},
376 IsTimedEvent: true,
377 StringIDs: []int{1},
378 },
379 EvUserTaskBegin: {
380 Name: "UserTaskBegin",
381 Args: []string{"dt", "task", "parent_task", "name_string", "stack"},
382 IsTimedEvent: true,
383 StackIDs: []int{4},
384 StringIDs: []int{3},
385 },
386 EvUserTaskEnd: {
387 Name: "UserTaskEnd",
388 Args: []string{"dt", "task", "stack"},
389 IsTimedEvent: true,
390 StackIDs: []int{2},
391 },
392 EvUserRegionBegin: {
393 Name: "UserRegionBegin",
394 Args: []string{"dt", "task", "name_string", "stack"},
395 IsTimedEvent: true,
396 StackIDs: []int{3},
397 StringIDs: []int{2},
398 },
399 EvUserRegionEnd: {
400 Name: "UserRegionEnd",
401 Args: []string{"dt", "task", "name_string", "stack"},
402 StartEv: EvUserRegionBegin,
403 IsTimedEvent: true,
404 StackIDs: []int{3},
405 StringIDs: []int{2},
406 },
407 EvUserLog: {
408 Name: "UserLog",
409 Args: []string{"dt", "task", "key_string", "value_string", "stack"},
410 IsTimedEvent: true,
411 StackIDs: []int{4},
412 StringIDs: []int{2, 3},
413 },
414 EvGoSwitch: {
415 Name: "GoSwitch",
416 Args: []string{"dt", "g", "g_seq"},
417 IsTimedEvent: true,
418 },
419 EvGoSwitchDestroy: {
420 Name: "GoSwitchDestroy",
421 Args: []string{"dt", "g", "g_seq"},
422 IsTimedEvent: true,
423 },
424 EvGoCreateBlocked: {
425 Name: "GoCreateBlocked",
426 Args: []string{"dt", "new_g", "new_stack", "stack"},
427 IsTimedEvent: true,
428 StackIDs: []int{3, 2},
429 },
430 EvGoStatusStack: {
431 Name: "GoStatusStack",
432 Args: []string{"dt", "g", "m", "gstatus", "stack"},
433 IsTimedEvent: true,
434 StackIDs: []int{4},
435 },
436 EvClockSnapshot: {
437 Name: "ClockSnapshot",
438 Args: []string{"dt", "mono", "sec", "nsec"},
439 IsTimedEvent: true,
440 },
441
442
443
444 EvSpan: {
445 Name: "Span",
446 Args: []string{"dt", "id", "npages_value", "kindclass"},
447 IsTimedEvent: true,
448 Experiment: AllocFree,
449 },
450 EvSpanAlloc: {
451 Name: "SpanAlloc",
452 Args: []string{"dt", "id", "npages_value", "kindclass"},
453 IsTimedEvent: true,
454 Experiment: AllocFree,
455 },
456 EvSpanFree: {
457 Name: "SpanFree",
458 Args: []string{"dt", "id"},
459 IsTimedEvent: true,
460 Experiment: AllocFree,
461 },
462 EvHeapObject: {
463 Name: "HeapObject",
464 Args: []string{"dt", "id", "type"},
465 IsTimedEvent: true,
466 Experiment: AllocFree,
467 },
468 EvHeapObjectAlloc: {
469 Name: "HeapObjectAlloc",
470 Args: []string{"dt", "id", "type"},
471 IsTimedEvent: true,
472 Experiment: AllocFree,
473 },
474 EvHeapObjectFree: {
475 Name: "HeapObjectFree",
476 Args: []string{"dt", "id"},
477 IsTimedEvent: true,
478 Experiment: AllocFree,
479 },
480 EvGoroutineStack: {
481 Name: "GoroutineStack",
482 Args: []string{"dt", "id", "order"},
483 IsTimedEvent: true,
484 Experiment: AllocFree,
485 },
486 EvGoroutineStackAlloc: {
487 Name: "GoroutineStackAlloc",
488 Args: []string{"dt", "id", "order"},
489 IsTimedEvent: true,
490 Experiment: AllocFree,
491 },
492 EvGoroutineStackFree: {
493 Name: "GoroutineStackFree",
494 Args: []string{"dt", "id"},
495 IsTimedEvent: true,
496 Experiment: AllocFree,
497 },
498 }
499
500
501
502
503 type GoStatus uint8
504
505 const (
506 GoBad GoStatus = iota
507 GoRunnable
508 GoRunning
509 GoSyscall
510 GoWaiting
511 )
512
513 func (s GoStatus) String() string {
514 switch s {
515 case GoRunnable:
516 return "Runnable"
517 case GoRunning:
518 return "Running"
519 case GoSyscall:
520 return "Syscall"
521 case GoWaiting:
522 return "Waiting"
523 }
524 return "Bad"
525 }
526
527
528
529
530 type ProcStatus uint8
531
532 const (
533 ProcBad ProcStatus = iota
534 ProcRunning
535 ProcIdle
536 ProcSyscall
537
538
539
540
541
542
543
544
545
546
547 ProcSyscallAbandoned
548 )
549
550 func (s ProcStatus) String() string {
551 switch s {
552 case ProcRunning:
553 return "Running"
554 case ProcIdle:
555 return "Idle"
556 case ProcSyscall:
557 return "Syscall"
558 }
559 return "Bad"
560 }
561
562 const (
563
564
565
566
567
568 MaxBatchSize = 64 << 10
569
570
571
572
573
574
575
576
577
578
579 MaxFramesPerStack = 128
580
581
582
583
584
585
586
587
588 MaxEventTrailerDataSize = 1 << 10
589 )
590
View as plain text