1
2
3
4
5 package go122
6
7 import (
8 "fmt"
9 "internal/trace/v2/event"
10 )
11
12 const (
13 EvNone event.Type = iota
14
15
16 EvEventBatch
17 EvStacks
18 EvStack
19 EvStrings
20 EvString
21 EvCPUSamples
22 EvCPUSample
23 EvFrequency
24
25
26 EvProcsChange
27 EvProcStart
28 EvProcStop
29 EvProcSteal
30 EvProcStatus
31
32
33 EvGoCreate
34 EvGoCreateSyscall
35 EvGoStart
36 EvGoDestroy
37 EvGoDestroySyscall
38 EvGoStop
39 EvGoBlock
40 EvGoUnblock
41 EvGoSyscallBegin
42 EvGoSyscallEnd
43 EvGoSyscallEndBlocked
44 EvGoStatus
45
46
47 EvSTWBegin
48 EvSTWEnd
49
50
51 EvGCActive
52 EvGCBegin
53 EvGCEnd
54 EvGCSweepActive
55 EvGCSweepBegin
56 EvGCSweepEnd
57 EvGCMarkAssistActive
58 EvGCMarkAssistBegin
59 EvGCMarkAssistEnd
60 EvHeapAlloc
61 EvHeapGoal
62
63
64 EvGoLabel
65 EvUserTaskBegin
66 EvUserTaskEnd
67 EvUserRegionBegin
68 EvUserRegionEnd
69 EvUserLog
70 )
71
72
73 func EventString(typ event.Type) string {
74 if int(typ) < len(specs) {
75 return specs[typ].Name
76 }
77 return fmt.Sprintf("Invalid(%d)", typ)
78 }
79
80 func Specs() []event.Spec {
81 return specs[:]
82 }
83
84 var specs = [...]event.Spec{
85
86 EvEventBatch: event.Spec{
87 Name: "EventBatch",
88 Args: []string{"gen", "m", "time", "size"},
89 },
90 EvStacks: event.Spec{
91 Name: "Stacks",
92 },
93 EvStack: event.Spec{
94 Name: "Stack",
95 Args: []string{"id", "nframes"},
96 IsStack: true,
97 },
98 EvStrings: event.Spec{
99 Name: "Strings",
100 },
101 EvString: event.Spec{
102 Name: "String",
103 Args: []string{"id"},
104 HasData: true,
105 },
106 EvCPUSamples: event.Spec{
107 Name: "CPUSamples",
108 },
109 EvCPUSample: event.Spec{
110 Name: "CPUSample",
111 Args: []string{"time", "p", "g", "m", "stack"},
112
113
114
115 },
116 EvFrequency: event.Spec{
117 Name: "Frequency",
118 Args: []string{"freq"},
119 },
120
121
122 EvProcsChange: event.Spec{
123 Name: "ProcsChange",
124 Args: []string{"dt", "procs_value", "stack"},
125 IsTimedEvent: true,
126 StackIDs: []int{2},
127 },
128 EvProcStart: event.Spec{
129 Name: "ProcStart",
130 Args: []string{"dt", "p", "p_seq"},
131 IsTimedEvent: true,
132 },
133 EvProcStop: event.Spec{
134 Name: "ProcStop",
135 Args: []string{"dt"},
136 IsTimedEvent: true,
137 },
138 EvProcSteal: event.Spec{
139 Name: "ProcSteal",
140 Args: []string{"dt", "p", "p_seq", "m"},
141 IsTimedEvent: true,
142 },
143 EvProcStatus: event.Spec{
144 Name: "ProcStatus",
145 Args: []string{"dt", "p", "pstatus"},
146 IsTimedEvent: true,
147 },
148 EvGoCreate: event.Spec{
149 Name: "GoCreate",
150 Args: []string{"dt", "new_g", "new_stack", "stack"},
151 IsTimedEvent: true,
152 StackIDs: []int{3, 2},
153 },
154 EvGoCreateSyscall: event.Spec{
155 Name: "GoCreateSyscall",
156 Args: []string{"dt", "new_g"},
157 IsTimedEvent: true,
158 },
159 EvGoStart: event.Spec{
160 Name: "GoStart",
161 Args: []string{"dt", "g", "g_seq"},
162 IsTimedEvent: true,
163 },
164 EvGoDestroy: event.Spec{
165 Name: "GoDestroy",
166 Args: []string{"dt"},
167 IsTimedEvent: true,
168 },
169 EvGoDestroySyscall: event.Spec{
170 Name: "GoDestroySyscall",
171 Args: []string{"dt"},
172 IsTimedEvent: true,
173 },
174 EvGoStop: event.Spec{
175 Name: "GoStop",
176 Args: []string{"dt", "reason_string", "stack"},
177 IsTimedEvent: true,
178 StackIDs: []int{2},
179 StringIDs: []int{1},
180 },
181 EvGoBlock: event.Spec{
182 Name: "GoBlock",
183 Args: []string{"dt", "reason_string", "stack"},
184 IsTimedEvent: true,
185 StackIDs: []int{2},
186 StringIDs: []int{1},
187 },
188 EvGoUnblock: event.Spec{
189 Name: "GoUnblock",
190 Args: []string{"dt", "g", "g_seq", "stack"},
191 IsTimedEvent: true,
192 StackIDs: []int{3},
193 },
194 EvGoSyscallBegin: event.Spec{
195 Name: "GoSyscallBegin",
196 Args: []string{"dt", "p_seq", "stack"},
197 IsTimedEvent: true,
198 StackIDs: []int{2},
199 },
200 EvGoSyscallEnd: event.Spec{
201 Name: "GoSyscallEnd",
202 Args: []string{"dt"},
203 StartEv: EvGoSyscallBegin,
204 IsTimedEvent: true,
205 },
206 EvGoSyscallEndBlocked: event.Spec{
207 Name: "GoSyscallEndBlocked",
208 Args: []string{"dt"},
209 StartEv: EvGoSyscallBegin,
210 IsTimedEvent: true,
211 },
212 EvGoStatus: event.Spec{
213 Name: "GoStatus",
214 Args: []string{"dt", "g", "m", "gstatus"},
215 IsTimedEvent: true,
216 },
217 EvSTWBegin: event.Spec{
218 Name: "STWBegin",
219 Args: []string{"dt", "kind_string", "stack"},
220 IsTimedEvent: true,
221 StackIDs: []int{2},
222 StringIDs: []int{1},
223 },
224 EvSTWEnd: event.Spec{
225 Name: "STWEnd",
226 Args: []string{"dt"},
227 StartEv: EvSTWBegin,
228 IsTimedEvent: true,
229 },
230 EvGCActive: event.Spec{
231 Name: "GCActive",
232 Args: []string{"dt", "gc_seq"},
233 IsTimedEvent: true,
234 StartEv: EvGCBegin,
235 },
236 EvGCBegin: event.Spec{
237 Name: "GCBegin",
238 Args: []string{"dt", "gc_seq", "stack"},
239 IsTimedEvent: true,
240 StackIDs: []int{2},
241 },
242 EvGCEnd: event.Spec{
243 Name: "GCEnd",
244 Args: []string{"dt", "gc_seq"},
245 StartEv: EvGCBegin,
246 IsTimedEvent: true,
247 },
248 EvGCSweepActive: event.Spec{
249 Name: "GCSweepActive",
250 Args: []string{"dt", "p"},
251 StartEv: EvGCSweepBegin,
252 IsTimedEvent: true,
253 },
254 EvGCSweepBegin: event.Spec{
255 Name: "GCSweepBegin",
256 Args: []string{"dt", "stack"},
257 IsTimedEvent: true,
258 StackIDs: []int{1},
259 },
260 EvGCSweepEnd: event.Spec{
261 Name: "GCSweepEnd",
262 Args: []string{"dt", "swept_value", "reclaimed_value"},
263 StartEv: EvGCSweepBegin,
264 IsTimedEvent: true,
265 },
266 EvGCMarkAssistActive: event.Spec{
267 Name: "GCMarkAssistActive",
268 Args: []string{"dt", "g"},
269 StartEv: EvGCMarkAssistBegin,
270 IsTimedEvent: true,
271 },
272 EvGCMarkAssistBegin: event.Spec{
273 Name: "GCMarkAssistBegin",
274 Args: []string{"dt", "stack"},
275 IsTimedEvent: true,
276 StackIDs: []int{1},
277 },
278 EvGCMarkAssistEnd: event.Spec{
279 Name: "GCMarkAssistEnd",
280 Args: []string{"dt"},
281 StartEv: EvGCMarkAssistBegin,
282 IsTimedEvent: true,
283 },
284 EvHeapAlloc: event.Spec{
285 Name: "HeapAlloc",
286 Args: []string{"dt", "heapalloc_value"},
287 IsTimedEvent: true,
288 },
289 EvHeapGoal: event.Spec{
290 Name: "HeapGoal",
291 Args: []string{"dt", "heapgoal_value"},
292 IsTimedEvent: true,
293 },
294 EvGoLabel: event.Spec{
295 Name: "GoLabel",
296 Args: []string{"dt", "label_string"},
297 IsTimedEvent: true,
298 StringIDs: []int{1},
299 },
300 EvUserTaskBegin: event.Spec{
301 Name: "UserTaskBegin",
302 Args: []string{"dt", "task", "parent_task", "name_string", "stack"},
303 IsTimedEvent: true,
304 StackIDs: []int{4},
305 StringIDs: []int{3},
306 },
307 EvUserTaskEnd: event.Spec{
308 Name: "UserTaskEnd",
309 Args: []string{"dt", "task", "stack"},
310 IsTimedEvent: true,
311 StackIDs: []int{2},
312 },
313 EvUserRegionBegin: event.Spec{
314 Name: "UserRegionBegin",
315 Args: []string{"dt", "task", "name_string", "stack"},
316 IsTimedEvent: true,
317 StackIDs: []int{3},
318 StringIDs: []int{2},
319 },
320 EvUserRegionEnd: event.Spec{
321 Name: "UserRegionEnd",
322 Args: []string{"dt", "task", "name_string", "stack"},
323 StartEv: EvUserRegionBegin,
324 IsTimedEvent: true,
325 StackIDs: []int{3},
326 StringIDs: []int{2},
327 },
328 EvUserLog: event.Spec{
329 Name: "UserLog",
330 Args: []string{"dt", "task", "key_string", "value_string", "stack"},
331 IsTimedEvent: true,
332 StackIDs: []int{4},
333 StringIDs: []int{2, 3},
334 },
335 }
336
337 type GoStatus uint8
338
339 const (
340 GoBad GoStatus = iota
341 GoRunnable
342 GoRunning
343 GoSyscall
344 GoWaiting
345 )
346
347 func (s GoStatus) String() string {
348 switch s {
349 case GoRunnable:
350 return "Runnable"
351 case GoRunning:
352 return "Running"
353 case GoSyscall:
354 return "Syscall"
355 case GoWaiting:
356 return "Waiting"
357 }
358 return "Bad"
359 }
360
361 type ProcStatus uint8
362
363 const (
364 ProcBad ProcStatus = iota
365 ProcRunning
366 ProcIdle
367 ProcSyscall
368 ProcSyscallAbandoned
369 )
370
371 func (s ProcStatus) String() string {
372 switch s {
373 case ProcRunning:
374 return "Running"
375 case ProcIdle:
376 return "Idle"
377 case ProcSyscall:
378 return "Syscall"
379 }
380 return "Bad"
381 }
382
383 const (
384
385 MaxBatchSize = 64 << 10
386 MaxFramesPerStack = 128
387 MaxStringSize = 1 << 10
388 )
389
View as plain text