@memlab/core 1.1.12 → 1.1.16

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 (123) hide show
  1. package/README.md +2 -2
  2. package/dist/__tests__/parser/HeapParser.test.d.ts +1 -1
  3. package/dist/__tests__/parser/HeapParser.test.js +2 -2
  4. package/dist/__tests__/parser/NodeHeap.test.d.ts +1 -1
  5. package/dist/__tests__/parser/NodeHeap.test.js +1 -1
  6. package/dist/__tests__/parser/StringNode.test.d.ts +1 -1
  7. package/dist/__tests__/parser/StringNode.test.js +1 -1
  8. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.d.ts +1 -1
  9. package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.js +1 -1
  10. package/dist/__tests__/utils/utils.test.d.ts +1 -1
  11. package/dist/__tests__/utils/utils.test.js +1 -1
  12. package/dist/index.d.ts +5 -1
  13. package/dist/index.js +7 -2
  14. package/dist/lib/BaseOption.d.ts +1 -1
  15. package/dist/lib/BaseOption.js +1 -1
  16. package/dist/lib/BrowserInfo.d.ts +1 -1
  17. package/dist/lib/BrowserInfo.js +1 -1
  18. package/dist/lib/Config.d.ts +11 -2
  19. package/dist/lib/Config.js +36 -3
  20. package/dist/lib/Console.d.ts +1 -1
  21. package/dist/lib/Console.js +1 -1
  22. package/dist/lib/Constant.d.ts +1 -1
  23. package/dist/lib/Constant.js +1 -1
  24. package/dist/lib/FileManager.d.ts +5 -3
  25. package/dist/lib/FileManager.js +13 -5
  26. package/dist/lib/HeapAnalyzer.d.ts +1 -1
  27. package/dist/lib/HeapAnalyzer.js +1 -1
  28. package/dist/lib/HeapParser.d.ts +1 -1
  29. package/dist/lib/HeapParser.js +1 -1
  30. package/dist/lib/InternalValueSetter.d.ts +1 -1
  31. package/dist/lib/InternalValueSetter.js +1 -1
  32. package/dist/lib/NodeHeap.d.ts +1 -1
  33. package/dist/lib/NodeHeap.js +1 -1
  34. package/dist/lib/PackageInfoLoader.js +1 -1
  35. package/dist/lib/ProcessManager.d.ts +1 -1
  36. package/dist/lib/ProcessManager.js +1 -1
  37. package/dist/lib/Serializer.d.ts +1 -1
  38. package/dist/lib/Serializer.js +22 -7
  39. package/dist/lib/StringLoader.d.ts +1 -1
  40. package/dist/lib/StringLoader.js +1 -1
  41. package/dist/lib/Types.d.ts +33 -1
  42. package/dist/lib/Types.js +1 -1
  43. package/dist/lib/Utils.d.ts +3 -1
  44. package/dist/lib/Utils.js +62 -5
  45. package/dist/lib/heap-data/HeapEdge.d.ts +1 -1
  46. package/dist/lib/heap-data/HeapEdge.js +1 -1
  47. package/dist/lib/heap-data/HeapLocation.d.ts +3 -2
  48. package/dist/lib/heap-data/HeapLocation.js +8 -1
  49. package/dist/lib/heap-data/HeapNode.d.ts +1 -1
  50. package/dist/lib/heap-data/HeapNode.js +2 -2
  51. package/dist/lib/heap-data/HeapSnapshot.d.ts +1 -1
  52. package/dist/lib/heap-data/HeapSnapshot.js +1 -1
  53. package/dist/lib/heap-data/HeapStringNode.d.ts +1 -1
  54. package/dist/lib/heap-data/HeapStringNode.js +1 -1
  55. package/dist/lib/heap-data/HeapUtils.d.ts +1 -1
  56. package/dist/lib/heap-data/HeapUtils.js +1 -1
  57. package/dist/lib/heap-data/MemLabTagStore.d.ts +1 -1
  58. package/dist/lib/heap-data/MemLabTagStore.js +1 -1
  59. package/dist/lib/leak-filters/BaseLeakFilter.rule.d.ts +1 -1
  60. package/dist/lib/leak-filters/BaseLeakFilter.rule.js +1 -1
  61. package/dist/lib/leak-filters/LeakFilterRuleList.d.ts +1 -1
  62. package/dist/lib/leak-filters/LeakFilterRuleList.js +1 -1
  63. package/dist/lib/leak-filters/LeakObjectFilter.d.ts +1 -1
  64. package/dist/lib/leak-filters/LeakObjectFilter.js +1 -1
  65. package/dist/lib/leak-filters/rules/FilterByExternalFilter.rule.d.ts +1 -1
  66. package/dist/lib/leak-filters/rules/FilterByExternalFilter.rule.js +1 -1
  67. package/dist/lib/leak-filters/rules/FilterDetachedDOMElement.rule.d.ts +1 -1
  68. package/dist/lib/leak-filters/rules/FilterDetachedDOMElement.rule.js +1 -1
  69. package/dist/lib/leak-filters/rules/FilterHermesNode.rule.d.ts +1 -1
  70. package/dist/lib/leak-filters/rules/FilterHermesNode.rule.js +1 -1
  71. package/dist/lib/leak-filters/rules/FilterOverSizedNodeAsLeak.rule.d.ts +1 -1
  72. package/dist/lib/leak-filters/rules/FilterOverSizedNodeAsLeak.rule.js +1 -1
  73. package/dist/lib/leak-filters/rules/FilterStackTraceFrame.rule.d.ts +1 -1
  74. package/dist/lib/leak-filters/rules/FilterStackTraceFrame.rule.js +1 -1
  75. package/dist/lib/leak-filters/rules/FilterTrivialNode.rule.d.ts +1 -1
  76. package/dist/lib/leak-filters/rules/FilterTrivialNode.rule.js +1 -1
  77. package/dist/lib/leak-filters/rules/FilterUnmountedFiberNode.rule.d.ts +1 -1
  78. package/dist/lib/leak-filters/rules/FilterUnmountedFiberNode.rule.js +1 -1
  79. package/dist/logger/LeakClusterLogger.d.ts +1 -1
  80. package/dist/logger/LeakClusterLogger.js +1 -1
  81. package/dist/logger/LeakTraceDetailsLogger.d.ts +1 -1
  82. package/dist/logger/LeakTraceDetailsLogger.js +1 -1
  83. package/dist/modes/BaseMode.d.ts +1 -1
  84. package/dist/modes/BaseMode.js +1 -1
  85. package/dist/modes/InteractionTestMode.d.ts +1 -1
  86. package/dist/modes/InteractionTestMode.js +1 -1
  87. package/dist/modes/MeasureMode.d.ts +1 -1
  88. package/dist/modes/MeasureMode.js +1 -1
  89. package/dist/modes/RunningModes.d.ts +1 -1
  90. package/dist/modes/RunningModes.js +1 -1
  91. package/dist/paths/TraceFinder.d.ts +1 -1
  92. package/dist/paths/TraceFinder.js +1 -1
  93. package/dist/trace-cluster/ClusterUtils.d.ts +16 -2
  94. package/dist/trace-cluster/ClusterUtils.js +43 -1
  95. package/dist/trace-cluster/ClusterUtilsHelper.d.ts +1 -1
  96. package/dist/trace-cluster/ClusterUtilsHelper.js +1 -1
  97. package/dist/trace-cluster/ClusteringHeuristics.d.ts +1 -1
  98. package/dist/trace-cluster/ClusteringHeuristics.js +1 -1
  99. package/dist/trace-cluster/EvalutationMetric.d.ts +1 -1
  100. package/dist/trace-cluster/EvalutationMetric.js +1 -1
  101. package/dist/trace-cluster/MultiIterationSeqClustering.d.ts +21 -0
  102. package/dist/trace-cluster/MultiIterationSeqClustering.js +112 -0
  103. package/dist/trace-cluster/SequentialClustering.d.ts +1 -1
  104. package/dist/trace-cluster/SequentialClustering.js +1 -1
  105. package/dist/trace-cluster/TraceBucket.d.ts +1 -1
  106. package/dist/trace-cluster/TraceBucket.js +4 -4
  107. package/dist/trace-cluster/TraceElement.d.ts +1 -1
  108. package/dist/trace-cluster/TraceElement.js +1 -1
  109. package/dist/trace-cluster/strategies/MLTraceSimilarityStrategy.d.ts +1 -1
  110. package/dist/trace-cluster/strategies/MLTraceSimilarityStrategy.js +1 -1
  111. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.d.ts +1 -1
  112. package/dist/trace-cluster/strategies/TraceAsClusterStrategy.js +1 -1
  113. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.d.ts +1 -1
  114. package/dist/trace-cluster/strategies/TraceSimilarityStrategy.js +1 -1
  115. package/dist/trace-cluster/strategies/machine-learning/DistanceMatrix.d.ts +1 -1
  116. package/dist/trace-cluster/strategies/machine-learning/DistanceMatrix.js +1 -1
  117. package/dist/trace-cluster/strategies/machine-learning/HAC.d.ts +1 -1
  118. package/dist/trace-cluster/strategies/machine-learning/HAC.js +1 -1
  119. package/dist/trace-cluster/strategies/machine-learning/Ngram.d.ts +1 -1
  120. package/dist/trace-cluster/strategies/machine-learning/Ngram.js +1 -1
  121. package/dist/trace-cluster/strategies/machine-learning/TfidfVectorizer.d.ts +1 -1
  122. package/dist/trace-cluster/strategies/machine-learning/TfidfVectorizer.js +1 -1
  123. package/package.json +4 -4
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { MemLabConfig } from '../../Config';
11
11
  import type { IHeapNode } from '../../Types';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { MemLabConfig } from '../../Config';
