@memlab/core 1.1.6 → 1.1.10

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 (120) hide show
  1. package/dist/__tests__/parser/HeapParser.test.d.ts +1 -1
  2. package/dist/__tests__/parser/HeapParser.test.js +3 -3
  3. package/dist/__tests__/parser/NodeHeap.test.d.ts +1 -1
  4. package/dist/__tests__/parser/NodeHeap.test.js +6 -6
  5. package/dist/__tests__/parser/StringNode.test.d.ts +1 -1
  6. package/dist/__tests__/parser/StringNode.test.js +2 -2
  7. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.d.ts +1 -1
  8. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.js +3 -3
  9. package/dist/__tests__/utils/utils.test.d.ts +1 -1
  10. package/dist/__tests__/utils/utils.test.js +1 -1
  11. package/dist/index.d.ts +4 -2
  12. package/dist/index.js +6 -3
  13. package/dist/lib/BaseOption.d.ts +1 -1
  14. package/dist/lib/BaseOption.js +1 -1
  15. package/dist/lib/BrowserInfo.d.ts +1 -1
  16. package/dist/lib/BrowserInfo.js +1 -1
  17. package/dist/lib/Config.d.ts +8 -2
  18. package/dist/lib/Config.js +23 -12
  19. package/dist/lib/Console.d.ts +1 -1
  20. package/dist/lib/Console.js +1 -1
  21. package/dist/lib/Constant.d.ts +1 -1
  22. package/dist/lib/Constant.js +1 -1
  23. package/dist/lib/FileManager.d.ts +1 -1
  24. package/dist/lib/FileManager.js +5 -3
  25. package/dist/lib/HeapAnalyzer.d.ts +9 -1
  26. package/dist/lib/HeapAnalyzer.js +51 -9
  27. package/dist/lib/HeapParser.d.ts +2 -2
  28. package/dist/lib/HeapParser.js +2 -2
  29. package/dist/lib/InternalValueSetter.d.ts +1 -1
  30. package/dist/lib/InternalValueSetter.js +1 -1
  31. package/dist/lib/NodeHeap.d.ts +35 -12
  32. package/dist/lib/NodeHeap.js +55 -24
  33. package/dist/lib/PackageInfoLoader.js +1 -1
  34. package/dist/lib/ProcessManager.d.ts +1 -1
  35. package/dist/lib/ProcessManager.js +1 -1
  36. package/dist/lib/Serializer.d.ts +1 -1
  37. package/dist/lib/Serializer.js +1 -1
  38. package/dist/lib/StringLoader.d.ts +2 -2
  39. package/dist/lib/StringLoader.js +2 -2
  40. package/dist/lib/Types.d.ts +51 -33
  41. package/dist/lib/Types.js +1 -1
  42. package/dist/lib/Utils.d.ts +3 -1
  43. package/dist/lib/Utils.js +71 -33
  44. package/dist/lib/heap-data/HeapEdge.d.ts +2 -2
  45. package/dist/lib/heap-data/HeapEdge.js +2 -2
  46. package/dist/lib/heap-data/HeapLocation.d.ts +2 -2
  47. package/dist/lib/heap-data/HeapLocation.js +2 -2
  48. package/dist/lib/heap-data/HeapNode.d.ts +3 -2
  49. package/dist/lib/heap-data/HeapNode.js +6 -2
  50. package/dist/lib/heap-data/HeapSnapshot.d.ts +3 -2
  51. package/dist/lib/heap-data/HeapSnapshot.js +6 -33
  52. package/dist/lib/heap-data/HeapStringNode.d.ts +2 -2
  53. package/dist/lib/heap-data/HeapStringNode.js +4 -2
  54. package/dist/lib/heap-data/HeapUtils.d.ts +2 -2
  55. package/dist/lib/heap-data/HeapUtils.js +2 -2
  56. package/dist/lib/heap-data/MemLabTagStore.d.ts +23 -0
  57. package/dist/lib/heap-data/MemLabTagStore.js +110 -0
  58. package/dist/lib/leak-filters/BaseLeakFilter.rule.d.ts +1 -1
  59. package/dist/lib/leak-filters/BaseLeakFilter.rule.js +1 -1
  60. package/dist/lib/leak-filters/LeakFilterRuleList.d.ts +1 -1
  61. package/dist/lib/leak-filters/LeakFilterRuleList.js +1 -1
  62. package/dist/lib/leak-filters/LeakObjectFilter.d.ts +1 -1
  63. package/dist/lib/leak-filters/LeakObjectFilter.js +1 -1
  64. package/dist/lib/leak-filters/rules/FilterByExternalFilter.rule.d.ts +1 -1
  65. package/dist/lib/leak-filters/rules/FilterByExternalFilter.rule.js +1 -1
  66. package/dist/lib/leak-filters/rules/FilterDetachedDOMElement.rule.d.ts +1 -1
  67. package/dist/lib/leak-filters/rules/FilterDetachedDOMElement.rule.js +1 -1
  68. package/dist/lib/leak-filters/rules/FilterHermesNode.rule.d.ts +1 -1
  69. package/dist/lib/leak-filters/rules/FilterHermesNode.rule.js +1 -1
  70. package/dist/lib/leak-filters/rules/FilterOverSizedNodeAsLeak.rule.d.ts +1 -1
  71. package/dist/lib/leak-filters/rules/FilterOverSizedNodeAsLeak.rule.js +1 -1
  72. package/dist/lib/leak-filters/rules/FilterStackTraceFrame.rule.d.ts +1 -1
  73. package/dist/lib/leak-filters/rules/FilterStackTraceFrame.rule.js +1 -1
  74. package/dist/lib/leak-filters/rules/FilterTrivialNode.rule.d.ts +1 -1
  75. package/dist/lib/leak-filters/rules/FilterTrivialNode.rule.js +1 -1
  76. package/dist/lib/leak-filters/rules/FilterUnmountedFiberNode.rule.d.ts +1 -1
  77. package/dist/lib/leak-filters/rules/FilterUnmountedFiberNode.rule.js +1 -1
  78. package/dist/logger/LeakClusterLogger.d.ts +1 -1
  79. package/dist/logger/LeakClusterLogger.js +1 -1
  80. package/dist/logger/LeakTraceDetailsLogger.d.ts +1 -1
  81. package/dist/logger/LeakTraceDetailsLogger.js +1 -1
  82. package/dist/modes/BaseMode.d.ts +1 -1
  83. package/dist/modes/BaseMode.js +1 -1
  84. package/dist/modes/InteractionTestMode.d.ts +1 -1
  85. package/dist/modes/InteractionTestMode.js +1 -1
  86. package/dist/modes/MeasureMode.d.ts +1 -1
  87. package/dist/modes/MeasureMode.js +1 -1
  88. package/dist/modes/RunningModes.d.ts +1 -1
  89. package/dist/modes/RunningModes.js +1 -1
  90. package/dist/paths/TraceFinder.d.ts +1 -1
  91. package/dist/paths/TraceFinder.js +58 -40
  92. package/dist/trace-cluster/ClusterUtils.d.ts +1 -1
  93. package/dist/trace-cluster/ClusterUtils.js +1 -1
  94. package/dist/trace-cluster/ClusterUtilsHelper.d.ts +1 -1
  95. package/dist/trace-cluster/ClusterUtilsHelper.js +1 -1
  96. package/dist/trace-cluster/ClusteringHeuristics.d.ts +1 -1
  97. package/dist/trace-cluster/ClusteringHeuristics.js +1 -1
  98. package/dist/trace-cluster/EvalutationMetric.d.ts +1 -1
  99. package/dist/trace-cluster/EvalutationMetric.js +1 -1
  100. package/dist/trace-cluster/SequentialClustering.d.ts +17 -0
  101. package/dist/trace-cluster/SequentialClustering.js +47 -0
  102. package/dist/trace-cluster/TraceBucket.d.ts +2 -1
  103. package/dist/trace-cluster/TraceBucket.js +11 -3
  104. package/dist/trace-cluster/TraceElement.d.ts +3 -1
  105. package/dist/trace-cluster/TraceElement.js +7 -1
  106. package/dist/trace-cluster/strategies/MLTraceSimilarityStrategy.d.ts +1 -1
  107. package/dist/trace-cluster/strategies/MLTraceSimilarityStrategy.js +2 -2
  108. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.d.ts +1 -1
  109. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.js +1 -1
  110. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.d.ts +1 -1
  111. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.js +1 -1
  112. package/dist/trace-cluster/strategies/machine-learning/DistanceMatrix.d.ts +1 -1
  113. package/dist/trace-cluster/strategies/machine-learning/DistanceMatrix.js +1 -1
  114. package/dist/trace-cluster/strategies/machine-learning/HAC.d.ts +2 -2
  115. package/dist/trace-cluster/strategies/machine-learning/HAC.js +5 -7
  116. package/dist/trace-cluster/strategies/machine-learning/Ngram.d.ts +1 -1
  117. package/dist/trace-cluster/strategies/machine-learning/Ngram.js +1 -1
  118. package/dist/trace-cluster/strategies/machine-learning/TfidfVectorizer.d.ts +1 -1
  119. package/dist/trace-cluster/strategies/machine-learning/TfidfVectorizer.js +7 -3
  120. package/package.json +1 -1
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  export {};
11
11
  //# sourceMappingURL=HeapParser.test.d.ts.map
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -36,7 +36,7 @@ test('Capture inserted object', () => __awaiter(void 0, void 0, void 0, function
36
36
  }
37
37
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
38
  const injected = new TestObject();
39
- const heap = yield (0, NodeHeap_1.getNodeInnocentHeap)();
39
+ const heap = yield (0, NodeHeap_1.takeNodeMinimalHeap)();
40
40
  expect(heap.hasObjectWithClassName('TestObject')).toBe(true);
41
41
  }), timeout);
