@datadog/pprof 0.1.1 → 0.2.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.
Files changed (44) hide show
  1. package/bindings/profiler.cc +124 -125
  2. package/out/src/profile-serializer.js +6 -3
  3. package/out/src/profile-serializer.js.map +1 -1
  4. package/out/src/time-profiler-bindings.d.ts +1 -4
  5. package/out/src/time-profiler-bindings.js +4 -16
  6. package/out/src/time-profiler-bindings.js.map +1 -1
  7. package/out/src/time-profiler.js +12 -12
  8. package/out/src/time-profiler.js.map +1 -1
  9. package/package.json +7 -5
  10. package/prebuilds/darwin-ia32/node-102.node +0 -0
  11. package/prebuilds/darwin-ia32/node-72.node +0 -0
  12. package/prebuilds/darwin-ia32/node-79.node +0 -0
  13. package/prebuilds/darwin-ia32/node-83.node +0 -0
  14. package/prebuilds/darwin-ia32/node-88.node +0 -0
  15. package/prebuilds/darwin-ia32/node-93.node +0 -0
  16. package/prebuilds/darwin-x64/node-102.node +0 -0
  17. package/prebuilds/darwin-x64/node-72.node +0 -0
  18. package/prebuilds/darwin-x64/node-79.node +0 -0
  19. package/prebuilds/darwin-x64/node-83.node +0 -0
  20. package/prebuilds/darwin-x64/node-88.node +0 -0
  21. package/prebuilds/darwin-x64/node-93.node +0 -0
  22. package/prebuilds/linux-ia32/node-72.node +0 -0
  23. package/prebuilds/linux-ia32/node-79.node +0 -0
  24. package/prebuilds/linux-x64/node-102.node +0 -0
  25. package/prebuilds/linux-x64/node-72.node +0 -0
  26. package/prebuilds/linux-x64/node-79.node +0 -0
  27. package/prebuilds/linux-x64/node-83.node +0 -0
  28. package/prebuilds/linux-x64/node-88.node +0 -0
  29. package/prebuilds/linux-x64/node-93.node +0 -0
  30. package/prebuilds/win32-ia32/node-102.node +0 -0
  31. package/prebuilds/win32-ia32/node-72.node +0 -0
  32. package/prebuilds/win32-ia32/node-79.node +0 -0
  33. package/prebuilds/win32-ia32/node-83.node +0 -0
  34. package/prebuilds/win32-ia32/node-88.node +0 -0
  35. package/prebuilds/win32-ia32/node-93.node +0 -0
  36. package/prebuilds/win32-x64/node-102.node +0 -0
  37. package/prebuilds/win32-x64/node-72.node +0 -0
  38. package/prebuilds/win32-x64/node-79.node +0 -0
  39. package/prebuilds/win32-x64/node-83.node +0 -0
  40. package/prebuilds/win32-x64/node-88.node +0 -0
  41. package/prebuilds/win32-x64/node-93.node +0 -0
  42. package/scripts/prebuild.js +0 -57
  43. package/scripts/prebuilds.js +0 -93
  44. package/scripts/prepublish.js +0 -201
@@ -16,6 +16,7 @@
16
16
 
17
17
  #include <memory>
18
18
 
19
+ #include <node.h>
19
20
  #include "nan.h"
20
21
  #include "v8-profiler.h"
21
22
 
@@ -95,22 +96,6 @@ NAN_METHOD(GetAllocationProfile) {
95
96
  info.GetReturnValue().Set(TranslateAllocationProfile(root));
96
97
  }
97
98
 
98
- // Time profiler
99
- #if NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION
100
- // For Node 12 and Node 14, a new CPU profiler object will be created each
101
- // time profiling is started to work around
102
- // https://bugs.chromium.org/p/v8/issues/detail?id=11051.
103
- CpuProfiler* cpuProfiler;
104
- // Default sampling interval is 1000us.
105
- int samplingIntervalUS = 1000;
106
- #elif NODE_MODULE_VERSION > NODE_8_0_MODULE_VERSION
107
- // This profiler exists for the lifetime of the program. Not calling
108
- // CpuProfiler::Dispose() is intentional.
109
- CpuProfiler* cpuProfiler = CpuProfiler::New(v8::Isolate::GetCurrent());
110
- #else
111
- CpuProfiler* cpuProfiler = v8::Isolate::GetCurrent()->GetCpuProfiler();
112
- #endif
113
-
114
99
  Local<Object> CreateTimeNode(Local<String> name, Local<String> scriptName,
115
100
  Local<Integer> scriptId, Local<Integer> lineNumber,
116
101
  Local<Integer> columnNumber,
@@ -130,7 +115,6 @@ Local<Object> CreateTimeNode(Local<String> name, Local<String> scriptName,
130
115
  return js_node;
131
116
  }
132
117
 
133
- #if NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION
134
118
  Local<Object> TranslateLineNumbersTimeProfileNode(const CpuProfileNode* parent,
135
119
  const CpuProfileNode* node);
136
120
 
@@ -216,7 +200,6 @@ Local<Value> TranslateLineNumbersTimeProfileRoot(const CpuProfileNode* node) {
216
200
  Nan::New<Integer>(node->GetColumnNumber()),
217
201
  Nan::New<Integer>(0), children);
218
202
  }
219
- #endif
220
203
 