11
11
  import type { IHeapNode } from '../../Types';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import { E2EStepInfo, TraceCluster, TraceClusterDiff, TraceClusterMetaInfo } from '../lib/Types';
11
11
  declare class LeakClusterLogger {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { IHeapSnapshot, ISerializedInfo, LeakTracePathItem, Nullable } from '../lib/Types';
11
11
  declare class LeakTraceDetailsLogger {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { E2EStepInfo, Config, IE2EScenarioVisitPlan, Optional } from '../lib/Types';
11
11
  import type { Page } from 'puppeteer';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import BaseMode from './BaseMode';
11
11
  declare class InteractionTestMode extends BaseMode {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import BaseMode from './BaseMode';
11
11
  import type { Page } from 'puppeteer';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
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); }); }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { Config, IRunningMode } from '../lib/Types';
11
11
  declare const _default: {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { AnyOptions, HeapNodeIdSet, IHeapEdge, IHeapNode, IHeapSnapshot, LeakTracePathItem, Nullable, Optional, Predicator } from '../lib/Types';
11
11
  declare class TraceFinder {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,10 +5,24 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
+ import type { LeakTrace } from '../lib/Types';
10
11
  declare const _default: {
11
- isSimilarTrace: (t1: import("..").LeakTrace, t2: import("..").LeakTrace) => boolean;
12
+ isSimilarTrace: (t1: LeakTrace, t2: LeakTrace) => boolean;
12
13
  };
13
14
  export default _default;
15
+ /**
16
+ * const elements = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
17
+ * randomChunks(elements, 3) -> [[4, 8, 3], [9, 5, 1], [2, 6, 7, 10]]
18
+ * @internal
19
+ */
20
+ export declare const randomChunks: <T>(items: T[], n: number) => T[][];
21
+ /**
22
+ * chunks(elements, 3) -> [[1, 2, 3], [4, 5, 6], [7, 8, 9, 10]]
23
+ * @internal
24
+ */
25
+ export declare const chunks: <T>(items: T[], n: number) => T[][];
26
+ /** @internal*/
27
+ export declare const lastNodeFromTrace: (trace: LeakTrace) => import("../lib/Types").LeakTraceElement;
14
28
  //# sourceMappingURL=ClusterUtils.d.ts.map
@@ -6,12 +6,54 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.lastNodeFromTrace = exports.chunks = exports.randomChunks = void 0;
15
16
  const ClusterUtilsHelper_1 = __importDefault(require("./ClusterUtilsHelper"));
16
17
  const ClusteringHeuristics_1 = __importDefault(require("./ClusteringHeuristics"));
17
18
  exports.default = ClusterUtilsHelper_1.default.initialize(ClusteringHeuristics_1.default);
19
+ /**
20
+ * const elements = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
21
+ * randomChunks(elements, 3) -> [[4, 8, 3], [9, 5, 1], [2, 6, 7, 10]]
22
+ * @internal
23
+ */
24
+ const randomChunks = (items, n) => {
25
+ const array = [...items];
26
+ const size = Math.floor(array.length / n);
27
+ const chunks = [];
28
+ for (let i = 0; i < n - 1; i++) {
29
+ const chunk = [];
30
+ for (let j = 0; j < size; j++) {
31
+ const idx = Math.floor(Math.random() * array.length);
32
+ chunk[j] = array[idx];
33
+ array.splice(idx, 1);
34
+ }
35
+ chunks.push(chunk);
36
+ }
37
+ chunks.push(array);
38
+ return chunks;
39
+ };
40
+ exports.randomChunks = randomChunks;
41
+ /**
42
+ * chunks(elements, 3) -> [[1, 2, 3], [4, 5, 6], [7, 8, 9, 10]]
43
+ * @internal
44
+ */
45
+ const chunks = (items, n) => {
46
+ const array = [...items];
47
+ const size = Math.floor(array.length / n);
48
+ const chunks = [];
49
+ for (let i = 0; i < n - 1; i++) {
50
+ const chunk = array.splice(0, size);
51
+ chunks.push(chunk);
52
+ }
53
+ chunks.push(array);
54
+ return chunks;
55
+ };
56
+ exports.chunks = chunks;
57
+ /** @internal*/
58
+ const lastNodeFromTrace = (trace) => trace[trace.length - 1];
59
+ exports.lastNodeFromTrace = lastNodeFromTrace;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { AnyValue, LeakTraceElement, LeakTrace } from '../lib/Types';
11
11
  declare type NameWeightMapType = Map<string | RegExp | number, number>;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.debugTraceElementSimilarityStats = exports.debugLog = void 0;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  declare const _default: {
11
11
  edgeNameStopWords: Map<any, any>;
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  declare type ClusteredLeakTraces = Record<string, string>;
11
11
  declare const _default: {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  ////////////////////////
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @oncall web_perf_infra
9
+ */
10
+ import type { LeakTrace } from '../lib/Types';
11
+ declare type ClusterOption = {
12
+ numberOfIteration?: number;
13
+ numberOfTraceToRetainInCluster?: number;
14
+ };
15
+ export default class MultiIterationSeqClustering {
16
+ private traceSimilarity;
17
+ constructor();
18
+ cluster(newLeakTraces: LeakTrace[], options?: ClusterOption): LeakTrace[][];
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=MultiIterationSeqClustering.d.ts.map
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ *
8
+ * @format
9
+ * @oncall web_perf_infra
10
+ */
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const ClusterUtils_1 = require("./ClusterUtils");
16
+ const TraceSimilarityStrategy_1 = __importDefault(require("./strategies/TraceSimilarityStrategy"));
17
+ const MLTraceSimilarityStrategy_1 = __importDefault(require("./strategies/MLTraceSimilarityStrategy"));
18
+ const Config_1 = __importDefault(require("../lib/Config"));
19
+ const Utils_1 = __importDefault(require("../lib/Utils"));
20
+ const Console_1 = __importDefault(require("../lib/Console"));
21
+ class MultiIterationSeqClustering {
22
+ constructor() {
23
+ this.traceSimilarity = Config_1.default.isMLClustering
24
+ ? new MLTraceSimilarityStrategy_1.default()
25
+ : new TraceSimilarityStrategy_1.default();
26
+ }
27
+ cluster(newLeakTraces, options = {}) {
28
+ const maxNumOfSampleTraceInCluster = positiveIntOrDefaultValue(options.numberOfTraceToRetainInCluster, Infinity);
29
+ const numIteration = positiveIntOrDefaultValue(options.numberOfIteration, 1);
30
+ if (Config_1.default.verbose) {
31
+ Console_1.default.lowLevel(`maxNumOfSampleTraceInCluster: ${maxNumOfSampleTraceInCluster}`);
32
+ Console_1.default.lowLevel(`numIteration: ${numIteration}`);
33
+ }
34
+ // build trace and id mapping
35
+ const traceId2RepTraceId = new Map();
36
+ const traceId2Trace = new Map();
37
+ for (const trace of newLeakTraces) {
38
+ traceId2Trace.set(traceId(trace), trace);
39
+ }
40
+ // split all traces into several batches
41
+ const splitFn = Config_1.default.seqClusteringIsRandomChunks ? ClusterUtils_1.randomChunks : ClusterUtils_1.chunks;
42
+ const traceGroups = splitFn(newLeakTraces, numIteration);
43
+ let clusteredTraceSamples = [];
44
+ for (let iter = 0; iter < numIteration; ++iter) {
45
+ Console_1.default.overwrite(`Iteration: ${iter + 1}`);
46
+ // mix the current traces to cluster with all clustered trace samples
47
+ const curTraceGroup = traceGroups[iter].concat(clusteredTraceSamples);
48
+ // cluster the trace group
49
+ const { allClusters: clusters } = this.traceSimilarity.diffTraces(curTraceGroup, []);
50
+ // assign trace id to representative trace id
51
+ updateTraceId2RepTraceIdMap(clusters, traceId2RepTraceId);
52
+ // sample each group
53
+ for (let i = 0; i < clusters.length; ++i) {
54
+ clusters[i] = clusters[i].slice(0, maxNumOfSampleTraceInCluster);
55
+ }
56
+ // update samples
57
+ clusteredTraceSamples = clusters.reduce((acc, cluster) => acc.concat(cluster), []);
58
+ }
59
+ // rebuild full clusters based on the mappings
60
+ const repTraceId2Cluster = new Map();
61
+ for (const id of traceId2RepTraceId.keys()) {
62
+ const repTraceId = traceId2RepTraceId.get(id);
63
+ if (!repTraceId2Cluster.has(repTraceId)) {
64
+ repTraceId2Cluster.set(repTraceId, []);
65
+ }
66
+ const cluster = repTraceId2Cluster.get(repTraceId);
67
+ if (cluster.length === 0) {
68
+ const repTrace = traceId2Trace.get(repTraceId);
69
+ cluster.push(repTrace);
70
+ }
71
+ if (id !== repTraceId) {
72
+ const trace = traceId2Trace.get(id);
73
+ cluster.push(trace);
74
+ }
75
+ }
76
+ return Array.from(repTraceId2Cluster.values());
77
+ }
78
+ }
79
+ exports.default = MultiIterationSeqClustering;
80
+ function traceId(trace) {
81
+ const lastNode = (0, ClusterUtils_1.lastNodeFromTrace)(trace);
82
+ if (lastNode.id == null) {
83
+ throw Utils_1.default.haltOrThrow('last node id missing');
84
+ }
85
+ return lastNode.id;
86
+ }
87
+ function updateTraceId2RepTraceIdMap(clusters, traceId2RepTraceId) {
88
+ for (const cluster of clusters) {
89
+ const repTrace = cluster[0];
90
+ for (const trace of cluster) {
91
+ traceId2RepTraceId.set(traceId(trace), traceId(repTrace));
92
+ }
93
+ }
94
+ // update trace id to representative trace id closure
95
+ for (const id of traceId2RepTraceId.keys()) {
96
+ const queue = [];
97
+ let cur = id;
98
+ let repTraceId = traceId2RepTraceId.get(cur);
99
+ while (repTraceId !== cur) {
100
+ queue.push(cur);
101
+ cur = repTraceId;
102
+ repTraceId = traceId2RepTraceId.get(cur);
103
+ }
104
+ for (const idInQueue of queue) {
105
+ traceId2RepTraceId.set(idInQueue, repTraceId);
106
+ }
107
+ }
108
+ return traceId2RepTraceId;
109
+ }
110
+ function positiveIntOrDefaultValue(v, d) {
111
+ return typeof v !== 'number' || v <= 0 ? d : v;
112
+ }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { LeakTrace } from '../lib/Types';
11
11
  export default class SequentialClustering {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { IHeapNode, IHeapSnapshot, LeakTrace, LeakTracePathItem, Optional, TraceCluster, TraceClusterDiff, IClusterStrategy } from '../lib/Types';
11
11
  import type { NormalizedTraceElement } from './TraceElement';
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -21,6 +21,7 @@ const TraceElement_1 = require("./TraceElement");
21
21
  const TraceSimilarityStrategy_1 = __importDefault(require("./strategies/TraceSimilarityStrategy"));
22
22
  const TraceAsClusterStrategy_1 = __importDefault(require("./strategies/TraceAsClusterStrategy"));
23
23
  const MLTraceSimilarityStrategy_1 = __importDefault(require("./strategies/MLTraceSimilarityStrategy"));
24
+ const ClusterUtils_1 = require("./ClusterUtils");
24
25
  // sync up with html/intern/js/webspeed/memlab/lib/LeakCluster.js
25
26
  class NormalizedTrace {
26
27
  constructor(p = null, snapshot = null) {
@@ -166,10 +167,9 @@ class NormalizedTrace {
166
167
  return NormalizedTrace.clusteredLeakTracesToRecord(allClusters);
167
168
  }
168
169
  static clusteredLeakTracesToRecord(allClusters) {
169
- const lastNodeFromTrace = (trace) => trace[trace.length - 1];
170
170
  const labaledLeakTraces = allClusters.reduce((acc, bucket) => {
171
- const lastNodeFromFirstTrace = lastNodeFromTrace(bucket[0]);
172
- bucket.map(lastNodeFromTrace).forEach(lastNodeInTrace => {
171
+ const lastNodeFromFirstTrace = (0, ClusterUtils_1.lastNodeFromTrace)(bucket[0]);
172
+ bucket.map(ClusterUtils_1.lastNodeFromTrace).forEach(lastNodeInTrace => {
173
173
  if (lastNodeInTrace.id == null || lastNodeFromFirstTrace.id == null) {
174
174
  throw new Error('node id not found in last node of the leak trace');
175
175
  }
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { EdgeIterationCallback, IHeapEdge, IHeapLocation, IHeapNode, IHeapSnapshot, IHeapStringNode, Nullable } from '../lib/Types';
11
11
  export declare class NodeRecord implements IHeapNode {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { IClusterStrategy, LeakTrace, TraceDiff } from '../../lib/Types';
11
11
  export default class MLTraceSimilarityStrategy implements IClusterStrategy {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { IClusterStrategy, LeakTrace, TraceDiff } from '../../lib/Types';
11
11
  export default class TraceAsClusterStrategy implements IClusterStrategy {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  import type { IClusterStrategy, LeakTrace, TraceDiff } from '../../lib/Types';
11
11
  export default class TraceSimilarityStrategy implements IClusterStrategy {
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  export declare const distance: (tfidfs: Record<string, number>[]) => Float32Array;
11
11
  //# sourceMappingURL=DistanceMatrix.d.ts.map
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.distance = void 0;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
7
  * @format
8
- * @oncall ws_labs
8
+ * @oncall web_perf_infra
9
9
  */
10
10
  /**
11
11
  *
@@ -6,7 +6,7 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  *
8
8
  * @format
9
- * @oncall ws_labs
9
+ * @oncall web_perf_infra
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.cluster = void 0;