42
42
  test('Does not capture transcient object', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -49,6 +49,6 @@ test('Does not capture transcient object', () => __awaiter(void 0, void 0, void
49
49
  let injected = new TestObject();
50
50
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
51
51
  injected = null;
52
- const heap = yield (0, NodeHeap_1.getNodeInnocentHeap)();
52
+ const heap = yield (0, NodeHeap_1.takeNodeMinimalHeap)();
53
53
  expect(heap.hasObjectWithClassName('TestObject')).toBe(false);
54
54
  }), timeout);
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  export {};
11
11
  //# sourceMappingURL=NodeHeap.test.d.ts.map
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -30,7 +30,7 @@ const timeout = 5 * 60 * 1000;
30
30
  test('Capture current node heap snapshot', () => __awaiter(void 0, void 0, void 0, function* () {
31
31
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
32
  const object = { 'memlab-test-heap-property': 'memlab-test-heap-value' };
33
- const heap = yield (0, NodeHeap_1.getNodeInnocentHeap)();
33
+ const heap = yield (0, NodeHeap_1.takeNodeMinimalHeap)();
34
34
  expect(heap.hasObjectWithPropertyName('memlab-test-heap-property')).toBe(true);
35
35
  }), timeout);
36
36
  test('Nullified Object should not exist in heap', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -39,7 +39,7 @@ test('Nullified Object should not exist in heap', () => __awaiter(void 0, void 0
39
39
  };
40
40
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
41
41
  object = null;
42
- const heap = yield (0, NodeHeap_1.getNodeInnocentHeap)();
42
+ const heap = yield (0, NodeHeap_1.takeNodeMinimalHeap)();
43
43
  expect(heap.hasObjectWithPropertyName('memlab-test-heap-property')).toBe(false);
44
44
  }), timeout);
