forked from firefox-devtools/profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gecko-profile.js
176 lines (162 loc) · 4.43 KB
/
gecko-profile.js
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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// @flow
import type { Lib, IndexIntoStringTable, PausedRange } from './profile';
import type { MarkerPayload_Gecko } from './markers';
import type { Milliseconds } from './units';
export type IndexIntoGeckoFrameTable = number;
export type IndexIntoGeckoStackTable = number;
export type GeckoMarkers = {
schema: { name: 0, time: 1, data: 2 },
data: Array<[IndexIntoStringTable, Milliseconds, MarkerPayload_Gecko]>,
};
/**
* These structs aren't very DRY, but it is a simple and complete approach.
* These structs are the initial transformation of the Gecko data to the
* processed format.
*/
export type GeckoMarkerStruct = {
name: IndexIntoStringTable[],
time: Milliseconds[],
data: MarkerPayload_Gecko[],
length: number,
};
export type GeckoMarkerStack = {
name: 'SyncProfile',
registerTime: null,
unregisterTime: null,
processType: string,
tid: number,
pid: number,
markers: GeckoMarkers,
samples: GeckoSamples,
};
export type GeckoSamples = {
schema: {
stack: 0,
time: 1,
responsiveness: 2,
rss: 3,
uss: 4,
},
data: Array<
[
null | IndexIntoGeckoStackTable,
Milliseconds, // since profile.meta.startTime
// milliseconds since the last event was processed in this
// thread's event loop at the time that the sample was taken
Milliseconds,
any, // TODO
any, // TODO
]
>,
};
export type GeckoSampleStruct = {
stack: Array<null | IndexIntoGeckoStackTable>,
time: Milliseconds[],
responsiveness: Milliseconds[],
rss: any[],
uss: any[],
length: number,
};
export type GeckoFrameTable = {
schema: {
location: 0,
implementation: 1,
optimizations: 2,
line: 3,
category: 4,
},
data: Array<
[
// index into stringTable, points to strings like:
// JS: "Startup::XRE_Main"
// C++: "0x7fff7d962da1"
IndexIntoStringTable,
// for JS frames, an index into the string table, usually "Baseline" or "Ion"
null | IndexIntoStringTable,
// JSON info about JIT optimizations.
null | Object,
// The line of code
null | number,
// int bitmask of the category
// 16 - js::ProfileEntry::Category::OTHER
// 32 - js::ProfileEntry::Category::CSS
// 64 - js::ProfileEntry::Category::JS
// 128 - js::ProfileEntry::Category::GC
// 256 - js::ProfileEntry::Category::CC
// 512 - js::ProfileEntry::Category::NETWORK
// 1024 - js::ProfileEntry::Category::GRAPHICS
// 2048 - js::ProfileEntry::Category::STORAGE
// 4096 - js::ProfileEntry::Category::EVENTS
// 9000 - other non-bitmask category
null | number,
]
>,
};
export type GeckoFrameStruct = {
location: IndexIntoStringTable[],
implementation: Array<null | IndexIntoStringTable>,
optimizations: Array<null | Object>,
line: Array<null | number>,
category: Array<null | number>,
length: number,
};
export type GeckoStackTable = {
schema: {
frame: 0,
prefix: 1,
},
data: Array<[IndexIntoGeckoFrameTable, IndexIntoGeckoStackTable | null]>,
};
export type GeckoStackStruct = {
frame: IndexIntoGeckoFrameTable[],
prefix: Array<IndexIntoGeckoStackTable | null>,
length: number,
};
export type GeckoThread = {
name: string,
registerTime: number,
processType: string,
unregisterTime: number | null,
tid: number,
pid: number,
markers: GeckoMarkers,
samples: GeckoSamples,
frameTable: GeckoFrameTable,
stackTable: GeckoStackTable,
stringTable: string[],
};
export type GeckoExtensionMeta = {|
schema: {|
id: 0,
name: 1,
baseURL: 2,
|},
data: Array<[string, string, string]>,
|};
export type GeckoProfile = {|
meta: {|
interval: Milliseconds,
startTime: Milliseconds,
shutdownTime: Milliseconds | null,
abi: string,
// The extensions property landed in Firefox 60, and is only optional because
// older profile versions may not have it. No upgrader was written for this change.
extensions?: GeckoExtensionMeta,
misc: string,
oscpu: string,
platform: string,
processType: number,
product: string,
stackwalk: number,
toolkit: string,
version: number,
|},
libs: Lib[],
threads: GeckoThread[],
pausedRanges: PausedRange[],
tasktracer?: Object,
processes: GeckoProfile[],
|};