@datadog/pprof 0.3.0 → 0.5.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 (118) hide show
  1. package/binding.gyp +130 -31
  2. package/bindings/binding.cc +13 -0
  3. package/bindings/code-event-record.cc +115 -0
  4. package/bindings/code-event-record.hh +67 -0
  5. package/bindings/code-map.cc +112 -0
  6. package/bindings/code-map.hh +47 -0
  7. package/bindings/cpu-time.cc +89 -0
  8. package/bindings/cpu-time.hh +35 -0
  9. package/bindings/location.cc +117 -0
  10. package/bindings/location.hh +43 -0
  11. package/bindings/per-isolate-data.cc +42 -0
  12. package/bindings/per-isolate-data.hh +26 -0
  13. package/bindings/profilers/cpu.cc +285 -0
  14. package/bindings/profilers/cpu.hh +78 -0
  15. package/bindings/profilers/heap.cc +112 -0
  16. package/bindings/profilers/heap.hh +40 -0
  17. package/bindings/profilers/wall.cc +306 -0
  18. package/bindings/profilers/wall.hh +28 -0
  19. package/bindings/sample.cc +160 -0
  20. package/bindings/sample.hh +48 -0
  21. package/bindings/test/binding.cc +59 -0
  22. package/bindings/test/code-event-record.test.cc +81 -0
  23. package/bindings/test/code-event-record.test.hh +5 -0
  24. package/bindings/test/code-map.test.cc +77 -0
  25. package/bindings/test/code-map.test.hh +5 -0
  26. package/bindings/test/cpu-time.test.cc +30 -0
  27. package/bindings/test/cpu-time.test.hh +5 -0
  28. package/bindings/test/location.test.cc +39 -0
  29. package/bindings/test/location.test.hh +5 -0
  30. package/bindings/test/profilers/cpu.test.cc +88 -0
  31. package/bindings/test/profilers/cpu.test.hh +5 -0
  32. package/bindings/test/sample.test.cc +128 -0
  33. package/bindings/test/sample.test.hh +5 -0
  34. package/bindings/test/tap.h +830 -0
  35. package/bindings/wrap.hh +20 -0
  36. package/out/src/cpu-profiler-bindings.d.ts +1 -0
  37. package/out/src/cpu-profiler-bindings.js +23 -0
  38. package/out/src/cpu-profiler-bindings.js.map +1 -0
  39. package/out/src/cpu-profiler.d.ts +19 -0
  40. package/out/src/cpu-profiler.js +94 -0
  41. package/out/src/cpu-profiler.js.map +1 -0
  42. package/out/src/index.d.ts +2 -0
  43. package/out/src/index.js +3 -1
  44. package/out/src/index.js.map +1 -1
  45. package/out/src/profile-encoder.js +3 -14
  46. package/out/src/profile-encoder.js.map +1 -1
  47. package/out/src/profile-serializer.d.ts +9 -1
  48. package/out/src/profile-serializer.js +73 -1
  49. package/out/src/profile-serializer.js.map +1 -1
  50. package/out/src/sourcemapper/sourcemapper.js +81 -88
  51. package/out/src/sourcemapper/sourcemapper.js.map +1 -1
  52. package/out/src/time-profiler.js +4 -15
  53. package/out/src/time-profiler.js.map +1 -1
  54. package/out/src/v8-types.d.ts +38 -0
  55. package/out/third_party/cloud-debug-nodejs/src/agent/io/scanner.js +6 -17
  56. package/out/third_party/cloud-debug-nodejs/src/agent/io/scanner.js.map +1 -1
  57. package/package.json +12 -14
  58. package/prebuilds/darwin-arm64/node-102.node +0 -0
  59. package/prebuilds/darwin-arm64/node-108.node +0 -0
  60. package/prebuilds/darwin-arm64/node-72.node +0 -0
  61. package/prebuilds/darwin-arm64/node-79.node +0 -0
  62. package/prebuilds/darwin-arm64/node-83.node +0 -0
  63. package/prebuilds/darwin-arm64/node-88.node +0 -0
  64. package/prebuilds/darwin-arm64/node-93.node +0 -0
  65. package/prebuilds/darwin-ia32/node-102.node +0 -0
  66. package/prebuilds/darwin-ia32/node-108.node +0 -0
  67. package/prebuilds/darwin-ia32/node-72.node +0 -0
  68. package/prebuilds/darwin-ia32/node-79.node +0 -0
  69. package/prebuilds/darwin-ia32/node-83.node +0 -0
  70. package/prebuilds/darwin-ia32/node-88.node +0 -0
  71. package/prebuilds/darwin-ia32/node-93.node +0 -0
  72. package/prebuilds/darwin-x64/node-102.node +0 -0
  73. package/prebuilds/darwin-x64/node-108.node +0 -0
  74. package/prebuilds/darwin-x64/node-72.node +0 -0
  75. package/prebuilds/darwin-x64/node-79.node +0 -0
  76. package/prebuilds/darwin-x64/node-83.node +0 -0
  77. package/prebuilds/darwin-x64/node-88.node +0 -0
  78. package/prebuilds/darwin-x64/node-93.node +0 -0
  79. package/prebuilds/linux-arm/node-102.node +0 -0
  80. package/prebuilds/linux-arm/node-108.node +0 -0
  81. package/prebuilds/linux-arm/node-72.node +0 -0
  82. package/prebuilds/linux-arm/node-79.node +0 -0
  83. package/prebuilds/linux-arm/node-83.node +0 -0
  84. package/prebuilds/linux-arm/node-88.node +0 -0
  85. package/prebuilds/linux-arm/node-93.node +0 -0
  86. package/prebuilds/linux-arm64/node-102.node +0 -0
  87. package/prebuilds/linux-arm64/node-108.node +0 -0
  88. package/prebuilds/linux-arm64/node-72.node +0 -0
  89. package/prebuilds/linux-arm64/node-79.node +0 -0
  90. package/prebuilds/linux-arm64/node-83.node +0 -0
  91. package/prebuilds/linux-arm64/node-88.node +0 -0
  92. package/prebuilds/linux-arm64/node-93.node +0 -0
  93. package/prebuilds/linux-ia32/node-72.node +0 -0
  94. package/prebuilds/linux-ia32/node-79.node +0 -0
  95. package/prebuilds/linux-x64/node-102.node +0 -0
  96. package/prebuilds/linux-x64/node-108.node +0 -0
  97. package/prebuilds/linux-x64/node-72.node +0 -0
  98. package/prebuilds/linux-x64/node-79.node +0 -0
  99. package/prebuilds/linux-x64/node-83.node +0 -0
  100. package/prebuilds/linux-x64/node-88.node +0 -0
  101. package/prebuilds/linux-x64/node-93.node +0 -0
  102. package/prebuilds/win32-ia32/node-102.node +0 -0
  103. package/prebuilds/win32-ia32/node-72.node +0 -0
  104. package/prebuilds/win32-ia32/node-79.node +0 -0
  105. package/prebuilds/win32-ia32/node-83.node +0 -0
  106. package/prebuilds/win32-ia32/node-88.node +0 -0
  107. package/prebuilds/win32-ia32/node-93.node +0 -0
  108. package/prebuilds/win32-x64/node-102.node +0 -0
  109. package/prebuilds/win32-x64/node-108.node +0 -0
  110. package/prebuilds/win32-x64/node-72.node +0 -0
  111. package/prebuilds/win32-x64/node-79.node +0 -0
  112. package/prebuilds/win32-x64/node-83.node +0 -0
  113. package/prebuilds/win32-x64/node-88.node +0 -0
  114. package/prebuilds/win32-x64/node-93.node +0 -0
  115. package/scripts/require-package-json.js +11 -11
  116. package/scripts/should_rebuild.js +3 -3
  117. package/bindings/profiler.cc +0 -406
  118. package/scripts/preinstall.js +0 -36