45
45
  test('Strongly referenced object should exist in heap', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -59,7 +59,7 @@ test('Strongly referenced object should exist in heap', () => __awaiter(void 0,
59
59
  }
60
60
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
61
61
  const object = buildTest();
62
- const heap = yield (0, NodeHeap_1.getNodeInnocentHeap)();
62
+ const heap = yield (0, NodeHeap_1.takeNodeMinimalHeap)();
63
63
  expect(heap.hasObjectWithClassName('TestClass1')).toBe(true);
64
64
  expect(heap.hasObjectWithClassName('TestClass2')).toBe(true);
65
65
  }), timeout);
@@ -80,7 +80,7 @@ test('Weakly referenced object should not exist in heap', () => __awaiter(void 0
80
80
  }
81
81
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
82
82
  const object = buildTest();
83
- const heap = yield (0, NodeHeap_1.getNodeInnocentHeap)();
83
+ const heap = yield (0, NodeHeap_1.takeNodeMinimalHeap)();
84
84
  expect(heap.hasObjectWithClassName('TestClass3')).toBe(true);
85
85
  expect(heap.hasObjectWithClassName('TestClass4')).toBe(false);
86
86
  }), timeout);
@@ -90,7 +90,7 @@ test('Check annotated objects', () => __awaiter(void 0, void 0, void 0, function
90
90
  (0, NodeHeap_1.tagObject)(o1, 'memlab-mark-1');
91
91
  (0, NodeHeap_1.tagObject)(o2, 'memlab-mark-2');
92
92
  o2 = null;
93
- const heap = yield (0, NodeHeap_1.getNodeInnocentHeap)();
93
+ const heap = yield (0, NodeHeap_1.takeNodeMinimalHeap)();
94
94
  expect(heap.hasObjectWithTag('memlab-mark-1')).toBe(true);
95
95
  expect(heap.hasObjectWithTag('memlab-mark-2')).toBe(false);
96
96
  }), timeout);
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  export {};
11
11
  //# sourceMappingURL=StringNode.test.d.ts.map
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -41,7 +41,7 @@ test('String heap object APIs work', () => __awaiter(void 0, void 0, void 0, fun
41
41
  injected.complexConcatString += 'value_';
42
42
  injected.complexConcatString += 123;
43
43
  injected.complexConcatString += '_suffix';
44
- const heap = yield (0, NodeHeap_1.getNodeInnocentHeap)();
44
+ const heap = yield (0, NodeHeap_1.takeNodeMinimalHeap)();
45
45
  const testObject = heap.getAnyObjectWithClassName('TestObject');
46
46
  expect(testObject).not.toBe(null);
47
47
  // testObject.originalString === 'test'
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { AnyValue } from '../../../lib/Types';
11
11
  declare global {
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -74,7 +74,7 @@ test('Check getReference and getReferenceNode', () => __awaiter(void 0, void 0,
74
74
  });
75
75
  return detected;
76
76
  };
77
- const heap = yield (0, NodeHeap_1.getNodeInnocentHeap)();
77
+ const heap = yield (0, NodeHeap_1.takeNodeMinimalHeap)();
78
78
  expect(checker(heap)).toBe(true);
79
79
  }), timeout);