221
204
  Local<Value> TranslateTimeProfileNode(const CpuProfileNode* node) {
222
205
  int32_t count = node->GetChildrenCount();
@@ -257,129 +240,145 @@ Local<Value> TranslateTimeProfile(const CpuProfile* profile,
257
240
  return js_profile;
258
241
  }
259
242
 
260
- // Signature:
261
- // startProfiling(runName: string, includeLineInfo: boolean)
262
- NAN_METHOD(StartProfiling) {
263
- if (info.Length() != 2) {
264
- return Nan::ThrowTypeError("StartProfiling must have two arguments.");
243
+ class TimeProfiler : public Nan::ObjectWrap {
244
+ public:
245
+ static inline Nan::Persistent<v8::Function> & constructor() {
246
+ static Nan::Persistent<v8::Function> my_constructor;
247
+ return my_constructor;
265
248
  }
266
- if (!info[0]->IsString()) {
267
- return Nan::ThrowTypeError("First argument must be a string.");
249
+
250
+ explicit TimeProfiler(int interval) {
251
+ Isolate* isolate = Isolate::GetCurrent();
252
+
253
+ // A new CPU profiler object will be created each time profiling is started
254
+ // to work around https://bugs.chromium.org/p/v8/issues/detail?id=11051.
255
+ cpuProfiler = CpuProfiler::New(isolate);
256
+ cpuProfiler->SetSamplingInterval(interval);
268
257
  }
269
- if (!info[1]->IsBoolean()) {
270
- return Nan::ThrowTypeError("Second argument must be a boolean.");
258
+
259
+ static NAN_METHOD(New) {
260
+ if (info.Length() != 1) {
261
+ return Nan::ThrowTypeError("TimeProfiler must have one argument.");
262
+ }
263
+ if (!info[0]->IsNumber()) {
264
+ return Nan::ThrowTypeError("Sample rate must be a number.");
265
+ }
266
+
267
+ if (info.IsConstructCall()) {
268
+ int interval =
269
+ Nan::MaybeLocal<Integer>(info[0].As<Integer>()).ToLocalChecked()->Value();
270
+
271
+ TimeProfiler* obj = new TimeProfiler(interval);
272
+ obj->Wrap(info.This());
273
+ info.GetReturnValue().Set(info.This());
274
+ } else {
275
+ const int argc = 1;
276
+ v8::Local<v8::Value> argv[argc] = {info[0]};
277
+ v8::Local<v8::Function> cons = Nan::New(constructor());
278
+ info.GetReturnValue().Set(Nan::NewInstance(cons, argc, argv).ToLocalChecked());
279
+ }
271
280
  }
272
281
 
273
- #if NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION
274
- // Since the CPU profiler is created and destroyed each time a CPU
275
- // profile is collected, there cannot be multiple CPU profiling requests
276
- // inflight in parallel.
277
- if (cpuProfiler) {
278
- return Nan::ThrowError("CPU profiler is already started.");
282
+ void StartProfiling(Local<String> name, bool includeLines) {
283
+ // Sample counts and timestamps are not used, so we do not need to record
284
+ // samples.
285
+ const bool recordSamples = false;
286
+
287
+ if (includeLines) {
288
+ cpuProfiler->StartProfiling(name, CpuProfilingMode::kCallerLineNumbers,
289
+ recordSamples);
290
+ } else {
291
+ cpuProfiler->StartProfiling(name, recordSamples);
292
+ }
279
293
  }
280
- cpuProfiler = CpuProfiler::New(v8::Isolate::GetCurrent());
281
- cpuProfiler->SetSamplingInterval(samplingIntervalUS);
282
- #endif
283
294
 
284
- Local<String> name =
285
- Nan::MaybeLocal<String>(info[0].As<String>()).ToLocalChecked();
295
+ static NAN_METHOD(Start) {
296
+ TimeProfiler* timeProfiler =
297
+ Nan::ObjectWrap::Unwrap<TimeProfiler>(info.Holder());
286
298
 
287
- // Sample counts and timestamps are not used, so we do not need to record
288
- // samples.
289
- const bool recordSamples = false;
299
+ if (info.Length() != 2) {
300
+ return Nan::ThrowTypeError("Start must have two arguments.");
301
+ }
302
+ if (!info[0]->IsString()) {
303
+ return Nan::ThrowTypeError("Profile name must be a string.");
304
+ }
305
+ if (!info[1]->IsBoolean()) {
306
+ return Nan::ThrowTypeError("Include lines must be a boolean.");
307
+ }
290
308
 
291
- // Line level accurate line information is not available in Node 11 or earlier.
292
- #if NODE_MODULE_VERSION > NODE_11_0_MODULE_VERSION
293
- bool includeLineInfo =
294
- Nan::MaybeLocal<Boolean>(info[1].As<Boolean>()).ToLocalChecked()->Value();
295
- if (includeLineInfo) {
296
- cpuProfiler->StartProfiling(name, CpuProfilingMode::kCallerLineNumbers,
297
- recordSamples);
298
- } else {
299
- cpuProfiler->StartProfiling(name, recordSamples);
300
- }
301
- #else
302
- cpuProfiler->StartProfiling(name, recordSamples);
303
- #endif
304
- }
309
+ Local<String> name =
310
+ Nan::MaybeLocal<String>(info[0].As<String>()).ToLocalChecked();
305
311
 
306
- // Signature:
307
- // stopProfiling(runName: string, includeLineInfo: boolean): TimeProfile
308
- NAN_METHOD(StopProfiling) {
309
- #if NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION
310
- if (!cpuProfiler) {
311
- return Nan::ThrowError("StopProfiling called without an active CPU profiler.");
312
- }
313
- #endif
314
- if (info.Length() != 2) {
315
- return Nan::ThrowTypeError("StopProfling must have two arguments.");
312
+ bool includeLines =
313
+ Nan::MaybeLocal<Boolean>(info[1].As<Boolean>()).ToLocalChecked()->Value();
314
+
315
+ timeProfiler->StartProfiling(name, includeLines);
316
316
  }
317
- if (!info[0]->IsString()) {
318
- return Nan::ThrowTypeError("First argument must be a string.");
317
+
318
+ Local<Value> StopProfiling(Local<String> name, bool includeLines) {
319
+ CpuProfile* profile = cpuProfiler->StopProfiling(name);
320
+ Local<Value> translated_profile =
321
+ TranslateTimeProfile(profile, includeLines);
322
+ profile->Delete();
323
+ // Dispose of CPU profiler to work around memory leak.
324
+ cpuProfiler->Dispose();
325
+ cpuProfiler = NULL;
326
+ return translated_profile;
319
327
  }
320
- if (!info[1]->IsBoolean()) {
321
- return Nan::ThrowTypeError("Second argument must be a boolean.");
328
+
329
+ static NAN_METHOD(Stop) {
330
+ TimeProfiler* timeProfiler =
331
+ Nan::ObjectWrap::Unwrap<TimeProfiler>(info.Holder());
332
+
333
+ if (info.Length() != 2) {
334
+ return Nan::ThrowTypeError("Start must have two arguments.");
335
+ }
336
+ if (!info[0]->IsString()) {
337
+ return Nan::ThrowTypeError("Profile name must be a string.");
338
+ }
339
+ if (!info[1]->IsBoolean()) {
340
+ return Nan::ThrowTypeError("Include lines must be a boolean.");
341
+ }
342
+
343
+ Local<String> name =
344
+ Nan::MaybeLocal<String>(info[0].As<String>()).ToLocalChecked();
345
+
346
+ bool includeLines =
347
+ Nan::MaybeLocal<Boolean>(info[1].As<Boolean>()).ToLocalChecked()->Value();
348
+
349
+ Local<Value> profile = timeProfiler->StopProfiling(name, includeLines);
350
+ info.GetReturnValue().Set(profile);
322
351
  }
323
- Local<String> name =
324
- Nan::MaybeLocal<String>(info[0].As<String>()).ToLocalChecked();
325
- bool includeLineInfo =
326
- Nan::MaybeLocal<Boolean>(info[1].As<Boolean>()).ToLocalChecked()->Value();
327
-
328
- CpuProfile* profile = cpuProfiler->StopProfiling(name);
329
- Local<Value> translated_profile =
330
- TranslateTimeProfile(profile, includeLineInfo);
331
- profile->Delete();
332
- #if NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION
333
- // Dispose of CPU profiler to work around memory leak.
334
- cpuProfiler->Dispose();
335
- cpuProfiler = NULL;
336
- #endif
337
- info.GetReturnValue().Set(translated_profile);
338
- }
339
352
 
340
- // Signature:
341
- // setSamplingInterval(intervalMicros: number)
342
- NAN_METHOD(SetSamplingInterval) {
343
- #if NODE_MODULE_VERSION > NODE_8_0_MODULE_VERSION
344
- int us = info[0].As<Integer>()->Value();
345
- #else
346
- int us = info[0].As<Integer>()->IntegerValue();
347
- #endif
348
- #if NODE_MODULE_VERSION >= NODE_12_0_MODULE_VERSION
349
- samplingIntervalUS = us;
350
- #else
351
- cpuProfiler->SetSamplingInterval(us);
352
- #endif
353
- }
353
+ static NAN_MODULE_INIT(Init) {
354
+ Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
355
+ Local<String> className = Nan::New("TimeProfiler").ToLocalChecked();
356
+ tpl->SetClassName(className);
357
+ tpl->InstanceTemplate()->SetInternalFieldCount(1);
358
+
359
+ Nan::SetPrototypeMethod(tpl, "start", Start);
360
+ Nan::SetPrototypeMethod(tpl, "stop", Stop);
354
361
 
355
- NAN_MODULE_INIT(InitAll) {
356
- Local<Object> timeProfiler = Nan::New<Object>();
357
- Nan::Set(timeProfiler, Nan::New("startProfiling").ToLocalChecked(),
358
- Nan::GetFunction(Nan::New<FunctionTemplate>(StartProfiling))
359
- .ToLocalChecked());
360
- Nan::Set(timeProfiler, Nan::New("stopProfiling").ToLocalChecked(),
361
- Nan::GetFunction(Nan::New<FunctionTemplate>(StopProfiling))
362
- .ToLocalChecked());
363
- Nan::Set(timeProfiler, Nan::New("setSamplingInterval").ToLocalChecked(),
364
- Nan::GetFunction(Nan::New<FunctionTemplate>(SetSamplingInterval))
365
- .ToLocalChecked());
366
- Nan::Set(target, Nan::New<String>("timeProfiler").ToLocalChecked(),
367
- timeProfiler);
362
+ constructor().Reset(Nan::GetFunction(tpl).ToLocalChecked());
363
+ Nan::Set(target, className, Nan::GetFunction(tpl).ToLocalChecked());
364
+ }
365
+ private:
366
+ CpuProfiler* cpuProfiler;
367
+ };
368
+
369
+ extern "C" NODE_MODULE_EXPORT void
370
+ NODE_MODULE_INITIALIZER(Local<Object> target,
371
+ Local<Value> module,
372
+ Local<Context> context) {
373
+ TimeProfiler::Init(target);
368
374
 
369
375
  Local<Object> heapProfiler = Nan::New<Object>();
370
- Nan::Set(
371
- heapProfiler, Nan::New("startSamplingHeapProfiler").ToLocalChecked(),
372
- Nan::GetFunction(Nan::New<FunctionTemplate>(StartSamplingHeapProfiler))
373
- .ToLocalChecked());
374
- Nan::Set(
375
- heapProfiler, Nan::New("stopSamplingHeapProfiler").ToLocalChecked(),
376
- Nan::GetFunction(Nan::New<FunctionTemplate>(StopSamplingHeapProfiler))
377
- .ToLocalChecked());
378
- Nan::Set(heapProfiler, Nan::New("getAllocationProfile").ToLocalChecked(),
379
- Nan::GetFunction(Nan::New<FunctionTemplate>(GetAllocationProfile))
380
- .ToLocalChecked());
376
+ Nan::SetMethod(heapProfiler, "startSamplingHeapProfiler",
377
+ StartSamplingHeapProfiler);
378
+ Nan::SetMethod(heapProfiler, "stopSamplingHeapProfiler",
379
+ StopSamplingHeapProfiler);
380
+ Nan::SetMethod(heapProfiler, "getAllocationProfile",
381
+ GetAllocationProfile);
381
382
  Nan::Set(target, Nan::New<String>("heapProfiler").ToLocalChecked(),
382
383
  heapProfiler);
383
384
  }
384
-
385
- NODE_MODULE(google_cloud_profiler, InitAll);
@@ -74,6 +74,8 @@ function serialize(profile, root, appendToSamples, stringTable, ignoreSamplesPat
74
74
  if (ignoreSamplesPath && node.scriptName.indexOf(ignoreSamplesPath) > -1) {
75
75
  continue;
76
76
  }
77
+ if (node.name === '(idle)' || node.name === '(program)')
78
+ continue;
77
79
  const stack = entry.stack;
78
80
  const location = getLocation(node, sourceMapper);
79
81
  stack.unshift(location.id);
@@ -148,13 +150,13 @@ function createSampleCountValueType(table) {
148
150
  });
149
151
  }
150
152
  /**
151
- * @return value type for time samples (type:wall, units:microseconds), and
153
+ * @return value type for time samples (type:wall, units:nanoseconds), and
152
154
  * adds strings used in this value type to the table.
153
155
  */
154
156
  function createTimeValueType(table) {
155
157
  return new profile_1.perftools.profiles.ValueType({
156
158
  type: table.getIndexOrAdd('wall'),
157
- unit: table.getIndexOrAdd('microseconds'),
159
+ unit: table.getIndexOrAdd('nanoseconds'),
158
160
  });
159
161
  }
160
162
  /**
@@ -185,11 +187,12 @@ function createAllocationValueType(table) {
185
187
  * @param intervalMicros - average time (microseconds) between samples.
186
188
  */
187
189
  function serializeTimeProfile(prof, intervalMicros, sourceMapper) {
190
+ const intervalNanos = intervalMicros * 1000;
188
191
  const appendTimeEntryToSamples = (entry, samples) => {
189
192
  if (entry.node.hitCount > 0) {
190
193
  const sample = new profile_1.perftools.profiles.Sample({
191
194
  locationId: entry.stack,
192
- value: [entry.node.hitCount, entry.node.hitCount * intervalMicros],
195
+ value: [entry.node.hitCount, entry.node.hitCount * intervalNanos],
193
196
  });
194
197
  samples.push(sample);
195
198
  }
@@ -1 +1 @@
1
- {"version":3,"file":"profile-serializer.js","sourceRoot":"","sources":["../../ts/src/profile-serializer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iDAA8C;AAmC9C,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;AAED;;;GAGG;AACH,MAAM,WAAW;IAIf;QACE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC5C,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,GAAW;QACvB,IAAI,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,OAAO,GAAG,CAAC;SACZ;QACD,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAC9B,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAED;;;;;;;;;;;GAWG;AACH,SAAS,SAAS,CAChB,OAAoC,EACpC,IAAO,EACP,eAAwC,EACxC,WAAwB,EACxB,iBAA0B,EAC1B,YAA2B;IAE3B,MAAM,OAAO,GAAgC,EAAE,CAAC;IAChD,MAAM,SAAS,GAAkC,EAAE,CAAC;IACpD,MAAM,SAAS,GAAkC,EAAE,CAAC;IACpD,MAAM,aAAa,GAAG,IAAI,GAA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C,QAAQ,CAAC,MAAM,CAAC;oBAC3C,UAAU,EAAE,KAAK,CAAC,KAAK;oBACvB,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC;oBACnD,oCAAoC;iBACrC,CAAC,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACtB;SACF;IACH,CAAC,CAAC;IAEJ,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IACtC,MAAM,eAAe,GAAG,0BAA0B,CAAC,WAAW,CAAC,CAAC;IAChE,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC;IAEnE,MAAM,OAAO,GAAG;QACd,UAAU,EAAE,CAAC,eAAe,EAAE,mBAAmB,CAAC;QAClD,SAAS,EAAE,cAAc;QACzB,UAAU,EAAE,mBAAmB;QAC/B,MAAM,EAAE,aAAa;KACtB,CAAC;IAEF,SAAS,CACP,OAAO,EACP,IAAI,EACJ,wBAAwB,EACxB,WAAW,EACX,iBAAiB,EACjB,YAAY,CACb,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AA5CD,oDA4CC"}
@@ -1,4 +1 @@
1
- import { TimeProfile } from './v8-types';
2
- export declare function startProfiling(runName: string, includeLineInfo?: boolean): void;
3
- export declare function stopProfiling(runName: string, includeLineInfo?: boolean): TimeProfile;
4
- export declare function setSamplingInterval(intervalMicros: number): void;
1
+ export declare const TimeProfiler: any;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setSamplingInterval = exports.stopProfiling = exports.startProfiling = void 0;
3
+ exports.TimeProfiler = void 0;
4
4
  /**
5
5
  * Copyright 2018 Google Inc. All Rights Reserved.
6
6
  *
@@ -16,20 +16,8 @@ exports.setSamplingInterval = exports.stopProfiling = exports.startProfiling = v
16
16
  * See the License for the specific language governing permissions and
17
17
  * limitations under the License.
18
18
  */
19
- const path = require("path");
19
+ const path_1 = require("path");
20
20
  const findBinding = require('node-gyp-build');
21
- const profiler = findBinding(path.join(__dirname, '..', '..'));
22
- // Wrappers around native time profiler functions.
23
- function startProfiling(runName, includeLineInfo) {
24
- profiler.timeProfiler.startProfiling(runName, includeLineInfo || false);
25
- }
26
- exports.startProfiling = startProfiling;
27
- function stopProfiling(runName, includeLineInfo) {
28
- return profiler.timeProfiler.stopProfiling(runName, includeLineInfo || false);
29
- }
30
- exports.stopProfiling = stopProfiling;
31
- function setSamplingInterval(intervalMicros) {
32
- profiler.timeProfiler.setSamplingInterval(intervalMicros);
33
- }
34
- exports.setSamplingInterval = setSamplingInterval;
21
+ const profiler = findBinding(path_1.join(__dirname, '..', '..'));
22
+ exports.TimeProfiler = profiler.TimeProfiler;
35
23
  //# sourceMappingURL=time-profiler-bindings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"time-profiler-bindings.js","sourceRoot":"","sources":["../../ts/src/time-profiler-bindings.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,6BAA6B;AAG7B,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE/D,kDAAkD;AAClD,SAAgB,cAAc,CAAC,OAAe,EAAE,eAAyB;IACvE,QAAQ,CAAC,YAAY,CAAC,cAAc,CAAC,OAAO,EAAE,eAAe,IAAI,KAAK,CAAC,CAAC;AAC1E,CAAC;AAFD,wCAEC;AAED,SAAgB,aAAa,CAC3B,OAAe,EACf,eAAyB;IAEzB,OAAO,QAAQ,CAAC,YAAY,CAAC,aAAa,CAAC,OAAO,EAAE,eAAe,IAAI,KAAK,CAAC,CAAC;AAChF,CAAC;AALD,sCAKC;AAED,SAAgB,mBAAmB,CAAC,cAAsB;IACxD,QAAQ,CAAC,YAAY,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC;AAC5D,CAAC;AAFD,kDAEC"}
1
+ {"version":3,"file":"time-profiler-bindings.js","sourceRoot":"","sources":["../../ts/src/time-profiler-bindings.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,+BAA0B;AAE1B,MAAM,WAAW,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC9C,MAAM,QAAQ,GAAG,WAAW,CAAC,WAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE7C,QAAA,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC"}
@@ -28,7 +28,6 @@ exports.start = exports.profile = void 0;
28
28
  const delay_1 = require("delay");
29
29
  const profile_serializer_1 = require("./profile-serializer");
30
30
  const time_profiler_bindings_1 = require("./time-profiler-bindings");
31
- let profiling = false;
32
31
  const DEFAULT_INTERVAL_MICROS = 1000;
33
32
  function profile(options) {
34
33
  return __awaiter(this, void 0, void 0, function* () {
@@ -38,26 +37,27 @@ function profile(options) {
38
37
  });
39
38
  }
40
39
  exports.profile = profile;
41
- function start(intervalMicros = DEFAULT_INTERVAL_MICROS, name, sourceMapper, lineNumbers) {
42
- if (profiling) {
43
- throw new Error('already profiling');
44
- }
45
- profiling = true;
40
+ function start(intervalMicros = DEFAULT_INTERVAL_MICROS, name, sourceMapper, lineNumbers = true) {
46
41
  const runName = name || `pprof-${Date.now()}-${Math.random()}`;
47
- time_profiler_bindings_1.setSamplingInterval(intervalMicros);
42
+ const profiler = new time_profiler_bindings_1.TimeProfiler(intervalMicros);
43
+ profiler.start(runName, lineNumbers);
48
44
  // Node.js contains an undocumented API for reporting idle status to V8.
49
45
  // This lets the profiler distinguish idle time from time spent in native
50
46
  // code. Ideally this should be default behavior. Until then, use the
51
47
  // undocumented API.
52
48
  // See https://github.com/nodejs/node/issues/19009#issuecomment-403161559.
53
49
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
- process._startProfilerIdleNotifier();
55
- time_profiler_bindings_1.startProfiling(runName, lineNumbers);
50
+ if (typeof process._startProfilerIdleNotifier === 'function') {
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ process._startProfilerIdleNotifier();
53
+ }
56
54
  return function stop() {
57
- profiling = false;
58
- const result = time_profiler_bindings_1.stopProfiling(runName, lineNumbers);
55
+ const result = profiler.stop(runName, lineNumbers);
59
56
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
- process._stopProfilerIdleNotifier();
57
+ if (typeof process._stopProfilerIdleNotifier === 'function') {
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
+ process._stopProfilerIdleNotifier();
60
+ }
61
61
  const profile = profile_serializer_1.serializeTimeProfile(result, intervalMicros, sourceMapper);
62
62
  return profile;
63
63
  };
@@ -1 +1 @@
1
- {"version":3,"file":"time-profiler.js","sourceRoot":"","sources":["../../ts/src/time-profiler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,iCAA0B;AAE1B,6DAA0D;AAE1D,qEAIkC;AAElC,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,MAAM,uBAAuB,GAAiB,IAAI,CAAC;AAsBnD,SAAsB,OAAO,CAAC,OAA4B;;QACxD,MAAM,IAAI,GAAG,KAAK,CAChB,OAAO,CAAC,cAAc,IAAI,uBAAuB,EACjD,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,WAAW,CACpB,CAAC;QACF,MAAM,eAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QACpC,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;CAAA;AATD,0BASC;AAED,SAAgB,KAAK,CACnB,iBAA+B,uBAAuB,EACtD,IAAa,EACb,YAA2B,EAC3B,WAAqB;IAErB,IAAI,SAAS,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;KACtC;IAED,SAAS,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EACb,YAA2B,EAC3B,WAAW,GAAG,IAAI;IAElB,MAAM,OAAO,GAAG,IAAI,IAAI,SAAS,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IAC/D,MAAM,QAAQ,GAAG,IAAI,qCAAY,CAAC,cAAc,CAAC,CAAC;IAClD,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACrC,wEAAwE;IACxE,yEAAyE;IACzE,qEAAqE;IACrE,oBAAoB;IACpB,0EAA0E;IAC1E,8DAA8D;IAC9D,IAAI,OAAQ,OAAe,CAAC,0BAA0B,KAAK,UAAU,EAAE;QACrE,8DAA8D;QAC7D,OAAe,CAAC,0BAA0B,EAAE,CAAC;KAC/C;IACD,OAAO,SAAS,IAAI;QAClB,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACnD,8DAA8D;QAC9D,IAAI,OAAQ,OAAe,CAAC,yBAAyB,KAAK,UAAU,EAAE;YACpE,8DAA8D;YAC7D,OAAe,CAAC,yBAAyB,EAAE,CAAC;SAC9C;QACD,MAAM,OAAO,GAAG,yCAAoB,CAAC,MAAM,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QAC3E,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC;AA7BD,sBA6BC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/pprof",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "pprof support for Node.js",
5
5
  "repository": "datadog/pprof-nodejs",
6
6
  "main": "out/src/index.js",
@@ -9,7 +9,7 @@
9
9
  "preinstall": "node scripts/preinstall.js",
10
10
  "install": "(node scripts/should_rebuild && node-gyp-build) || exit 0",
11
11
  "rebuild": "node-gyp rebuild --jobs=max",
12
- "test": "nyc mocha out/test/test-*.js",
12
+ "test": "nyc mocha out/test/test-*.js",
13
13
  "check": "gts check",
14
14
  "clean": "gts clean && node-gyp clean",
15
15
  "codecov": "nyc report --reporter=json && codecov -f coverage/*.json",
@@ -37,6 +37,7 @@
37
37
  "delay": "^5.0.0",
38
38
  "findit2": "^2.2.3",
39
39
  "nan": "^2.14.0",
40
+ "node-gyp-build": "^3.9.0",
40
41
  "p-limit": "^3.0.0",
41
42
  "pify": "^5.0.0",
42
43
  "protobufjs": "~6.11.0",
@@ -64,7 +65,6 @@
64
65
  "linkinator": "^2.0.0",
65
66
  "mkdirp": "^1.0.4",
66
67
  "mocha": "^8.0.0",
67
- "node-gyp-build": "^4.2.3",
68
68
  "nyc": "^15.0.0",
69
69
  "rimraf": "^3.0.2",
70
70
  "semver": "^7.3.5",
@@ -84,7 +84,9 @@
84
84
  "package-lock.json",
85
85
  "package.json",
86
86
  "README.md",
87
- "scripts",
87
+ "scripts/preinstall.js",
88
+ "scripts/require-package-json.js",
89
+ "scripts/should_rebuild.js",
88
90
  "prebuilds"
89
91
  ],
90
92
  "nyc": {
@@ -95,6 +97,6 @@
95
97
  ]
96
98
  },
97
99
  "engines": {
98
- "node": ">=10.4.1"
100
+ "node": ">=12.0.0"
99
101
  }
100
102
  }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,57 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
- const os = require('os');
5
- const fs = require('fs');
6
- const mkdirp = require('mkdirp');
7
- const {execSync} = require('child_process');
8
- const semver = require('semver');
9
- const checksum = require('checksum');
10
-
11
- const platform = os.platform();
12
- const arch = process.env.ARCH || os.arch();
13
-
14
- const {NODE_VERSIONS = '>=12'} = process.env;
15
-
16
- // https://nodejs.org/en/download/releases/
17
- const targets = [
18
- {version: '12.0.0', abi: '72'},
19
- {version: '13.0.0', abi: '79'},
20
- {version: '14.0.0', abi: '83'},
21
- {version: '15.0.0', abi: '88'},
22
- {version: '16.0.0', abi: '93'},
23
- ].filter(target => semver.satisfies(target.version, NODE_VERSIONS));
24
-
25
- prebuildify();
26
-
27
- function prebuildify() {
28
- const cache = path.join(os.tmpdir(), 'prebuilds');
29
-
30
- mkdirp.sync(cache);
31
- mkdirp.sync(`prebuilds/${platform}-${arch}`);
32
-
33
- targets.forEach(target => {
34
- const output = `prebuilds/${platform}-${arch}/node-${target.abi}.node`;
35
- const cmd = [
36
- 'node-gyp rebuild',
37
- `--target=${target.version}`,
38
- `--target_arch=${arch}`,
39
- `--devdir=${cache}`,
40
- '--release',
41
- '--jobs=max',
42
- '--build_v8_with_gn=false',
43
- '--v8_enable_pointer_compression=""',
44
- '--v8_enable_31bit_smis_on_64bit_arch=""',
45
- '--enable_lto=false',
46
- ].join(' ');
47
-
48
- execSync(cmd, {stdio: [0, 1, 2]});
49
-
50
- const sum = checksum(fs.readFileSync('build/Release/dd-pprof.node'), {
51
- algorithm: 'sha256',
52
- });
53
-
54
- fs.writeFileSync(`${output}.sha1`, sum);
55
- fs.copyFileSync('build/Release/dd-pprof.node', output);
56
- });
57
- }
@@ -1,93 +0,0 @@
1
- 'use strict';
2
-
3
- const checksum = require('checksum');
4
- const fs = require('fs');
5
- const glob = require('glob');
6
- const os = require('os');
7
- const path = require('path');
8
- const tar = require('tar');
9
-
10
- const platforms = [
11
- 'darwin-ia32',
12
- 'darwin-x64',
13
- 'linux-ia32',
14
- 'linux-x64',
15
- 'win32-ia32',
16
- 'win32-x64',
17
- ];
18
-
19
- zipPrebuilds();
20
- extractPrebuilds();
21
- validatePrebuilds();
22
- createChecksum();
23
- copyPrebuilds();
24
-
25
- function zipPrebuilds() {
26
- tar.create(
27
- {
28
- gzip: true,
29
- sync: true,
30
- portable: true,
31
- strict: true,
32
- file: path.join(os.tmpdir(), 'prebuilds.tgz'),
33
- },
34
- glob.sync('prebuilds/**/*.node')
35
- );
36
- }
37
-
38
- function extractPrebuilds() {
39
- tar.extract({
40
- sync: true,
41
- strict: true,
42
- file: path.join(os.tmpdir(), 'prebuilds.tgz'),
43
- cwd: os.tmpdir(),
44
- });
45
- }
46
-
47
- function validatePrebuilds() {
48
- platforms.forEach(platform => {
49
- try {
50
- fs.readdirSync(path.join(os.tmpdir(), 'prebuilds', platform))
51
- .filter(file => /^node-\d+\.node$/.test(file))
52
- .forEach(file => {
53
- const content = fs.readFileSync(
54
- path.join('prebuilds', platform, file)
55
- );
56
- const sum = fs.readFileSync(
57
- path.join('prebuilds', platform, `${file}.sha1`),
58
- 'ascii'
59
- );
60
-
61
- if (sum !== checksum(content, {algorithm: 'sha256'})) {
62
- throw new Error(
63
- `Invalid checksum for "prebuilds/${platform}/${file}".`
64
- );
65
- }
66
- });
67
- } catch (e) {
68
- // skip missing platforms
69
- }
70
- });
71
- }
72
-
73
- function createChecksum() {
74
- const file = path.join(os.tmpdir(), 'prebuilds.tgz');
75
- const sum = checksum(fs.readFileSync(file), {algorithm: 'sha256'});
76
-
77
- fs.writeFileSync(`${file}.sha1`, sum);
78
- }
79
-
80
- function copyPrebuilds() {
81
- const basename = path.normalize(path.join(__dirname, '..'));
82
- const filename = 'prebuilds.tgz';
83
-
84
- fs.copyFileSync(
85
- path.join(os.tmpdir(), filename),
86
- path.join(basename, filename)
87
- );
88
-
89
- fs.copyFileSync(
90
- path.join(os.tmpdir(), `${filename}.sha1`),
91
- path.join(basename, `${filename}.sha1`)
92
- );
93
- }
@@ -1,201 +0,0 @@
1
- 'use strict';
2
-
3
- /* eslint-disable no-console */
4
-
5
- const axios = require('axios');
6
- const checksum = require('checksum');
7
- const fs = require('fs');
8
- const os = require('os');
9
- const path = require('path');
10
- const rimraf = require('rimraf');
11
- const tar = require('tar');
12
- const {execSync} = require('child_process');
13
-
14
- // https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
15
- const color = {
16
- GRAY: '\\033[1;90m',
17
- CYAN: '\\033[1;36m',
18
- NONE: '\\033[0m',
19
- };
20
-
21
- const {CIRCLE_TOKEN} = process.env;
22
-
23
- title('Downloading and compiling files for release.');
24
-
25
- const revision = execPipe('git rev-parse HEAD');
26
-
27
- console.log(revision);
28
-
29
- const branch = execPipe('git symbolic-ref --short HEAD');
30
-
31
- console.log(branch);
32
-
33
- const headers = CIRCLE_TOKEN
34
- ? {
35
- 'circle-token': CIRCLE_TOKEN,
36
- }
37
- : {};
38
- const client = axios.create({
39
- baseURL: 'https://circleci.com/api/v2/',
40
- timeout: 5000,
41
- headers,
42
- });
43
-
44
- const fetch = (url, options) => {
45
- console.log(`GET ${url}`);
46
-
47
- return client
48
- .get(url, options)
49
- .catch(() => client.get(url, options))
50
- .catch(() => client.get(url, options));
51
- };
52
-
53
- getPipeline()
54
- .then(getWorkflow)
55
- .then(getPrebuildsJob)
56
- .then(getPrebuildArtifacts)
57
- .then(downloadArtifacts)
58
- .then(validatePrebuilds)
59
- .then(extractPrebuilds)
60
- .catch(e => {
61
- process.exitCode = 1;
62
- console.error(e);
63
- });
64
-
65
- function getPipeline() {
66
- return fetch(
67
- `project/github/DataDog/pprof-nodejs/pipeline?branch=${branch}`
68
- ).then(response => {
69
- const pipeline = response.data.items
70
- .filter(item => item.trigger.type !== 'schedule')
71
- .find(item => item.vcs.revision === revision);
72
-
73
- if (!pipeline) {
74
- throw new Error(
75
- `Unable to find CircleCI pipeline for ${branch}@${revision}.`
76
- );
77
- }
78
-
79
- return pipeline;
80
- });
81
- }
82
-
83
- function getWorkflow(pipeline) {
84
- return fetch(`pipeline/${pipeline.id}/workflow`).then(response => {
85
- const workflows = response.data.items.sort((a, b) =>
86
- a.stopped_at < b.stopped_at ? 1 : -1
87
- );
88
- const workflow = workflows.find(workflow => workflow.name === 'prebuild');
89
-
90
- if (!workflow) {
91
- throw new Error(
92
- `Unable to find CircleCI workflow for pipeline ${pipeline.id}.`
93
- );
94
- }
95
-
96
- if (!workflow.stopped_at) {
97
- throw new Error(
98
- `Workflow ${workflow.id} is still running for pipeline ${pipeline.id}.`
99
- );
100
- }
101
-
102
- if (workflow.status !== 'success') {
103
- throw new Error(
104
- `Aborting because CircleCI workflow ${workflow.id} did not succeed.`
105
- );
106
- }
107
-
108
- return workflow;
109
- });
110
- }
111
-
112
- function getPrebuildsJob(workflow) {
113
- return fetch(`workflow/${workflow.id}/job`).then(response => {
114
- const job = response.data.items.find(item => item.name === 'prebuilds');
115
-
116
- if (!job) {
117
- throw new Error(`Missing prebuild jobs in workflow ${workflow.id}.`);
118
- }
119
-
120
- return job;
121
- });
122
- }
123
-
124
- function getPrebuildArtifacts(job) {
125
- return fetch(
126
- `project/github/DataDog/pprof-nodejs/${job.job_number}/artifacts`
127
- ).then(response => {
128
- const artifacts = response.data.items.filter(artifact =>
129
- /\/prebuilds\.tgz/.test(artifact.url)
130
- );
131
-
132
- if (artifacts.length === 0) {
133
- throw new Error(`Missing artifacts in job ${job.job_number}.`);
134
- }
135
-
136
- return artifacts;
137
- });
138
- }
139
-
140
- function downloadArtifacts(artifacts) {
141
- const files = artifacts.map(artifact => artifact.url);
142
-
143
- return Promise.all(files.map(downloadArtifact));
144
- }
145
-
146
- function downloadArtifact(file) {
147
- return fetch(file, {responseType: 'stream'}).then(response => {
148
- const parts = file.split('/');
149
- const basename = os.tmpdir();
150
- const filename = parts.slice(-1)[0];
151
-
152
- return new Promise((resolve, reject) => {
153
- response.data
154
- .pipe(fs.createWriteStream(path.join(basename, filename)))
155
- .on('finish', () => resolve())
156
- .on('error', reject);
157
- });
158
- });
159
- }
160
-
161
- function validatePrebuilds() {
162
- const file = path.join(os.tmpdir(), 'prebuilds.tgz');
163
- const content = fs.readFileSync(file);
164
- const sum = fs.readFileSync(path.join(`${file}.sha1`), 'ascii');
165
-
166
- if (sum !== checksum(content, {algorithm: 'sha256'})) {
167
- throw new Error('Invalid checksum for "prebuilds.tgz".');
168
- }
169
- }
170
-
171
- function extractPrebuilds() {
172
- rimraf.sync('prebuilds');
173
-
174
- return tar.extract({
175
- file: path.join(os.tmpdir(), 'prebuilds.tgz'),
176
- cwd: path.join(__dirname, '..'),
177
- });
178
- }
179
-
180
- function exec(command, options) {
181
- options = Object.assign({stdio: [0, 1, 2]}, options);
182
-
183
- execSync(`echo "${color.GRAY}$ ${command}${color.NONE}"`, {stdio: [0, 1, 2]});
184
-
185
- return execSync(command, options);
186
- }
187
-
188
- function execPipe(command, options) {
189
- return exec(command, Object.assign({stdio: 'pipe'}, options))
190
- .toString()
191
- .replace(/\n$/, '');
192
- }
193
-
194
- function title(str) {
195
- const options = {stdio: [0, 1, 2]};
196
- const line = ''.padStart(str.length, '=');
197
-
198
- execSync(`echo "${color.CYAN}${line}${color.NONE}"`, options);
199
- execSync(`echo "${color.CYAN}${str}${color.NONE}"`, options);
200
- execSync(`echo "${color.CYAN}${line}${color.NONE}"`, options);
201
- }