@@ -0,0 +1,20 @@
1
+ #pragma once
2
+
3
+ #include <v8.h> // cppcheck-suppress missingIncludeSystem
4
+
5
+ namespace dd {
6
+
7
+ class LabelWrap {
8
+ protected:
9
+ v8::Global<v8::Value> handle_;
10
+
11
+ public:
12
+ LabelWrap(v8::Local<v8::Value> object)
13
+ : handle_(v8::Isolate::GetCurrent(), object) {}
14
+
15
+ v8::Local<v8::Value> handle() {
16
+ return handle_.Get(v8::Isolate::GetCurrent());
17
+ }
18
+ };
19
+
20
+ }; // namespace dd
@@ -0,0 +1 @@
1
+ export declare const CpuProfiler: any;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CpuProfiler = void 0;
4
+ /**
5
+ * Copyright 2018 Google Inc. All Rights Reserved.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const path_1 = require("path");
20
+ const findBinding = require('node-gyp-build');
21
+ const profiler = findBinding(path_1.join(__dirname, '..', '..'));
22
+ exports.CpuProfiler = profiler.CpuProfiler;
23
+ //# sourceMappingURL=cpu-profiler-bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cpu-profiler-bindings.js","sourceRoot":"","sources":["../../ts/src/cpu-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,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2017 Google Inc. All Rights Reserved.
3
+ *
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 { CpuProfiler as NativeCpuProfiler } from './cpu-profiler-bindings';
17
+ export default class CpuProfiler extends NativeCpuProfiler {
18
+ profile(): import("../../proto/profile").perftools.profiles.IProfile | undefined;
19
+ }
@@ -0,0 +1,94 @@
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
+ const profile_serializer_1 = require("./profile-serializer");
19
+ const cpu_profiler_bindings_1 = require("./cpu-profiler-bindings");
20
+ function isNodeEqual(a, b) {
21
+ if (a.name !== b.name)
22
+ return false;
23
+ if (a.scriptName !== b.scriptName)
24
+ return false;
25
+ if (a.scriptId !== b.scriptId)
26
+ return false;
27
+ if (a.lineNumber !== b.lineNumber)
28
+ return false;
29
+ if (a.columnNumber !== b.columnNumber)
30
+ return false;
31
+ return true;
32
+ }
33
+ function makeNode(location) {
34
+ return {
35
+ name: location.comment || location.functionName,
36
+ scriptName: location.scriptName || '',
37
+ scriptId: location.scriptId,
38
+ lineNumber: location.line,
39
+ columnNumber: location.column,
40
+ hitCount: 0,
41
+ cpuTime: 0,
42
+ labelSets: [],
43
+ children: [],
44
+ };
45
+ }
46
+ class CpuProfiler extends cpu_profiler_bindings_1.CpuProfiler {
47
+ profile() {
48
+ if (this.frequency === 0)
49
+ return;
50
+ const profile = super.profile();
51
+ const timeProfile = {
52
+ startTime: profile.startTime,
53
+ endTime: profile.endTime,
54
+ topDownRoot: {
55
+ name: '(root)',
56
+ scriptName: '',
57
+ scriptId: 0,
58
+ lineNumber: 0,
59
+ columnNumber: 0,
60
+ hitCount: 0,
61
+ cpuTime: 0,
62
+ labelSets: [],
63
+ children: [],
64
+ },
65
+ };
66
+ let targetNode = timeProfile.topDownRoot;
67
+ for (const sample of profile.samples) {
68
+ if (!sample)
69
+ continue;
70
+ locations: for (const location of sample.locations) {
71
+ const node = makeNode(location);
72
+ for (const found of targetNode.children) {
73
+ const foundNode = found;
74
+ if (isNodeEqual(node, foundNode)) {
75
+ targetNode = foundNode;
76
+ continue locations;
77
+ }
78
+ }
79
+ targetNode.children.push(node);
80
+ targetNode = node;
81
+ }
82
+ targetNode.cpuTime += sample.cpuTime;
83
+ targetNode.hitCount++;
84
+ if (sample.labels) {
85
+ targetNode.labelSets.push(sample.labels);
86
+ }
87
+ targetNode = timeProfile.topDownRoot;
88
+ }
89
+ const intervalMicros = 1000 / this.frequency;
90
+ return profile_serializer_1.serializeCpuProfile(timeProfile, intervalMicros);
91
+ }
92
+ }
93
+ exports.default = CpuProfiler;
94
+ //# sourceMappingURL=cpu-profiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cpu-profiler.js","sourceRoot":"","sources":["../../ts/src/cpu-profiler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;AAEH,6DAAyD;AACzD,mEAAyE;AAQzE,SAAS,WAAW,CAAC,CAAiB,EAAE,CAAiB;IACvD,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IACpC,IAAI,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IAChD,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IAChD,IAAI,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,YAAY;QAAE,OAAO,KAAK,CAAC;IACpD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,QAAQ,CAAC,QAAmB;IACnC,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,YAAY;QAC/C,UAAU,EAAE,QAAQ,CAAC,UAAU,IAAI,EAAE;QACrC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,UAAU,EAAE,QAAQ,CAAC,IAAI;QACzB,YAAY,EAAE,QAAQ,CAAC,MAAM;QAC7B,QAAQ,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;QACV,SAAS,EAAE,EAAE;QACb,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC;AAED,MAAqB,WAAY,SAAQ,mCAAiB;IACxD,OAAO;QACL,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC;YAAE,OAAO;QAEjC,MAAM,OAAO,GAAsB,KAAK,CAAC,OA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AG,IAAI,GAAI,IAAI,CAAC,SAAoB,CAAC;QACzD,OAAO,wCAAmB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IAC1D,CAAC;CACF;AArDD,8BAqDC"}
@@ -1,8 +1,10 @@
1
+ import cpuProfiler from './cpu-profiler';
1
2
  import * as heapProfiler from './heap-profiler';
2
3
  import * as timeProfiler from './time-profiler';
3
4
  export { AllocationProfileNode, TimeProfileNode, ProfileNode } from './v8-types';
4
5
  export { encode, encodeSync } from './profile-encoder';
5
6
  export { SourceMapper } from './sourcemapper/sourcemapper';
7
+ export declare const CpuProfiler: typeof cpuProfiler;
6
8
  export declare const time: {
7
9
  profile: typeof timeProfiler.profile;
8
10
  start: typeof timeProfiler.start;
package/out/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.heap = exports.time = exports.SourceMapper = exports.encodeSync = exports.encode = void 0;
3
+ exports.heap = exports.time = exports.CpuProfiler = exports.SourceMapper = exports.encodeSync = exports.encode = void 0;
4
4
  /**
5
5
  * Copyright 2019 Google Inc. All Rights Reserved.
6
6
  *
@@ -17,6 +17,7 @@ exports.heap = exports.time = exports.SourceMapper = exports.encodeSync = export
17
17
  * limitations under the License.
18
18
  */