80
80
  test('Check getReferrers and getReferrerNodes', () => __awaiter(void 0, void 0, void 0, function* () {
@@ -135,6 +135,6 @@ test('Check getReferrers and getReferrerNodes', () => __awaiter(void 0, void 0,
135
135
  }
136
136
  return true;
137
137
  };
138
- const heap = yield (0, NodeHeap_1.getNodeInnocentHeap)();
138
+ const heap = yield (0, NodeHeap_1.takeNodeMinimalHeap)();
139
139
  expect(checker(heap)).toBe(true);
140
140
  }), timeout);
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  export {};
11
11
  //# sourceMappingURL=utils.test.d.ts.map
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
package/dist/index.d.ts CHANGED
@@ -4,12 +4,13 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  /** @internal */
11
11
  export declare function registerPackage(): Promise<void>;
12
12
  export * from './lib/Types';
13
+ export * from './lib/NodeHeap';
13
14
  /** @internal */
14
15
  export { default as config } from './lib/Config';
15
16
  /** @internal */
@@ -46,5 +47,6 @@ export { default as NormalizedTrace } from './trace-cluster/TraceBucket';
46
47
  export { default as EvaluationMetric } from './trace-cluster/EvalutationMetric';
47
48
  /** @internal */
48
49
  export * from './lib/PackageInfoLoader';
