@ohos-ports/datadog-pprof 5.17.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +112 -0
- package/out/src/heap-profiler-bindings.d.ts +22 -0
- package/out/src/heap-profiler-bindings.js +75 -0
- package/out/src/heap-profiler-bindings.js.map +1 -0
- package/out/src/heap-profiler.d.ts +98 -0
- package/out/src/heap-profiler.js +219 -0
- package/out/src/heap-profiler.js.map +1 -0
- package/out/src/index.d.ts +46 -0
- package/out/src/index.js +111 -0
- package/out/src/index.js.map +1 -0
- package/out/src/logger.d.ts +18 -0
- package/out/src/logger.js +36 -0
- package/out/src/logger.js.map +1 -0
- package/out/src/otel-thread-ctx.d.ts +85 -0
- package/out/src/otel-thread-ctx.js +176 -0
- package/out/src/otel-thread-ctx.js.map +1 -0
- package/out/src/profile-encoder.d.ts +18 -0
- package/out/src/profile-encoder.js +29 -0
- package/out/src/profile-encoder.js.map +1 -0
- package/out/src/profile-serializer.d.ts +56 -0
- package/out/src/profile-serializer.js +509 -0
- package/out/src/profile-serializer.js.map +1 -0
- package/out/src/sourcemapper/sourcemapper.d.ts +123 -0
- package/out/src/sourcemapper/sourcemapper.js +528 -0
- package/out/src/sourcemapper/sourcemapper.js.map +1 -0
- package/out/src/time-profiler-bindings.d.ts +3 -0
- package/out/src/time-profiler-bindings.js +25 -0
- package/out/src/time-profiler-bindings.js.map +1 -0
- package/out/src/time-profiler.d.ts +72 -0
- package/out/src/time-profiler.js +202 -0
- package/out/src/time-profiler.js.map +1 -0
- package/out/src/v8-types.d.ts +82 -0
- package/out/src/v8-types.js +18 -0
- package/out/src/v8-types.js.map +1 -0
- package/package.json +112 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi108.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi111.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi115.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi120.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi127.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi131.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi137.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi141.node +0 -0
- package/prebuilds/darwin-arm64/dd_pprof.node.abi147.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi108.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi111.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi115.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi120.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi127.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi131.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi137.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi141.node +0 -0
- package/prebuilds/darwin-x64/dd_pprof.node.abi147.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi108.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi111.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi115.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi120.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi127.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi131.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi137.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi141.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.musl.node.abi147.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi108.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi111.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi115.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi120.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi127.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi131.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi137.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi141.node +0 -0
- package/prebuilds/linux-arm64/dd_pprof.node.abi147.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi108.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi111.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi115.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi120.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi127.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi131.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi137.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi141.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.musl.node.abi147.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi108.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi111.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi115.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi120.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi127.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi131.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi137.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi141.node +0 -0
- package/prebuilds/linux-x64/dd_pprof.node.abi147.node +0 -0
- package/prebuilds/openharmony-arm64/dd_pprof.node.abi147.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi108.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi111.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi115.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi120.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi127.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi131.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi137.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi141.node +0 -0
- package/prebuilds/win32-x64/dd_pprof.node.abi147.node +0 -0
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright 2017 Google Inc. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DEFAULT_COLUMN_NUMBERS = exports.GARBAGE_COLLECTION_FUNCTION_NAME = exports.NON_JS_THREADS_FUNCTION_NAME = void 0;
|
|
19
|
+
exports.computeTotalHitCount = computeTotalHitCount;
|
|
20
|
+
exports.serializeTimeProfile = serializeTimeProfile;
|
|
21
|
+
exports.serializeHeapProfile = serializeHeapProfile;
|
|
22
|
+
const pprof_format_1 = require("pprof-format");
|
|
23
|
+
exports.NON_JS_THREADS_FUNCTION_NAME = 'Non JS threads activity';
|
|
24
|
+
exports.GARBAGE_COLLECTION_FUNCTION_NAME = 'Garbage Collection';
|
|
25
|
+
function isGeneratedLocation(location) {
|
|
26
|
+
return (location.column !== undefined &&
|
|
27
|
+
location.line !== undefined &&
|
|
28
|
+
location.line > 0);
|
|
29
|
+
}
|
|
30
|
+
exports.DEFAULT_COLUMN_NUMBERS = 'drop';
|
|
31
|
+
/**
|
|
32
|
+
* Packs a frame's line and column into the single value carried by the pprof
|
|
33
|
+
* Line.line field: the column in the high 32 bits, the line in the low 32 bits
|
|
34
|
+
* (matching the backend's JavaScriptProfileUnminifier.decodeLineAndColumn).
|
|
35
|
+
*
|
|
36
|
+
* BigInt is required: JavaScript's bitwise operators are 32-bit, so `column <<
|
|
37
|
+
* 32` on a plain number is a no-op that returns `column` unchanged. Computing
|
|
38
|
+
* the pack arithmetically as `column * 2**32 + line` instead loses integer
|
|
39
|
+
* precision once the column exceeds 2**21 (the product passes 2**53, Number's
|
|
40
|
+
* safe-integer limit) — and minified single-line bundles routinely have columns
|
|
41
|
+
* that large.
|
|
42
|
+
*/
|
|
43
|
+
function packLineAndColumn(line, column) {
|
|
44
|
+
if (!line) {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
if (!column) {
|
|
48
|
+
return line;
|
|
49
|
+
}
|
|
50
|
+
return (BigInt(column) << 32n) | BigInt(line);
|
|
51
|
+
}
|
|
52
|
+
function requireAllocationStat(value, field) {
|
|
53
|
+
if (value === undefined) {
|
|
54
|
+
throw new Error(`Allocation profile is missing ${field}.`);
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Takes v8 profile and populates sample, location, and function fields of
|
|
60
|
+
* profile.proto.
|
|
61
|
+
*
|
|
62
|
+
* @param profile - profile.proto with empty sample, location, and function
|
|
63
|
+
* fields.
|
|
64
|
+
* @param root - root of v8 profile tree describing samples to be appended
|
|
65
|
+
* to profile.
|
|
66
|
+
* @param appendToSamples - function which converts entry to sample(s) and
|
|
67
|
+
* appends these to end of an array of samples.
|
|
68
|
+
* @param stringTable - string table for the existing profile.
|
|
69
|
+
*/
|
|
70
|
+
function serialize(profile, root, appendToSamples, stringTable, ignoreSamplesPath, sourceMapper, columnNumbers = exports.DEFAULT_COLUMN_NUMBERS) {
|
|
71
|
+
const samples = [];
|
|
72
|
+
const locations = [];
|
|
73
|
+
const functions = [];
|
|
74
|
+
const functionIdMap = new Map();
|
|
75
|
+
const locationIdMap = new Map();
|
|
76
|
+
const packColumns = columnNumbers === 'pack';
|
|
77
|
+
let hasMissingMapFiles = false;
|
|
78
|
+
const entries = root.children.map((n) => ({
|
|
79
|
+
node: n,
|
|
80
|
+
stack: [],
|
|
81
|
+
}));
|
|
82
|
+
while (entries.length > 0) {
|
|
83
|
+
const entry = entries.pop();
|
|
84
|
+
const node = entry.node;
|
|
85
|
+
// mjs files have a `file://` prefix in the scriptName -> remove it
|
|
86
|
+
const scriptName = node.scriptName.startsWith('file://')
|
|
87
|
+
? node.scriptName.slice(7)
|
|
88
|
+
: node.scriptName;
|
|
89
|
+
if (ignoreSamplesPath && scriptName.indexOf(ignoreSamplesPath) > -1) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const stack = entry.stack;
|
|
93
|
+
const location = getLocation(node, scriptName, sourceMapper);
|
|
94
|
+
stack.unshift(location.id);
|
|
95
|
+
appendToSamples(entry, samples);
|
|
96
|
+
for (const child of node.children) {
|
|
97
|
+
entries.push({ node: child, stack: stack.slice() });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
profile.sample = samples;
|
|
101
|
+
profile.location = locations;
|
|
102
|
+
profile.function = functions;
|
|
103
|
+
profile.stringTable = stringTable;
|
|
104
|
+
if (hasMissingMapFiles) {
|
|
105
|
+
profile.comment = [stringTable.dedup('dd:has-missing-map-files')];
|
|
106
|
+
}
|
|
107
|
+
function getLocation(node, scriptName, sourceMapper) {
|
|
108
|
+
let profLoc = {
|
|
109
|
+
file: scriptName || '',
|
|
110
|
+
line: node.lineNumber,
|
|
111
|
+
column: node.columnNumber,
|
|
112
|
+
name: node.name,
|
|
113
|
+
};
|
|
114
|
+
if (profLoc.line) {
|
|
115
|
+
if (sourceMapper && isGeneratedLocation(profLoc)) {
|
|
116
|
+
profLoc = sourceMapper.mappingInfo(profLoc);
|
|
117
|
+
if (profLoc.missingMapFile) {
|
|
118
|
+
hasMissingMapFiles = true;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const keyStr = `${node.scriptId}:${profLoc.line}:${profLoc.column}:${profLoc.name}`;
|
|
123
|
+
let id = locationIdMap.get(keyStr);
|
|
124
|
+
if (id !== undefined) {
|
|
125
|
+
// id is index+1, since 0 is not valid id.
|
|
126
|
+
return locations[id - 1];
|
|
127
|
+
}
|
|
128
|
+
id = locations.length + 1;
|
|
129
|
+
locationIdMap.set(keyStr, id);
|
|
130
|
+
const line = getLine(profLoc, node.scriptId);
|
|
131
|
+
const location = new pprof_format_1.Location({ id, line: [line] });
|
|
132
|
+
locations.push(location);
|
|
133
|
+
return location;
|
|
134
|
+
}
|
|
135
|
+
function getLine(loc, scriptId) {
|
|
136
|
+
// Only pack the column for frames whose source map was declared but missing
|
|
137
|
+
// locally — i.e. exactly the frames that will be sent for server-side
|
|
138
|
+
// unminification (the same condition that sets dd:has-missing-map-files).
|
|
139
|
+
// Locally-resolved frames keep their plain line, so packed values never
|
|
140
|
+
// reach profiles that skip server-side unminification.
|
|
141
|
+
const packColumn = packColumns && loc.missingMapFile === true;
|
|
142
|
+
return new pprof_format_1.Line({
|
|
143
|
+
functionId: getFunction(loc, scriptId).id,
|
|
144
|
+
line: packColumn ? packLineAndColumn(loc.line, loc.column) : loc.line,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function getFunction(loc, scriptId) {
|
|
148
|
+
let name = loc.name;
|
|
149
|
+
const keyStr = name
|
|
150
|
+
? `${scriptId}:${name}`
|
|
151
|
+
: `${scriptId}:${loc.line}:${loc.column}`;
|
|
152
|
+
let id = functionIdMap.get(keyStr);
|
|
153
|
+
if (id !== undefined) {
|
|
154
|
+
// id is index+1, since 0 is not valid id.
|
|
155
|
+
return functions[id - 1];
|
|
156
|
+
}
|
|
157
|
+
id = functions.length + 1;
|
|
158
|
+
functionIdMap.set(keyStr, id);
|
|
159
|
+
if (!name) {
|
|
160
|
+
if (loc.line) {
|
|
161
|
+
if (loc.column) {
|
|
162
|
+
name = `(anonymous:L#${loc.line}:C#${loc.column})`;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
name = `(anonymous:L#${loc.line})`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
name = '(anonymous)';
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
const nameId = stringTable.dedup(name);
|
|
173
|
+
const f = new pprof_format_1.Function({
|
|
174
|
+
id,
|
|
175
|
+
name: nameId,
|
|
176
|
+
systemName: nameId,
|
|
177
|
+
filename: stringTable.dedup(loc.file || ''),
|
|
178
|
+
});
|
|
179
|
+
functions.push(f);
|
|
180
|
+
return f;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* @return value type for sample counts (type:sample, units:count), and
|
|
185
|
+
* adds strings used in this value type to the table.
|
|
186
|
+
*/
|
|
187
|
+
function createSampleCountValueType(table) {
|
|
188
|
+
return new pprof_format_1.ValueType({
|
|
189
|
+
type: table.dedup('sample'),
|
|
190
|
+
unit: table.dedup('count'),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @return value type for time samples (type:wall, units:nanoseconds), and
|
|
195
|
+
* adds strings used in this value type to the table.
|
|
196
|
+
*/
|
|
197
|
+
function createTimeValueType(table) {
|
|
198
|
+
return new pprof_format_1.ValueType({
|
|
199
|
+
type: table.dedup('wall'),
|
|
200
|
+
unit: table.dedup('nanoseconds'),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* @return value type for cpu samples (type:cpu, units:nanoseconds), and
|
|
205
|
+
* adds strings used in this value type to the table.
|
|
206
|
+
*/
|
|
207
|
+
function createCpuValueType(table) {
|
|
208
|
+
return new pprof_format_1.ValueType({
|
|
209
|
+
type: table.dedup('cpu'),
|
|
210
|
+
unit: table.dedup('nanoseconds'),
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function createInUseObjectCountValueType(table) {
|
|
214
|
+
return new pprof_format_1.ValueType({
|
|
215
|
+
type: table.dedup('inuse_objects'),
|
|
216
|
+
unit: table.dedup('count'),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
function createAllocatedObjectCountValueType(table) {
|
|
220
|
+
return new pprof_format_1.ValueType({
|
|
221
|
+
type: table.dedup('alloc_objects'),
|
|
222
|
+
unit: table.dedup('count'),
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
function createInUseSpaceValueType(table) {
|
|
226
|
+
return new pprof_format_1.ValueType({
|
|
227
|
+
type: table.dedup('inuse_space'),
|
|
228
|
+
unit: table.dedup('bytes'),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
function createAllocatedSpaceValueType(table) {
|
|
232
|
+
return new pprof_format_1.ValueType({
|
|
233
|
+
type: table.dedup('alloc_space'),
|
|
234
|
+
unit: table.dedup('bytes'),
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function computeTotalHitCount(root) {
|
|
238
|
+
return (root.hitCount +
|
|
239
|
+
root.children.reduce((sum, node) => sum + computeTotalHitCount(node), 0));
|
|
240
|
+
}
|
|
241
|
+
/** Perform some modifications on time profile:
|
|
242
|
+
* - Add non-JS thread activity node if available
|
|
243
|
+
* - remove `(program)` nodes
|
|
244
|
+
* - remove `(idle)` nodes with no context
|
|
245
|
+
* - set `(idle)` nodes' wall time to zero when they have a context
|
|
246
|
+
* - Convert `(garbage collector)` node to `Garbage Collection`
|
|
247
|
+
* - Put `non-JS thread activity` node and `Garbage Collection` under a top level `Node.js` node
|
|
248
|
+
* This function does not change the input profile.
|
|
249
|
+
*/
|
|
250
|
+
function updateTimeProfile(prof) {
|
|
251
|
+
const newTopLevelChildren = [];
|
|
252
|
+
let runtimeNode;
|
|
253
|
+
function getRuntimeNode() {
|
|
254
|
+
if (!runtimeNode) {
|
|
255
|
+
runtimeNode = {
|
|
256
|
+
name: 'Node.js',
|
|
257
|
+
scriptName: '',
|
|
258
|
+
scriptId: 0,
|
|
259
|
+
lineNumber: 0,
|
|
260
|
+
columnNumber: 0,
|
|
261
|
+
children: [],
|
|
262
|
+
hitCount: 0,
|
|
263
|
+
};
|
|
264
|
+
newTopLevelChildren.push(runtimeNode);
|
|
265
|
+
}
|
|
266
|
+
return runtimeNode;
|
|
267
|
+
}
|
|
268
|
+
for (const child of prof.topDownRoot.children) {
|
|
269
|
+
if (child.name === '(program)') {
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (child.name === '(idle)' && child.contexts?.length === 0) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
if (child.name === '(garbage collector)') {
|
|
276
|
+
// Create a new node to avoid modifying the input one
|
|
277
|
+
const newChild = {
|
|
278
|
+
...child,
|
|
279
|
+
name: exports.GARBAGE_COLLECTION_FUNCTION_NAME,
|
|
280
|
+
};
|
|
281
|
+
getRuntimeNode().children.push(newChild);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
newTopLevelChildren.push(child);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (prof.hasCpuTime && prof.nonJSThreadsCpuTime) {
|
|
288
|
+
const node = {
|
|
289
|
+
name: exports.NON_JS_THREADS_FUNCTION_NAME,
|
|
290
|
+
scriptName: '',
|
|
291
|
+
scriptId: 0,
|
|
292
|
+
lineNumber: 0,
|
|
293
|
+
columnNumber: 0,
|
|
294
|
+
children: [],
|
|
295
|
+
hitCount: 0, // 0 because this should not be accounted for wall time
|
|
296
|
+
contexts: [
|
|
297
|
+
{
|
|
298
|
+
context: {},
|
|
299
|
+
timestamp: BigInt(0),
|
|
300
|
+
cpuTime: prof.nonJSThreadsCpuTime,
|
|
301
|
+
asyncId: -1,
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
};
|
|
305
|
+
getRuntimeNode().children.push(node);
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
...prof,
|
|
309
|
+
topDownRoot: { ...prof.topDownRoot, children: newTopLevelChildren },
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Converts v8 time profile into into a profile proto.
|
|
314
|
+
* (https://github.com/google/pprof/blob/master/proto/profile.proto)
|
|
315
|
+
*
|
|
316
|
+
* @param prof - profile to be converted.
|
|
317
|
+
* @param intervalMicros - average time (microseconds) between samples.
|
|
318
|
+
*/
|
|
319
|
+
function serializeTimeProfile(prof, intervalMicros, sourceMapper, recomputeSamplingInterval = false, generateLabels, lowCardinalityLabels = [], columnNumbers = exports.DEFAULT_COLUMN_NUMBERS) {
|
|
320
|
+
// If requested, recompute sampling interval from profile duration and total number of hits,
|
|
321
|
+
// since profile duration should be #hits x interval.
|
|
322
|
+
// Recomputing an average interval is more accurate, since in practice intervals between
|
|
323
|
+
// samples are larger than the requested sampling interval (eg. 12.5ms vs 10ms requested).
|
|
324
|
+
// For very short durations, computation becomes meaningless (eg. if there is only one hit),
|
|
325
|
+
// therefore keep intervalMicros as a lower bound and 2 * intervalMicros as upper bound.
|
|
326
|
+
if (recomputeSamplingInterval) {
|
|
327
|
+
const totalHitCount = prof.totalHitCount ?? computeTotalHitCount(prof.topDownRoot);
|
|
328
|
+
if (totalHitCount > 0) {
|
|
329
|
+
intervalMicros = Math.min(Math.max(Math.floor((prof.endTime - prof.startTime) / totalHitCount), intervalMicros), 2 * intervalMicros);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const intervalNanos = intervalMicros * 1000;
|
|
333
|
+
const stringTable = new pprof_format_1.StringTable();
|
|
334
|
+
const labelCaches = [];
|
|
335
|
+
for (const l of lowCardinalityLabels) {
|
|
336
|
+
labelCaches[stringTable.dedup(l)] = new Map();
|
|
337
|
+
}
|
|
338
|
+
const dedupLabels = (labels) => {
|
|
339
|
+
for (let i = 0; i < labels.length; i++) {
|
|
340
|
+
const label = labels[i];
|
|
341
|
+
const cache = labelCaches[Number(label.key)];
|
|
342
|
+
if (cache !== undefined) {
|
|
343
|
+
const key = label.str ?? label.num;
|
|
344
|
+
const exlabel = cache.get(key);
|
|
345
|
+
if (exlabel === undefined) {
|
|
346
|
+
cache.set(key, label);
|
|
347
|
+
}
|
|
348
|
+
else if (label.str === exlabel.str &&
|
|
349
|
+
label.num === exlabel.num &&
|
|
350
|
+
label.numUnit === exlabel.numUnit) {
|
|
351
|
+
labels[i] = exlabel;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return labels;
|
|
356
|
+
};
|
|
357
|
+
const appendTimeEntryToSamples = (entry, samples) => {
|
|
358
|
+
let unlabelledHits = entry.node.hitCount;
|
|
359
|
+
let unlabelledCpuTime = 0;
|
|
360
|
+
const isIdle = entry.node.name === '(idle)';
|
|
361
|
+
for (const context of entry.node.contexts || []) {
|
|
362
|
+
const labels = generateLabels
|
|
363
|
+
? generateLabels({ node: entry.node, context })
|
|
364
|
+
: (context.context ?? {});
|
|
365
|
+
const labelsArr = buildLabels(labels, stringTable);
|
|
366
|
+
if (labelsArr.length > 0) {
|
|
367
|
+
// Only assign wall time if there are hits, some special nodes such as `(Non-JS threads)`
|
|
368
|
+
// have zero hit count (since they do not count as wall time) and should not be assigned any
|
|
369
|
+
// wall time. Also, `(idle)` nodes should be assigned zero wall time.
|
|
370
|
+
const values = unlabelledHits > 0 ? [1, isIdle ? 0 : intervalNanos] : [0, 0];
|
|
371
|
+
if (prof.hasCpuTime) {
|
|
372
|
+
values.push(context.cpuTime ?? 0);
|
|
373
|
+
}
|
|
374
|
+
const sample = new pprof_format_1.Sample({
|
|
375
|
+
locationId: entry.stack,
|
|
376
|
+
value: values,
|
|
377
|
+
label: dedupLabels(labelsArr),
|
|
378
|
+
});
|
|
379
|
+
samples.push(sample);
|
|
380
|
+
unlabelledHits--;
|
|
381
|
+
}
|
|
382
|
+
else if (prof.hasCpuTime) {
|
|
383
|
+
unlabelledCpuTime += context.cpuTime ?? 0;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if ((!isIdle && unlabelledHits > 0) || unlabelledCpuTime > 0) {
|
|
387
|
+
const labels = generateLabels ? generateLabels({ node: entry.node }) : {};
|
|
388
|
+
const values = unlabelledHits > 0
|
|
389
|
+
? [unlabelledHits, isIdle ? 0 : unlabelledHits * intervalNanos]
|
|
390
|
+
: [0, 0];
|
|
391
|
+
if (prof.hasCpuTime) {
|
|
392
|
+
values.push(unlabelledCpuTime);
|
|
393
|
+
}
|
|
394
|
+
const sample = new pprof_format_1.Sample({
|
|
395
|
+
locationId: entry.stack,
|
|
396
|
+
value: values,
|
|
397
|
+
label: buildLabels(labels, stringTable),
|
|
398
|
+
});
|
|
399
|
+
samples.push(sample);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
const sampleValueType = createSampleCountValueType(stringTable);
|
|
403
|
+
const timeValueType = createTimeValueType(stringTable);
|
|
404
|
+
const sampleTypes = [sampleValueType, timeValueType];
|
|
405
|
+
if (prof.hasCpuTime) {
|
|
406
|
+
const cpuValueType = createCpuValueType(stringTable);
|
|
407
|
+
sampleTypes.push(cpuValueType);
|
|
408
|
+
}
|
|
409
|
+
const profile = {
|
|
410
|
+
sampleType: sampleTypes,
|
|
411
|
+
timeNanos: Date.now() * 1000 * 1000,
|
|
412
|
+
durationNanos: (prof.endTime - prof.startTime) * 1000,
|
|
413
|
+
periodType: timeValueType,
|
|
414
|
+
period: intervalNanos,
|
|
415
|
+
};
|
|
416
|
+
const updatedProf = updateTimeProfile(prof);
|
|
417
|
+
serialize(profile, updatedProf.topDownRoot, appendTimeEntryToSamples, stringTable, undefined, sourceMapper, columnNumbers);
|
|
418
|
+
return new pprof_format_1.Profile(profile);
|
|
419
|
+
}
|
|
420
|
+
function buildLabels(labelSet, stringTable) {
|
|
421
|
+
const labels = [];
|
|
422
|
+
for (const [key, value] of Object.entries(labelSet)) {
|
|
423
|
+
const labelInput = {
|
|
424
|
+
key: stringTable.dedup(key),
|
|
425
|
+
};
|
|
426
|
+
switch (typeof value) {
|
|
427
|
+
case 'string':
|
|
428
|
+
labelInput.str = stringTable.dedup(value);
|
|
429
|
+
break;
|
|
430
|
+
case 'number':
|
|
431
|
+
case 'bigint':
|
|
432
|
+
labelInput.num = value;
|
|
433
|
+
break;
|
|
434
|
+
default:
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
labels.push(new pprof_format_1.Label(labelInput));
|
|
438
|
+
}
|
|
439
|
+
return labels;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Converts v8 heap profile into into a profile proto.
|
|
443
|
+
* (https://github.com/google/pprof/blob/master/proto/profile.proto)
|
|
444
|
+
*
|
|
445
|
+
* @param prof - profile to be converted.
|
|
446
|
+
* @param startTimeNanos - start time of profile, in nanoseconds (POSIX time).
|
|
447
|
+
* @param durationsNanos - duration of the profile (wall clock time) in
|
|
448
|
+
* nanoseconds.
|
|
449
|
+
* @param intervalBytes - bytes allocated between samples.
|
|
450
|
+
*/
|
|
451
|
+
function serializeHeapProfile(prof, startTimeNanos, intervalBytes, ignoreSamplesPath, sourceMapper, generateLabels, allocations = false, columnNumbers = exports.DEFAULT_COLUMN_NUMBERS) {
|
|
452
|
+
const appendHeapEntryToSamples = (entry, samples) => {
|
|
453
|
+
if (entry.node.allocations.length > 0) {
|
|
454
|
+
const labels = generateLabels
|
|
455
|
+
? buildLabels(generateLabels({ node: entry.node }), stringTable)
|
|
456
|
+
: [];
|
|
457
|
+
for (const alloc of entry.node.allocations) {
|
|
458
|
+
// Live heap only
|
|
459
|
+
if (!allocations) {
|
|
460
|
+
const heapAllocation = alloc;
|
|
461
|
+
const sample = new pprof_format_1.Sample({
|
|
462
|
+
locationId: entry.stack,
|
|
463
|
+
value: [
|
|
464
|
+
heapAllocation.count,
|
|
465
|
+
heapAllocation.sizeBytes * heapAllocation.count,
|
|
466
|
+
],
|
|
467
|
+
label: labels,
|
|
468
|
+
// TODO: add tag for allocation size
|
|
469
|
+
});
|
|
470
|
+
samples.push(sample);
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
const stats = alloc;
|
|
474
|
+
const inuseObjects = requireAllocationStat(stats.inuseObjects, 'inuseObjects');
|
|
475
|
+
const inuseSpaceBytes = requireAllocationStat(stats.inuseSpaceBytes, 'inuseSpaceBytes');
|
|
476
|
+
const allocObjects = requireAllocationStat(stats.allocObjects, 'allocObjects');
|
|
477
|
+
const allocSpaceBytes = requireAllocationStat(stats.allocSpaceBytes, 'allocSpaceBytes');
|
|
478
|
+
const sample = new pprof_format_1.Sample({
|
|
479
|
+
locationId: entry.stack,
|
|
480
|
+
value: [inuseObjects, allocObjects, inuseSpaceBytes, allocSpaceBytes],
|
|
481
|
+
label: labels,
|
|
482
|
+
// TODO: add tag for allocation size
|
|
483
|
+
});
|
|
484
|
+
samples.push(sample);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
const stringTable = new pprof_format_1.StringTable();
|
|
489
|
+
const sampleTypes = allocations
|
|
490
|
+
? [
|
|
491
|
+
createInUseObjectCountValueType(stringTable),
|
|
492
|
+
createAllocatedObjectCountValueType(stringTable),
|
|
493
|
+
createInUseSpaceValueType(stringTable),
|
|
494
|
+
createAllocatedSpaceValueType(stringTable),
|
|
495
|
+
]
|
|
496
|
+
: [
|
|
497
|
+
createInUseObjectCountValueType(stringTable),
|
|
498
|
+
createInUseSpaceValueType(stringTable),
|
|
499
|
+
];
|
|
500
|
+
const profile = {
|
|
501
|
+
sampleType: sampleTypes,
|
|
502
|
+
timeNanos: startTimeNanos,
|
|
503
|
+
periodType: sampleTypes[sampleTypes.length - 1],
|
|
504
|
+
period: intervalBytes,
|
|
505
|
+
};
|
|
506
|
+
serialize(profile, prof, appendHeapEntryToSamples, stringTable, ignoreSamplesPath, sourceMapper, columnNumbers);
|
|
507
|
+
return new pprof_format_1.Profile(profile);
|
|
508
|
+
}
|
|
509
|
+
//# sourceMappingURL=profile-serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-serializer.js","sourceRoot":"","sources":["../../ts/src/profile-serializer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAsUH,oDAQC;AAoFD,oDAuIC;AAoCD,oDAmGC;AA9qBD,+CAWsB;AAkBT,QAAA,4BAA4B,GAAG,yBAAyB,CAAC;AACzD,QAAA,gCAAgC,GAAG,oBAAoB,CAAC;AAwBrE,SAAS,mBAAmB,CAC1B,QAAwB;IAExB,OAAO,CACL,QAAQ,CAAC,MAAM,KAAK,SAAS;QAC7B,QAAQ,CAAC,IAAI,KAAK,SAAS;QAC3B,QAAQ,CAAC,IAAI,GAAG,CAAC,CAClB,CAAC;AACJ,CAAC;AAkBY,QAAA,sBAAsB,GAAkB,MAAM,CAAC;AAE5D;;;;;;;;;;;GAWG;AACH,SAAS,iBAAiB,CACxB,IAAwB,EACxB,MAA0B;IAE1B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,qBAAqB,CAC5B,KAAyB,EACzB,KAAa;IAEb,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,iCAAiC,KAAK,GAAG,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,SAAS,CAChB,OAAqB,EACrB,IAAO,EACP,eAAwC,EACxC,WAAwB,EACxB,iBAA0B,EAC1B,YAA2B,EAC3B,gBAA+B,8BAAsB;IAErD,MAAM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
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import * as sourceMap from 'source-map';
|
|
17
|
+
export declare const ANNOTATION_TAIL_BYTES: number;
|
|
18
|
+
/**
|
|
19
|
+
* Extracts a sourceMappingURL from JS source per ECMA-426 §11.1.2.1
|
|
20
|
+
* (without-parsing variant).
|
|
21
|
+
*
|
|
22
|
+
* Scans lines from the end, skipping empty/whitespace-only lines.
|
|
23
|
+
* Returns null as soon as the first non-empty line is found that does not
|
|
24
|
+
* carry a valid annotation — the URL must be on the last non-empty line.
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractSourceMappingURL(content: string): string | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Reads the sourceMappingURL from a JS file efficiently by only reading a
|
|
29
|
+
* small tail of the file.
|
|
30
|
+
*
|
|
31
|
+
* The annotation must be on the last non-empty line (ECMA-426), so as long as
|
|
32
|
+
* the tail contains at least one line terminator the last line is fully
|
|
33
|
+
* captured. If no line terminator appears in the tail the entire tail is part
|
|
34
|
+
* of one very long inline data: line; we fall back to a full file read in
|
|
35
|
+
* that case.
|
|
36
|
+
*/
|
|
37
|
+
export declare function readSourceMappingURL(filePath: string): Promise<string | undefined>;
|
|
38
|
+
export interface MapInfoCompiled {
|
|
39
|
+
mapFileDir: string;
|
|
40
|
+
mapConsumer: sourceMap.RawSourceMap;
|
|
41
|
+
}
|
|
42
|
+
export interface GeneratedLocation {
|
|
43
|
+
file: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
line: number;
|
|
46
|
+
column: number;
|
|
47
|
+
}
|
|
48
|
+
export interface SourceLocation {
|
|
49
|
+
file?: string;
|
|
50
|
+
name?: string;
|
|
51
|
+
line?: number;
|
|
52
|
+
column?: number;
|
|
53
|
+
/** True when the file declares a sourceMappingURL but the map could not be found. */
|
|
54
|
+
missingMapFile?: boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare class SourceMapper {
|
|
57
|
+
infoMap: Map<string, MapInfoCompiled>;
|
|
58
|
+
/** JS files that declared a sourceMappingURL but no map was ultimately found. */
|
|
59
|
+
private declaredMissingMap;
|
|
60
|
+
debug: boolean;
|
|
61
|
+
static create(searchDirs: string[], debug?: boolean): Promise<SourceMapper>;
|
|
62
|
+
constructor(debug?: boolean);
|
|
63
|
+
/**
|
|
64
|
+
* Scans `searchDir` recursively for JS files and source map files, loading
|
|
65
|
+
* source maps for all JS files found.
|
|
66
|
+
*
|
|
67
|
+
* Priority for each JS file:
|
|
68
|
+
* 1. A map pointed to by a `sourceMappingURL` annotation in the JS file
|
|
69
|
+
* (inline `data:` URL or external file path, only if the file exists).
|
|
70
|
+
* 2. A `.map` file found in the directory scan that claims to belong to
|
|
71
|
+
* that JS file (via its `file` property or naming convention).
|
|
72
|
+
*
|
|
73
|
+
* Safe to call multiple times; already-loaded files are skipped.
|
|
74
|
+
*/
|
|
75
|
+
loadDirectory(searchDir: string): Promise<void>;
|
|
76
|
+
private loadMapContent;
|
|
77
|
+
/**
|
|
78
|
+
* Used to get the information about the transpiled file from a given input
|
|
79
|
+
* source file provided there isn't any ambiguity with associating the input
|
|
80
|
+
* path to exactly one output transpiled file.
|
|
81
|
+
*
|
|
82
|
+
* @param inputPath The (possibly relative) path to the original source file.
|
|
83
|
+
* @return The `MapInfoCompiled` object that describes the transpiled file
|
|
84
|
+
* associated with the specified input path. `null` is returned if either
|
|
85
|
+
* zero files are associated with the input path or if more than one file
|
|
86
|
+
* could possibly be associated with the given input path.
|
|
87
|
+
*/
|
|
88
|
+
private getMappingInfo;
|
|
89
|
+
/**
|
|
90
|
+
* Used to determine if the source file specified by the given path has
|
|
91
|
+
* a .map file and an output file associated with it.
|
|
92
|
+
*
|
|
93
|
+
* If there is no such mapping, it could be because the input file is not
|
|
94
|
+
* the input to a transpilation process or it is the input to a transpilation
|
|
95
|
+
* process but its corresponding .map file was not given to the constructor
|
|
96
|
+
* of this mapper.
|
|
97
|
+
*
|
|
98
|
+
* @param {string} inputPath The path to an input file that could
|
|
99
|
+
* possibly be the input to a transpilation process. The path should be
|
|
100
|
+
* relative to the process's current working directory.
|
|
101
|
+
*/
|
|
102
|
+
hasMappingInfo(inputPath: string): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* @param {string} inputPath The path to an input file that could possibly
|
|
105
|
+
* be the input to a transpilation process. The path should be relative to
|
|
106
|
+
* the process's current working directory
|
|
107
|
+
* @param {number} The line number in the input file where the line number is
|
|
108
|
+
* zero-based.
|
|
109
|
+
* @param {number} (Optional) The column number in the line of the file
|
|
110
|
+
* specified where the column number is zero-based.
|
|
111
|
+
* @return {Object} The object returned has a "file" attribute for the
|
|
112
|
+
* path of the output file associated with the given input file (where the
|
|
113
|
+
* path is relative to the process's current working directory),
|
|
114
|
+
* a "line" attribute of the line number in the output file associated with
|
|
115
|
+
* the given line number for the input file, and an optional "column" number
|
|
116
|
+
* of the column number of the output file associated with the given file
|
|
117
|
+
* and line information.
|
|
118
|
+
*
|
|
119
|
+
* If the given input file does not have mapping information associated
|
|
120
|
+
* with it then the input location is returned.
|
|
121
|
+
*/
|
|
122
|
+
mappingInfo(location: GeneratedLocation): SourceLocation;
|
|
123
|
+
}
|