19
19
  const fs_1 = require("fs");
20
+ const cpu_profiler_1 = require("./cpu-profiler");
20
21
  const heapProfiler = require("./heap-profiler");
21
22
  const profile_encoder_1 = require("./profile-encoder");
22
23
  const timeProfiler = require("./time-profiler");
@@ -25,6 +26,7 @@ Object.defineProperty(exports, "encode", { enumerable: true, get: function () {
25
26
  Object.defineProperty(exports, "encodeSync", { enumerable: true, get: function () { return profile_encoder_2.encodeSync; } });
26
27
  var sourcemapper_1 = require("./sourcemapper/sourcemapper");
27
28
  Object.defineProperty(exports, "SourceMapper", { enumerable: true, get: function () { return sourcemapper_1.SourceMapper; } });
29
+ exports.CpuProfiler = cpu_profiler_1.default;
28
30
  exports.time = {
29
31
  profile: timeProfiler.profile,
30
32
  start: timeProfiler.start,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,2BAAiC;AAEjC,gDAAgD;AAChD,uDAA6C;AAC7C,gDAAgD;AAGhD,qDAAqD;AAA7C,yGAAA,MAAM,OAAA;AAAE,6GAAA,UAAU,OAAA;AAC1B,4DAAyD;AAAjD,4GAAA,YAAY,OAAA;AAEP,QAAA,IAAI,GAAG;IAClB,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,KAAK,EAAE,YAAY,CAAC,KAAK;CAC1B,CAAC;AAEW,QAAA,IAAI,GAAG;IAClB,KAAK,EAAE,YAAY,CAAC,KAAK;IACzB,IAAI,EAAE,YAAY,CAAC,IAAI;IACvB,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,SAAS,EAAE,YAAY,CAAC,SAAS;CAClC,CAAC;AAEF,6CAA6C;AAC7C,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,kBAAkB,EAAE;IAC5D,MAAM,IAAI,GAAG,YAAI,CAAC,KAAK,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACtB,uEAAuE;QACvE,kBAAkB;QAClB,MAAM,OAAO,GAAG,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,4BAAU,CAAC,OAAO,CAAC,CAAC;QACnC,kBAAa,CAAC,iBAAiB,OAAO,CAAC,GAAG,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;CACJ"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACH,2BAAiC;AAEjC,iDAAyC;AACzC,gDAAgD;AAChD,uDAA6C;AAC7C,gDAAgD;AAGhD,qDAAqD;AAA7C,yGAAA,MAAM,OAAA;AAAE,6GAAA,UAAU,OAAA;AAC1B,4DAAyD;AAAjD,4GAAA,YAAY,OAAA;AAEP,QAAA,WAAW,GAAG,sBAAW,CAAC;AAE1B,QAAA,IAAI,GAAG;IAClB,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,KAAK,EAAE,YAAY,CAAC,KAAK;CAC1B,CAAC;AAEW,QAAA,IAAI,GAAG;IAClB,KAAK,EAAE,YAAY,CAAC,KAAK;IACzB,IAAI,EAAE,YAAY,CAAC,IAAI;IACvB,OAAO,EAAE,YAAY,CAAC,OAAO;IAC7B,SAAS,EAAE,YAAY,CAAC,SAAS;CAClC,CAAC;AAEF,6CAA6C;AAC7C,IAAI,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,kBAAkB,EAAE;IAC5D,MAAM,IAAI,GAAG,YAAI,CAAC,KAAK,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACtB,uEAAuE;QACvE,kBAAkB;QAClB,MAAM,OAAO,GAAG,IAAI,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,4BAAU,CAAC,OAAO,CAAC,CAAC;QACnC,kBAAa,CAAC,iBAAiB,OAAO,CAAC,GAAG,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;CACJ"}
@@ -14,26 +14,15 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
17
  Object.defineProperty(exports, "__esModule", { value: true });
27
18
  exports.encodeSync = exports.encode = void 0;
28
19
  const pify = require("pify");
29
20
  const zlib_1 = require("zlib");
30
21
  const profile_1 = require("../../proto/profile");
31
22
  const gzipPromise = pify(zlib_1.gzip);
32
- function encode(profile) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const buffer = profile_1.perftools.profiles.Profile.encode(profile).finish();
35
- return gzipPromise(buffer);
36
- });
23
+ async function encode(profile) {
24
+ const buffer = profile_1.perftools.profiles.Profile.encode(profile).finish();
25
+ return gzipPromise(buffer);
37
26
  }
38
27
  exports.encode = encode;
39
28
  function encodeSync(profile) {
@@ -1 +1 @@
1
- {"version":3,"file":"profile-encoder.js","sourceRoot":"","sources":["../../ts/src/profile-encoder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;AAEH,6BAA6B;AAC7B,+BAAoC;AAEpC,iDAA8C;AAE9C,MAAM,WAAW,GAAG,IAAI,CAAC,WAAI,CAAC,CAAC;AAE/B,SAAsB,MAAM,CAC1B,OAAoC;;QAEpC,MAAM,MAAM,GAAG,mBAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;QACnE,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;CAAA;AALD,wBAKC;AAED,SAAgB,UAAU,CAAC,OAAoC;IAC7D,MAAM,MAAM,GAAG,mBAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;IACnE,OAAO,eAAQ,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAHD,gCAGC"}
1
+ {"version":3,"file":"profile-encoder.js","sourceRoot":"","sources":["../../ts/src/profile-encoder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,6BAA6B;AAC7B,+BAAoC;AAEpC,iDAA8C;AAE9C,MAAM,WAAW,GAAG,IAAI,CAAC,WAAI,CAAC,CAAC;AAExB,KAAK,UAAU,MAAM,CAC1B,OAAoC;IAEpC,MAAM,MAAM,GAAG,mBAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;IACnE,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC;AALD,wBAKC;AAED,SAAgB,UAAU,CAAC,OAAoC;IAC7D,MAAM,MAAM,GAAG,mBAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;IACnE,OAAO,eAAQ,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAHD,gCAGC"}
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import { perftools } from '../../proto/profile';
17
17
  import { SourceMapper } from './sourcemapper/sourcemapper';
18
- import { AllocationProfileNode, TimeProfile } from './v8-types';
18
+ import { AllocationProfileNode, CpuProfile, TimeProfile } from './v8-types';
19
19
  /**
20
20
  * Converts v8 time profile into into a profile proto.
21
21
  * (https://github.com/google/pprof/blob/master/proto/profile.proto)
@@ -24,6 +24,14 @@ import { AllocationProfileNode, TimeProfile } from './v8-types';
24
24
  * @param intervalMicros - average time (microseconds) between samples.
25
25
  */
26
26
  export declare function serializeTimeProfile(prof: TimeProfile, intervalMicros: number, sourceMapper?: SourceMapper): perftools.profiles.IProfile;
27
+ /**
28
+ * Converts cpu profile into into a profile proto.
29
+ * (https://github.com/google/pprof/blob/master/proto/profile.proto)
30
+ *
31
+ * @param prof - profile to be converted.
32
+ * @param intervalMicros - average time (microseconds) between samples.
33
+ */
34
+ export declare function serializeCpuProfile(prof: CpuProfile, intervalMicros: number, sourceMapper?: SourceMapper): perftools.profiles.IProfile;
27
35
  /**
28
36
  * Converts v8 heap profile into into a profile proto.
29
37
  * (https://github.com/google/pprof/blob/master/proto/profile.proto)
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.serializeHeapProfile = exports.serializeTimeProfile = void 0;
18
+ exports.serializeHeapProfile = exports.serializeCpuProfile = exports.serializeTimeProfile = void 0;
19
19
  const profile_1 = require("../../proto/profile");
20
20
  function isGeneratedLocation(location) {
21
21
  return (location.column !== undefined &&
@@ -159,6 +159,16 @@ function createTimeValueType(table) {
159
159
  unit: table.getIndexOrAdd('nanoseconds'),
160
160
  });
161
161
  }
162
+ /**
163
+ * @return value type for cpu samples (type:cpu, units:nanoseconds), and
164
+ * adds strings used in this value type to the table.
165
+ */
166
+ function createCpuValueType(table) {
167
+ return new profile_1.perftools.profiles.ValueType({
168
+ type: table.getIndexOrAdd('cpu'),
169
+ unit: table.getIndexOrAdd('nanoseconds'),
170
+ });
171
+ }
162
172
  /**
163
173
  * @return value type for object counts (type:objects, units:count), and
164
174
  * adds strings used in this value type to the table.
@@ -211,6 +221,68 @@ function serializeTimeProfile(prof, intervalMicros, sourceMapper) {
211
221
  return profile;
212
222
  }
213
223
  exports.serializeTimeProfile = serializeTimeProfile;
224
+ function buildLabels(labelSet, stringTable) {
225
+ const labels = [];
226
+ for (const [key, value] of Object.entries(labelSet)) {
227
+ if (typeof value === 'number' || typeof value === 'string') {
228
+ const label = new profile_1.perftools.profiles.Label({
229
+ key: stringTable.getIndexOrAdd(key),
230
+ num: typeof value === 'number' ? value : undefined,
231
+ str: typeof value === 'string'
232
+ ? stringTable.getIndexOrAdd(value)
233
+ : undefined,
234
+ });
235
+ labels.push(label);
236
+ }
237
+ }
238
+ return labels;
239
+ }
240
+ /**
241
+ * Converts cpu profile into into a profile proto.
242
+ * (https://github.com/google/pprof/blob/master/proto/profile.proto)
243
+ *
244
+ * @param prof - profile to be converted.
245
+ * @param intervalMicros - average time (microseconds) between samples.
246
+ */
247
+ function serializeCpuProfile(prof, intervalMicros, sourceMapper) {
248
+ const intervalNanos = intervalMicros * 1000;
249
+ const appendCpuEntryToSamples = (entry, samples) => {
250
+ for (const labelSet of entry.node.labelSets) {
251
+ const sample = new profile_1.perftools.profiles.Sample({
252
+ locationId: entry.stack,
253
+ value: [1, intervalNanos],
254
+ label: buildLabels(labelSet, stringTable),
255
+ });
256
+ samples.push(sample);
257
+ }
258
+ const unknownEntryCount = entry.node.hitCount - entry.node.labelSets.length;
259
+ if (unknownEntryCount > 0) {
260
+ const sample = new profile_1.perftools.profiles.Sample({
261
+ locationId: entry.stack,
262
+ value: [
263
+ unknownEntryCount,
264
+ entry.node.cpuTime,
265
+ // unknownEntryCount * intervalNanos,
266
+ ],
267
+ });
268
+ samples.push(sample);
269
+ }
270
+ };
271
+ const stringTable = new StringTable();
272
+ const sampleValueType = createSampleCountValueType(stringTable);
273
+ // const wallValueType = createTimeValueType(stringTable);
274
+ const cpuValueType = createCpuValueType(stringTable);
275
+ const profile = {
276
+ sampleType: [sampleValueType, cpuValueType /*, wallValueType*/],
277
+ timeNanos: Date.now() * 1000 * 1000,
278
+ durationNanos: prof.endTime - prof.startTime,
279
+ periodType: cpuValueType,
280
+ period: intervalMicros,
281
+ };
282
+ serialize(profile, prof.topDownRoot, appendCpuEntryToSamples, stringTable, undefined, sourceMapper);
283
+ return profile;
284
+ }
285
+ exports.serializeCpuProfile = serializeCpuProfile;
214
286
  /**
215
287
  * Converts v8 heap profile into into a profile proto.
216
288
  * (https://github.com/google/pprof/blob/master/proto/profile.proto)
@@ -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,GAA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,CAAC,KAAK,CAAC;oBACnD,oCAAoC;iBACrC,CAAC,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACtB;SACF;IACH,CAAC,CAAC;IAEF,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;AA7CD,oDA6CC"}
@@ -14,15 +14,6 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
17
  Object.defineProperty(exports, "__esModule", { value: true });
27
18
  exports.SourceMapper = void 0;
28
19
  // Originally copied from cloud-debug-nodejs's sourcemapper.ts from
@@ -31,7 +22,17 @@ exports.SourceMapper = void 0;
31
22
  // code to generated code.
32
23
  const fs = require("fs");
33
24
  const path = require("path");
25
+ // Apparently the source-map module feature-detects the browser by checking
26
+ // if the fetch function exists. Because it now exists in Node.js v18, the
27
+ // source-map module thinks it's running in a browser and doesn't work.
28
+ const desc = Object.getOwnPropertyDescriptor(globalThis, 'fetch');
29
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
30
+ // @ts-ignore
31
+ delete globalThis.fetch;
34
32
  const sourceMap = require("source-map");
33
+ if (desc) {
34
+ Object.defineProperty(globalThis, 'fetch', desc);
35
+ }
35
36
  const scanner = require("../../third_party/cloud-debug-nodejs/src/agent/io/scanner");
36
37
  const pify = require('pify');
37
38
  const pLimit = require('p-limit');
@@ -45,51 +46,49 @@ const MAP_EXT = '.map';
45
46
  * path should be relative to the process's current working directory
46
47
  * @private
47
48
  */
48
- function processSourceMap(infoMap, mapPath) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- // this handles the case when the path is undefined, null, or
51
- // the empty string
52
- if (!mapPath || !mapPath.endsWith(MAP_EXT)) {
53
- throw new Error(`The path "${mapPath}" does not specify a source map file`);
54
- }
55
- mapPath = path.normalize(mapPath);
56
- let contents;
57
- try {
58
- contents = yield readFile(mapPath, 'utf8');
59
- }
60
- catch (e) {
61
- throw new Error('Could not read source map file ' + mapPath + ': ' + e);
62
- }
63
- let consumer;
64
- try {
65
- // TODO: Determine how to reconsile the type conflict where `consumer`
66
- // is constructed as a SourceMapConsumer but is used as a
67
- // RawSourceMap.
68
- // TODO: Resolve the cast of `contents as any` (This is needed because the
69
- // type is expected to be of `RawSourceMap` but the existing
70
- // working code uses a string.)
71
- consumer = (yield new sourceMap.SourceMapConsumer(contents));
72
- }
73
- catch (e) {
74
- throw new Error('An error occurred while reading the ' +
75
- 'sourceMap file ' +
76
- mapPath +
77
- ': ' +
78
- e);
79
- }
80
- /*
81
- * If the source map file defines a "file" attribute, use it as
82
- * the output file where the path is relative to the directory
83
- * containing the map file. Otherwise, use the name of the output
84
- * file (with the .map extension removed) as the output file.
85
- */
86
- const dir = path.dirname(mapPath);
87
- const generatedBase = consumer.file
88
- ? consumer.file
89
- : path.basename(mapPath, MAP_EXT);
90
- const generatedPath = path.resolve(dir, generatedBase);
91
- infoMap.set(generatedPath, { mapFileDir: dir, mapConsumer: consumer });
92
- });
49
+ async function processSourceMap(infoMap, mapPath) {
50
+ // this handles the case when the path is undefined, null, or
51
+ // the empty string
52
+ if (!mapPath || !mapPath.endsWith(MAP_EXT)) {
53
+ throw new Error(`The path "${mapPath}" does not specify a source map file`);
54
+ }
55
+ mapPath = path.normalize(mapPath);
56
+ let contents;
57
+ try {
58
+ contents = await readFile(mapPath, 'utf8');
59
+ }
60
+ catch (e) {
61
+ throw new Error('Could not read source map file ' + mapPath + ': ' + e);
62
+ }
63
+ let consumer;
64
+ try {
65
+ // TODO: Determine how to reconsile the type conflict where `consumer`
66
+ // is constructed as a SourceMapConsumer but is used as a
67
+ // RawSourceMap.
68
+ // TODO: Resolve the cast of `contents as any` (This is needed because the
69
+ // type is expected to be of `RawSourceMap` but the existing
70
+ // working code uses a string.)
71
+ consumer = (await new sourceMap.SourceMapConsumer(contents));
72
+ }
73
+ catch (e) {
74
+ throw new Error('An error occurred while reading the ' +
75
+ 'sourceMap file ' +
76
+ mapPath +
77
+ ': ' +
78
+ e);
79
+ }
80
+ /*
81
+ * If the source map file defines a "file" attribute, use it as
82
+ * the output file where the path is relative to the directory
83
+ * containing the map file. Otherwise, use the name of the output
84
+ * file (with the .map extension removed) as the output file.
85
+ */
86
+ const dir = path.dirname(mapPath);
87
+ const generatedBase = consumer.file
88
+ ? consumer.file
89
+ : path.basename(mapPath, MAP_EXT);
90
+ const generatedPath = path.resolve(dir, generatedBase);
91
+ infoMap.set(generatedPath, { mapFileDir: dir, mapConsumer: consumer });
93
92
  }
94
93
  class SourceMapper {
95
94
  /**
@@ -103,22 +102,20 @@ class SourceMapper {
103
102
  constructor() {
104
103
  this.infoMap = new Map();
105
104
  }
106
- static create(searchDirs) {
107
- return __awaiter(this, void 0, void 0, function* () {
108
- const mapFiles = [];
109
- for (const dir of searchDirs) {
110
- try {
111
- const mf = yield getMapFiles(dir);
112
- mf.forEach(mapFile => {
113
- mapFiles.push(path.resolve(dir, mapFile));
114
- });
115
- }
116
- catch (e) {
117
- throw new Error(`failed to get source maps from ${dir}: ${e}`);
118
- }
105
+ static async create(searchDirs) {
106
+ const mapFiles = [];
107
+ for (const dir of searchDirs) {
108
+ try {
109
+ const mf = await getMapFiles(dir);
110
+ mf.forEach(mapFile => {
111
+ mapFiles.push(path.resolve(dir, mapFile));
112
+ });
119
113
  }
120
- return createFromMapFiles(mapFiles);
121
- });
114
+ catch (e) {
115
+ throw new Error(`failed to get source maps from ${dir}: ${e}`);
116
+ }
117
+ }
118
+ return createFromMapFiles(mapFiles);
122
119
  }
123
120
  /**
124
121
  * Used to get the information about the transpiled file from a given input
@@ -194,25 +191,21 @@ class SourceMapper {
194
191
  }
195
192
  }
196
193
  exports.SourceMapper = SourceMapper;
197
- function createFromMapFiles(mapFiles) {
198
- return __awaiter(this, void 0, void 0, function* () {
199
- const limit = pLimit(CONCURRENCY);
200
- const mapper = new SourceMapper();
201
- const promises = mapFiles.map(mapPath => limit(() => processSourceMap(mapper.infoMap, mapPath)));
202
- try {
203
- yield Promise.all(promises);
204
- }
205
- catch (err) {
206
- throw new Error('An error occurred while processing the source map files' + err);
207
- }
208
- return mapper;
209
- });
194
+ async function createFromMapFiles(mapFiles) {
195
+ const limit = pLimit(CONCURRENCY);
196
+ const mapper = new SourceMapper();
197
+ const promises = mapFiles.map(mapPath => limit(() => processSourceMap(mapper.infoMap, mapPath)));
198
+ try {
199
+ await Promise.all(promises);
200
+ }
201
+ catch (err) {
202
+ throw new Error('An error occurred while processing the source map files' + err);
203
+ }
204
+ return mapper;
210
205
  }
211
- function getMapFiles(baseDir) {
212
- return __awaiter(this, void 0, void 0, function* () {
213
- const fileStats = yield scanner.scan(false, baseDir, /.js.map$/);
214
- const mapFiles = fileStats.selectFiles(/.js.map$/, process.cwd());
215
- return mapFiles;
216
- });
206
+ async function getMapFiles(baseDir) {
207
+ const fileStats = await scanner.scan(false, baseDir, /.js.map$/);
208
+ const mapFiles = fileStats.selectFiles(/.js.map$/, process.cwd());
209
+ return mapFiles;
217
210
  }
218
211
  //# sourceMappingURL=sourcemapper.js.map