49
- export * from './lib/NodeHeap';
50
+ /** @internal */
51
+ export { default as SequentialClustering } from './trace-cluster/SequentialClustering';
50
52
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
12
  if (k2 === undefined) k2 = k;
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.EvaluationMetric = exports.NormalizedTrace = exports.leakClusterLogger = exports.ProcessManager = exports.modes = exports.constant = exports.analysis = exports.browserInfo = exports.serializer = exports.fileManager = exports.utils = exports.BaseOption = exports.info = exports.config = exports.registerPackage = void 0;
38
+ exports.SequentialClustering = exports.EvaluationMetric = exports.NormalizedTrace = exports.leakClusterLogger = exports.ProcessManager = exports.modes = exports.constant = exports.analysis = exports.browserInfo = exports.serializer = exports.fileManager = exports.utils = exports.BaseOption = exports.info = exports.config = exports.registerPackage = void 0;
39
39
  const path_1 = __importDefault(require("path"));
40
40
  const PackageInfoLoader_1 = require("./lib/PackageInfoLoader");
41
41
  /** @internal */
@@ -46,6 +46,7 @@ function registerPackage() {
46
46
  }
47
47
  exports.registerPackage = registerPackage;
48
48
  __exportStar(require("./lib/Types"), exports);
49
+ __exportStar(require("./lib/NodeHeap"), exports);
49
50
  /** @internal */
50
51
  var Config_1 = require("./lib/Config");
51
52
  Object.defineProperty(exports, "config", { enumerable: true, get: function () { return __importDefault(Config_1).default; } });
@@ -96,4 +97,6 @@ var EvalutationMetric_1 = require("./trace-cluster/EvalutationMetric");
96
97
  Object.defineProperty(exports, "EvaluationMetric", { enumerable: true, get: function () { return __importDefault(EvalutationMetric_1).default; } });
97
98
  /** @internal */
98
99
  __exportStar(require("./lib/PackageInfoLoader"), exports);
99
- __exportStar(require("./lib/NodeHeap"), exports);
100
+ /** @internal */
101
+ var SequentialClustering_1 = require("./trace-cluster/SequentialClustering");
102
+ Object.defineProperty(exports, "SequentialClustering", { enumerable: true, get: function () { return __importDefault(SequentialClustering_1).default; } });
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { ParsedArgs } from 'minimist';
11
11
  import type { AnyRecord } from './Types';
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { ConsoleMessage, Dialog, LaunchOptions, Page } from 'puppeteer';
11
11
  import type { IBrowserInfo } from './Types';
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -4,11 +4,12 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { LaunchOptions, Permission } from 'puppeteer';
11
11
  import type { AnyFunction, AnyValue, IClusterStrategy, IRunningMode, IScenario, Nullable, Optional, QuickExperiment, ILeakFilter, IPackageInfo } from './Types';
12
+ import { IHeapConfig } from '..';
12
13
  interface BrowserLaunchArgumentOptions {
13
14
  headless?: boolean;
14
15
  userDataDir?: string;
@@ -95,6 +96,7 @@ export declare class MemLabConfig {
95
96
  dataBuilderDataDir: string;
96
97
  unclassifiedClusterDir: string;
97
98
  externalCookiesFile: Optional<string>;
99
+ heapConfig: Optional<IHeapConfig>;
98
100
  puppeteerConfig: LaunchOptions & BrowserLaunchArgumentOptions & BrowserConnectOptions;
99
101
  openDevtoolsConsole: boolean;
100
102
  emulateDevice: Nullable<Device>;
@@ -182,6 +184,10 @@ export declare class MemLabConfig {
182
184
  packageInfo: IPackageInfo[];
183
185
  isMLClustering: boolean;
184
186
  mlClusteringLinkageMaxDistance: number;
187
+ mlMaxDF: number;
188
+ isSequentialClustering: boolean;
189
+ seqClusteringSplitCount: number;
190
+ seqClusteringIsRandomChunks: boolean;
185
191
  constructor(options?: ConfigOption);
186
192
  private initInternalConfigs;
187
193
  private init;
@@ -200,7 +206,7 @@ export declare class MemLabConfig {
200
206
  set isHeadfulBrowser(isHeadful: boolean);
201
207
  get isHeadfulBrowser(): boolean;
202
208
  get browserBinaryPath(): string;
203
- set reportLeaksInTimers(flag: boolean);
209
+ set reportLeaksInTimers(shouldReport: boolean);
204
210
  get reportLeaksInTimers(): boolean;
205
211
  setDevice(deviceName: string, options?: {
206
212
  manualOverride?: boolean;
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -50,7 +50,7 @@ class MemLabConfig {
50
50
  initInternalConfigs() {
51
51
  // DO NOT SET PARAMETER HERE
52
52
  this._isFullRun = false;
53
- this._reportLeaksInTimers = false;
53
+ this._reportLeaksInTimers = true;
54
54
  this._deviceManualOverridden = false;
55
55
  this._timerNodes = ['Pending activities'];
56
56
  this._timerEdges = [];
@@ -58,13 +58,15 @@ class MemLabConfig {
58
58
  this.targetApp = Constant_1.default.unset;
59
59
  this.targetTab = Constant_1.default.unset;
60
60
  this.analysisMode = Constant_1.default.unset;
61
- this.focusFiberNodeId = 1;
61
+ this.focusFiberNodeId = -1;
62
62
  this.isFB = Constant_1.default.isFB;
63
63
  // assuming the Evn doesn't support Xvfb before checking
64
64
  this.machineSupportsXVFB = false;
65
65
  // by default we want to use Xvfb if the Env supports it
66
66
  this.useXVFB = true;
67
67
  this.specifiedEngine = false;
68
+ // set by the heap-analysis package if HeapConfig is used
69
+ this.heapConfig = null;
68
70
  // set puppeteer configuration
69
71
  this.puppeteerConfig = {
70
72
  headless: !this._isHeadfulBrowser,
@@ -126,7 +128,19 @@ class MemLabConfig {
126
128
  this.includeObjectInfoInTraceReturnChain = false;
127
129
  // by default halt the program when utils.haltOrThrow is calleds
128
130
  this.errorHandling = ErrorHandling.Halt;
131
+ // by default use clustering based on heurastics
132
+ this.isMLClustering = false;
133
+ // linkage max distance for caclulating distances among clusters
129
134
  this.mlClusteringLinkageMaxDistance = 0.7;
135
+ // TF/IDF maximum document frequency
136
+ this.mlMaxDF = 1;
137
+ // if true, evaluating results with sequential clustering
138
+ this.isSequentialClustering = false;
139
+ // split the sample leak traces into 4 smaller ones by default.
140
+ this.seqClusteringSplitCount = 4;
141
+ // if true, split dataset into trunks
142
+ // with random order for sequential clustering
143
+ this.seqClusteringIsRandomChunks = false;
130
144
  }
131
145
  // initialize configurable parameters
132
146
  init(options = {}) {
@@ -171,9 +185,9 @@ class MemLabConfig {
171
185
  // the # of retries when initial load fails
172
186
  this.initialLoadFailRetry = 2;
173
187
  // timeout for checking the presence of non-optional click target
174
- this.presenceCheckTimeout = 120000;
188
+ this.presenceCheckTimeout = 2 * 60 * 1000;
175
189
  // default waiting time before exit when exception occurs during page interaction
176
- this.delayBeforeExitUponException = 120 * 1000;
190
+ this.delayBeforeExitUponException = 2 * 60 * 1000;
177
191
  // Chrome window width
178
192
  this.windowWidth = windowWidth;
179
193
  // Chrome window height
@@ -299,7 +313,7 @@ class MemLabConfig {
299
313
  static getInstance() {
300
314
  if (!MemLabConfig.instance) {
301
315
  const config = new MemLabConfig();
302
- // do not consider objects kept alive by timers as leaks
316
+ // consider objects kept alive by timers as leaks
303
317
  config.reportLeaksInTimers = true;
304
318
  // assign configuration to console manager
305
319
  Console_1.default.setConfig(config);
@@ -382,11 +396,8 @@ class MemLabConfig {
382
396
  get browserBinaryPath() {
383
397
  return path_1.default.join(this.browserDir, this.browser);
384
398
  }
385
- set reportLeaksInTimers(flag) {
386
- if (typeof flag !== 'boolean') {
387
- return;
388
- }
389
- if (flag) {
399
+ set reportLeaksInTimers(shouldReport) {
400
+ if (shouldReport) {
390
401
  this.removeFromSet(this.nodeNameBlockList, this._timerNodes);
391
402
  this.removeFromSet(this.edgeNameBlockList, this._timerEdges);
392
403
  }
@@ -394,7 +405,7 @@ class MemLabConfig {
394
405
  this.addToSet(this.nodeNameBlockList, this._timerNodes);
395
406
  this.addToSet(this.edgeNameBlockList, this._timerEdges);
396
407
  }
397
- this._reportLeaksInTimers = flag;
408
+ this._reportLeaksInTimers = shouldReport;
398
409
  }
399
410
  get reportLeaksInTimers() {
400
411
  return this._reportLeaksInTimers;
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import { Chalk } from 'chalk';
11
11
  import type { MemLabConfig } from './Config';
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  'use strict';
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  declare const constants: {
11
11
  isFB: boolean;
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const InternalValueSetter_1 = require("./InternalValueSetter");
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { MemLabConfig } from './Config';
11
11
  import type { AnyValue, Optional } from './Types';
@@ -5,8 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
- * @emails oncall+ws_labs
9
8
  * @format
9
+ * @oncall ws_labs
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -41,8 +41,10 @@ class FileManager {
41
41
  return path_1.default.join(this.getTmpDir(), 'memlab');
42
42
  }
43
43
  generateTmpHeapDir() {
44
- const dirPath = path_1.default.join(this.getTmpDir(), Utils_1.default.getUniqueID());
45
- fs_extra_1.default.mkdirSync(dirPath);
44
+ const dirPath = path_1.default.join(this.getTmpDir(), 'memlab-' + Utils_1.default.getUniqueID());
45
+ if (!fs_extra_1.default.existsSync(dirPath)) {
46
+ fs_extra_1.default.mkdirSync(dirPath);
47
+ }
46
48
  return dirPath;
47
49
  }
48
50
  getWorkDir(options = {}) {
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  import type { E2EStepInfo, HeapNodeIdSet, IHeapNode, IHeapSnapshot, IMemoryAnalystOptions, IMemoryAnalystSnapshotDiff, LeakTracePathItem, Optional, IOveralLeakInfo, TraceCluster, ISerializedInfo } from './Types';
11
11
  import TraceFinder from '../paths/TraceFinder';
@@ -41,6 +41,14 @@ declare class MemoryAnalyst {
41
41
  searchLeakedTraces(leakedNodeIds: HeapNodeIdSet, snapshot: IHeapSnapshot): Promise<{
42
42
  paths: LeakTracePathItem[];
43
43
  }>;
44
+ /**
45
+ * Given a set of heap object ids, cluster them based on the similarity
46
+ * of their retainer traces and return a
47
+ * @param leakedNodeIds
48
+ * @param snapshot
49
+ * @returns
50
+ */
51
+ clusterHeapObjects(objectIds: HeapNodeIdSet, snapshot: IHeapSnapshot): TraceCluster[];
44
52
  serializeClusterUpdate(clusters: TraceCluster[], options?: {
45
53
  reclusterOnly?: boolean;
46
54
  }): Promise<void>;
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
7
  * @format
8
+ * @oncall ws_labs
9
9
  */
10
10
  'use strict';
11
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
@@ -250,9 +250,17 @@ class MemoryAnalyst {
250
250
  let snapshotLeakedHeapNodeIdSet = new Set();
251
251
  let nodeIdsInSnapshots = [];
252
252
  let snapshot;
253
+ // if specified a heap file
253
254
  if (options.file) {
254
255
  const opt = { buildNodeIdIndex: true, verbose: true };
255
256
  snapshot = yield Utils_1.default.getSnapshotFromFile(options.file, opt);
257
+ // if running in interactive heap analysis mode
258
+ }
259
+ else if (Config_1.default.heapConfig &&
260
+ Config_1.default.heapConfig.isCliInteractiveMode &&
261
+ Config_1.default.heapConfig.currentHeap) {
262
+ snapshot = Config_1.default.heapConfig.currentHeap;
263
+ // otherwise diff heap snapshots
256
264
  }
257
265
  else {
258
266
  Utils_1.default.checkSnapshots();
@@ -368,14 +376,17 @@ class MemoryAnalyst {
368
376
  // initialize the path finder
369
377
  preparePathFinder(snapshot) {
370
378
  const finder = new TraceFinder_1.default();
371
- // shortest path for all nodes
372
- finder.annotateShortestPaths(snapshot);
373
- // dominator and retained size
374
- finder.calculateAllNodesRetainedSizes(snapshot);
375
- // mark detached Fiber nodes
376
- Utils_1.default.markAllDetachedFiberNode(snapshot);
377
- // mark alternate Fiber nodes
378
- Utils_1.default.markAlternateFiberNode(snapshot);
379
+ if (!snapshot.isProcessed) {
380
+ // shortest path for all nodes
381
+ finder.annotateShortestPaths(snapshot);
382
+ // dominator and retained size
383
+ finder.calculateAllNodesRetainedSizes(snapshot);
384
+ // mark detached Fiber nodes
385
+ Utils_1.default.markAllDetachedFiberNode(snapshot);
386
+ // mark alternate Fiber nodes
387
+ Utils_1.default.markAlternateFiberNode(snapshot);
388
+ snapshot.isProcessed = true;
389
+ }
379
390
  return finder;
380
391
  }
381
392
  // summarize the page interaction and dump to the leak text summary file
@@ -636,6 +647,7 @@ class MemoryAnalyst {
636
647
  ? new MLTraceSimilarityStrategy_1.default()
637
648
  : undefined,
638
649
  });
650
+ Console_1.default.midLevel(`MemLab found ${clusters.length} leak(s)`);
639
651
  yield this.serializeClusterUpdate(clusters);
640
652
  if (Config_1.default.logUnclassifiedClusters) {
641
653
  // cluster traces from the current run
@@ -647,6 +659,36 @@ class MemoryAnalyst {
647
659
  };
648
660
  });
649
661
  }
662
+ /**
663
+ * Given a set of heap object ids, cluster them based on the similarity
664
+ * of their retainer traces and return a
665
+ * @param leakedNodeIds
666
+ * @param snapshot
667
+ * @returns
668
+ */
669
+ clusterHeapObjects(objectIds, snapshot) {
670
+ const finder = this.preparePathFinder(snapshot);
671
+ const paths = [];
672
+ let i = 0;
673
+ // analysis for each node
674
+ Utils_1.default.applyToNodes(objectIds, snapshot, node => {
675
+ if (++i % 11 === 0) {
676
+ Console_1.default.overwrite(`progress: ${i} / ${objectIds.size} @${node.id}`);
677
+ }
678
+ // BFS search for path from the leaked node to GC roots
679
+ const p = finder.getPathToGCRoots(snapshot, node);
680
+ if (p) {
681
+ paths.push(p);
682
+ }
683
+ }, { reverse: true });
684
+ // cluster traces from the current run
685
+ const clusters = TraceBucket_1.default.clusterPaths(paths, snapshot, this.aggregateDominatorMetrics, {
686
+ strategy: Config_1.default.isMLClustering
687
+ ? new MLTraceSimilarityStrategy_1.default()
688
+ : undefined,
689
+ });
690
+ return clusters;
691
+ }
650
692
  serializeClusterUpdate(clusters, options = {}) {
651
693
  return __awaiter(this, void 0, void 0, function* () {
652
694
  // load existing clusters
@@ -4,9 +4,9 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @emails oncall+ws_labs
8
- * @lightSyntaxTransform
9
7
  * @format
8
+ * @lightSyntaxTransform
9
+ * @oncall ws_labs
10
10
  */
11
11
  import type { IHeapSnapshot } from './Types';
12
12
  declare function getNodeIdsFromFile(file: string, _options?: {}): Promise<Set<number>>;