@fluidframework/container-runtime 2.0.0-dev.4.3.0.159619 → 2.0.0-dev.4.4.0.161516

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 (107) hide show
  1. package/dist/connectionTelemetry.d.ts.map +1 -1
  2. package/dist/connectionTelemetry.js +1 -0
  3. package/dist/connectionTelemetry.js.map +1 -1
  4. package/dist/containerRuntime.d.ts.map +1 -1
  5. package/dist/containerRuntime.js +5 -2
  6. package/dist/containerRuntime.js.map +1 -1
  7. package/dist/gc/garbageCollection.d.ts +1 -27
  8. package/dist/gc/garbageCollection.d.ts.map +1 -1
  9. package/dist/gc/garbageCollection.js +30 -227
  10. package/dist/gc/garbageCollection.js.map +1 -1
  11. package/dist/gc/gcHelpers.d.ts +0 -10
  12. package/dist/gc/gcHelpers.d.ts.map +1 -1
  13. package/dist/gc/gcHelpers.js +1 -20
  14. package/dist/gc/gcHelpers.js.map +1 -1
  15. package/dist/gc/gcTelemetry.d.ts +91 -0
  16. package/dist/gc/gcTelemetry.d.ts.map +1 -0
  17. package/dist/gc/gcTelemetry.js +262 -0
  18. package/dist/gc/gcTelemetry.js.map +1 -0
  19. package/dist/gc/index.d.ts +2 -1
  20. package/dist/gc/index.d.ts.map +1 -1
  21. package/dist/gc/index.js +4 -2
  22. package/dist/gc/index.js.map +1 -1
  23. package/dist/opLifecycle/opGroupingManager.js +1 -1
  24. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  25. package/dist/opLifecycle/outbox.js +1 -1
  26. package/dist/opLifecycle/outbox.js.map +1 -1
  27. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  28. package/dist/opLifecycle/remoteMessageProcessor.js +25 -22
  29. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  30. package/dist/packageVersion.d.ts +1 -1
  31. package/dist/packageVersion.js +1 -1
  32. package/dist/packageVersion.js.map +1 -1
  33. package/dist/summary/summarizer.d.ts +2 -0
  34. package/dist/summary/summarizer.d.ts.map +1 -1
  35. package/dist/summary/summarizer.js +9 -4
  36. package/dist/summary/summarizer.js.map +1 -1
  37. package/dist/summary/summarizerHeuristics.d.ts +8 -9
  38. package/dist/summary/summarizerHeuristics.d.ts.map +1 -1
  39. package/dist/summary/summarizerHeuristics.js +15 -16
  40. package/dist/summary/summarizerHeuristics.js.map +1 -1
  41. package/dist/summary/summarizerTypes.d.ts +2 -0
  42. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  43. package/dist/summary/summarizerTypes.js.map +1 -1
  44. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  45. package/dist/summary/summaryGenerator.js +4 -3
  46. package/dist/summary/summaryGenerator.js.map +1 -1
  47. package/lib/connectionTelemetry.d.ts.map +1 -1
  48. package/lib/connectionTelemetry.js +1 -0
  49. package/lib/connectionTelemetry.js.map +1 -1
  50. package/lib/containerRuntime.d.ts.map +1 -1
  51. package/lib/containerRuntime.js +5 -2
  52. package/lib/containerRuntime.js.map +1 -1
  53. package/lib/gc/garbageCollection.d.ts +1 -27
  54. package/lib/gc/garbageCollection.d.ts.map +1 -1
  55. package/lib/gc/garbageCollection.js +34 -231
  56. package/lib/gc/garbageCollection.js.map +1 -1
  57. package/lib/gc/gcHelpers.d.ts +0 -10
  58. package/lib/gc/gcHelpers.d.ts.map +1 -1
  59. package/lib/gc/gcHelpers.js +0 -18
  60. package/lib/gc/gcHelpers.js.map +1 -1
  61. package/lib/gc/gcTelemetry.d.ts +91 -0
  62. package/lib/gc/gcTelemetry.d.ts.map +1 -0
  63. package/lib/gc/gcTelemetry.js +257 -0
  64. package/lib/gc/gcTelemetry.js.map +1 -0
  65. package/lib/gc/index.d.ts +2 -1
  66. package/lib/gc/index.d.ts.map +1 -1
  67. package/lib/gc/index.js +2 -1
  68. package/lib/gc/index.js.map +1 -1
  69. package/lib/opLifecycle/opGroupingManager.js +1 -1
  70. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  71. package/lib/opLifecycle/outbox.js +1 -1
  72. package/lib/opLifecycle/outbox.js.map +1 -1
  73. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  74. package/lib/opLifecycle/remoteMessageProcessor.js +25 -22
  75. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  76. package/lib/packageVersion.d.ts +1 -1
  77. package/lib/packageVersion.js +1 -1
  78. package/lib/packageVersion.js.map +1 -1
  79. package/lib/summary/summarizer.d.ts +2 -0
  80. package/lib/summary/summarizer.d.ts.map +1 -1
  81. package/lib/summary/summarizer.js +9 -4
  82. package/lib/summary/summarizer.js.map +1 -1
  83. package/lib/summary/summarizerHeuristics.d.ts +8 -9
  84. package/lib/summary/summarizerHeuristics.d.ts.map +1 -1
  85. package/lib/summary/summarizerHeuristics.js +15 -16
  86. package/lib/summary/summarizerHeuristics.js.map +1 -1
  87. package/lib/summary/summarizerTypes.d.ts +2 -0
  88. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  89. package/lib/summary/summarizerTypes.js.map +1 -1
  90. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  91. package/lib/summary/summaryGenerator.js +4 -3
  92. package/lib/summary/summaryGenerator.js.map +1 -1
  93. package/package.json +15 -15
  94. package/src/connectionTelemetry.ts +1 -0
  95. package/src/containerRuntime.ts +7 -1
  96. package/src/gc/garbageCollection.ts +53 -315
  97. package/src/gc/gcHelpers.ts +1 -38
  98. package/src/gc/gcTelemetry.ts +393 -0
  99. package/src/gc/index.ts +1 -1
  100. package/src/opLifecycle/opGroupingManager.ts +1 -1
  101. package/src/opLifecycle/outbox.ts +2 -2
  102. package/src/opLifecycle/remoteMessageProcessor.ts +37 -28
  103. package/src/packageVersion.ts +1 -1
  104. package/src/summary/summarizer.ts +17 -5
  105. package/src/summary/summarizerHeuristics.ts +15 -16
  106. package/src/summary/summarizerTypes.ts +2 -0
  107. package/src/summary/summaryGenerator.ts +5 -4
@@ -44,13 +44,11 @@ export declare class GarbageCollector implements IGarbageCollector {
44
44
  private readonly baseGCDetailsP;
45
45
  private readonly unreferencedNodesState;
46
46
  private sessionExpiryTimer;
47
- private readonly loggedUnreferencedEvents;
48
- private pendingEventsQueue;
49
47
  private completedRuns;
50
48
  private readonly runtime;
51
- private readonly createContainerMetadata;
52
49
  private readonly isSummarizerClient;
53
50
  private readonly summaryStateTracker;
51
+ private readonly telemetryTracker;
54
52
  /** For a given node path, returns the node's package path. */
55
53
  private readonly getNodePackagePath;
56
54
  /** Returns the timestamp of the last summary generated for this container. */
@@ -170,35 +168,11 @@ export declare class GarbageCollector implements IGarbageCollector {
170
168
  * @returns - a list of all nodes referenced from the last local summary until now.
171
169
  */
172
170
  private findAllNodesReferencedBetweenGCs;
173
- /**
174
- * Finds all new references or outbound routes in the current graph that haven't been explicitly notified to GC.
175
- * The principle is that every new reference or outbound route must be notified to GC via the
176
- * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.
177
- *
178
- * In more simple terms:
179
- * Missing Explicit References = Current References - Previous References - Explicitly Added References;
180
- *
181
- * @param currentGCData - The GC data (reference graph) from the current GC run.
182
- * @param previousGCData - The GC data (reference graph) from the previous GC run.
183
- * @param explicitReferences - New references added explicity between the previous and the current run.
184
- * @returns - a list of missing explicit references
185
- */
186
- private findMissingExplicitReferences;
187
171
  /**
188
172
  * Generates the stats of a garbage collection run from the given results of the run.
189
173
  * @param gcResult - The result of a GC run.
190
174
  * @returns the GC stats of the GC run.
191
175
  */
192
176
  private generateStats;
193
- /**
194
- * For nodes that are ready to sweep, log an event for now. Until we start running sweep which deletes objects,
195
- * this will give us a view into how much deleted content a container has.
196
- */
197
- private logSweepEvents;
198
- /**
199
- * Called when an inactive node is used after. Queue up an event that will be logged next time GC runs.
200
- */
201
- private inactiveNodeUsed;
202
- private logUnreferencedEvents;
203
177
  }
204
178
  //# sourceMappingURL=garbageCollection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"garbageCollection.d.ts","sourceRoot":"","sources":["../../src/gc/garbageCollection.ts"],"names":[],"m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H,OAAO,CAAC,eAAe;IAuDvB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAsBrB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAmBzB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,gCAAgC;IAqExC;;;;OAIG;IACH,OAAO,CAAC,aAAa;CAyDrB"}
@@ -3,23 +3,11 @@
3
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
4
  * Licensed under the MIT License.
5
5
  */
6
- var __rest = (this && this.__rest) || function (s, e) {
7
- var t = {};
8
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
9
- t[p] = s[p];
10
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
11
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
12
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
13
- t[p[i]] = s[p[i]];
14
- }
15
- return t;
16
- };
17
6
  Object.defineProperty(exports, "__esModule", { value: true });
18
7
  exports.GarbageCollector = void 0;
19
8
  const common_utils_1 = require("@fluidframework/common-utils");
20
9
  const container_utils_1 = require("@fluidframework/container-utils");
21
10
  const runtime_definitions_1 = require("@fluidframework/runtime-definitions");
22
- const runtime_utils_1 = require("@fluidframework/runtime-utils");
23
11
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
24
12
  const containerRuntime_1 = require("../containerRuntime");
25
13
  const gcConfigs_1 = require("./gcConfigs");
@@ -28,6 +16,7 @@ const gcHelpers_1 = require("./gcHelpers");
28
16
  const gcReferenceGraphAlgorithm_1 = require("./gcReferenceGraphAlgorithm");
29
17
  const gcSummaryStateTracker_1 = require("./gcSummaryStateTracker");
30
18
  const gcUnreferencedStateTracker_1 = require("./gcUnreferencedStateTracker");
19
+ const gcTelemetry_1 = require("./gcTelemetry");
31
20
  /**
32
21
  * The garbage collector for the container runtime. It consolidates the garbage collection functionality and maintains
33
22
  * its state across summaries.
@@ -61,16 +50,10 @@ class GarbageCollector {
61
50
  this.deletedNodes = new Set();
62
51
  // Map of node ids to their unreferenced state tracker.
63
52
  this.unreferencedNodesState = new Map();
64
- // Keeps track of unreferenced events that are logged for a node. This is used to limit the log generation to one
65
- // per event per node.
66
- this.loggedUnreferencedEvents = new Set();
67
- // Queue for unreferenced events that should be logged the next time GC runs.
68
- this.pendingEventsQueue = [];
69
53
  // The number of times GC has successfully completed on this instance of GarbageCollector.
70
54
  this.completedRuns = 0;
71
55
  this.runtime = createParams.runtime;
72
56
  this.isSummarizerClient = createParams.isSummarizerClient;
73
- this.createContainerMetadata = createParams.createContainerMetadata;
74
57
  this.getNodePackagePath = createParams.getNodePackagePath;
75
58
  this.getLastSummaryTimestampMs = createParams.getLastSummaryTimestampMs;
76
59
  this.activeConnection = createParams.activeConnection;
@@ -91,6 +74,7 @@ class GarbageCollector {
91
74
  this.sessionExpiryTimer.start();
92
75
  }
93
76
  this.summaryStateTracker = new gcSummaryStateTracker_1.GCSummaryStateTracker(this.configs, (baseSnapshot === null || baseSnapshot === void 0 ? void 0 : baseSnapshot.trees[runtime_definitions_1.gcTreeKey]) !== undefined /* wasGCRunInBaseSnapshot */);
77
+ this.telemetryTracker = new gcTelemetry_1.GCTelemetryTracker(this.mc, this.configs, this.isSummarizerClient, this.runtime.gcTombstoneEnforcementAllowed, createParams.createContainerMetadata, (nodeId) => this.runtime.getNodeType(nodeId), (nodeId) => this.unreferencedNodesState.get(nodeId), this.getNodePackagePath);
94
78
  // Get the GC data from the base snapshot. Use LazyPromise because we only want to do this once since it
95
79
  // it involves fetching blobs from storage which is expensive.
96
80
  this.baseSnapshotDataP = new common_utils_1.LazyPromise(async () => {
@@ -379,9 +363,8 @@ class GarbageCollector {
379
363
  // Update the current mark state and update the runtime of all used routes or ids that used as per the GC run.
380
364
  const sweepReadyNodes = this.updateMarkPhase(gcData, gcResult, currentReferenceTimestampMs, logger);
381
365
  this.runtime.updateUsedRoutes(gcResult.referencedNodeIds);
382
- // Log events for objects that are ready to be deleted by sweep. When we have sweep enabled, we will
383
- // delete these objects here instead.
384
- this.logSweepEvents(logger, currentReferenceTimestampMs);
366
+ // Log events for objects that are ready to be deleted by sweep.
367
+ this.telemetryTracker.logSweepEvents(logger, currentReferenceTimestampMs, this.unreferencedNodesState, this.completedRuns, this.getLastSummaryTimestampMs());
385
368
  let updatedGCData = gcData;
386
369
  if (this.configs.shouldRunSweep) {
387
370
  updatedGCData = this.runSweepPhase(sweepReadyNodes, gcData);
@@ -402,7 +385,7 @@ class GarbageCollector {
402
385
  // Log pending unreferenced events such as a node being used after inactive. This is done after GC runs and
403
386
  // updates its state so that we don't send false positives based on intermediate state. For example, we may get
404
387
  // reference to an unreferenced node from another unreferenced node which means the node wasn't revived.
405
- await this.logUnreferencedEvents(logger);
388
+ await this.telemetryTracker.logPendingEvents(logger);
406
389
  return gcStats;
407
390
  }
408
391
  /**
@@ -478,10 +461,16 @@ class GarbageCollector {
478
461
  if (!this.configs.shouldRunGC) {
479
462
  return;
480
463
  }
481
- const nodeStateTracker = this.unreferencedNodesState.get(nodePath);
482
- if (nodeStateTracker && nodeStateTracker.state !== gcDefinitions_1.UnreferencedState.Active) {
483
- this.inactiveNodeUsed(reason, nodePath, nodeStateTracker, undefined /* fromNodeId */, packagePath, timestampMs, requestHeaders);
484
- }
464
+ this.telemetryTracker.nodeUsed({
465
+ nodeId: nodePath,
466
+ usageType: reason,
467
+ currentReferenceTimestampMs: timestampMs !== null && timestampMs !== void 0 ? timestampMs : this.runtime.getCurrentReferenceTimestampMs(),
468
+ packagePath,
469
+ completedGCRuns: this.completedRuns,
470
+ isTombstoned: this.tombstones.includes(nodePath),
471
+ lastSummaryTime: this.getLastSummaryTimestampMs(),
472
+ viaHandle: requestHeaders === null || requestHeaders === void 0 ? void 0 : requestHeaders[containerRuntime_1.RuntimeHeaders.viaHandle],
473
+ });
485
474
  }
486
475
  /**
487
476
  * Called when an outbound reference is added to a node. This is used to identify all nodes that have been
@@ -498,27 +487,16 @@ class GarbageCollector {
498
487
  const outboundRoutes = (_a = this.newReferencesSinceLastRun.get(fromNodePath)) !== null && _a !== void 0 ? _a : [];
499
488
  outboundRoutes.push(toNodePath);
500
489
  this.newReferencesSinceLastRun.set(fromNodePath, outboundRoutes);
501
- const nodeStateTracker = this.unreferencedNodesState.get(toNodePath);
502
- if (nodeStateTracker && nodeStateTracker.state !== gcDefinitions_1.UnreferencedState.Active) {
503
- this.inactiveNodeUsed("Revived", toNodePath, nodeStateTracker, fromNodePath);
504
- }
505
- if (this.tombstones.includes(toNodePath)) {
506
- const nodeType = this.runtime.getNodeType(toNodePath);
507
- let eventName = "GC_Tombstone_SubDatastore_Revived";
508
- if (nodeType === gcDefinitions_1.GCNodeType.DataStore) {
509
- eventName = "GC_Tombstone_Datastore_Revived";
510
- }
511
- else if (nodeType === gcDefinitions_1.GCNodeType.Blob) {
512
- eventName = "GC_Tombstone_Blob_Revived";
513
- }
514
- (0, gcHelpers_1.sendGCUnexpectedUsageEvent)(this.mc, {
515
- eventName,
516
- category: "generic",
517
- url: toNodePath,
518
- nodeType,
519
- gcTombstoneEnforcementAllowed: this.runtime.gcTombstoneEnforcementAllowed,
520
- }, undefined /* packagePath */);
521
- }
490
+ this.telemetryTracker.nodeUsed({
491
+ nodeId: toNodePath,
492
+ usageType: "Revived",
493
+ currentReferenceTimestampMs: this.runtime.getCurrentReferenceTimestampMs(),
494
+ packagePath: undefined,
495
+ completedGCRuns: this.completedRuns,
496
+ isTombstoned: this.tombstones.includes(toNodePath),
497
+ lastSummaryTime: this.getLastSummaryTimestampMs(),
498
+ fromId: fromNodePath,
499
+ });
522
500
  }
523
501
  /**
524
502
  * Returns whether a node with the given path has been deleted or not. This can be used by the runtime to identify
@@ -640,17 +618,11 @@ class GarbageCollector {
640
618
  if (previousGCData === undefined) {
641
619
  return undefined;
642
620
  }
643
- // Find any references that haven't been identified correctly.
644
- const missingExplicitReferences = this.findMissingExplicitReferences(currentGCData, previousGCData, this.newReferencesSinceLastRun);
645
- if (missingExplicitReferences.length > 0) {
646
- missingExplicitReferences.forEach((missingExplicitReference) => {
647
- logger.sendErrorEvent({
648
- eventName: "gcUnknownOutboundReferences",
649
- gcNodeId: missingExplicitReference[0],
650
- gcRoutes: JSON.stringify(missingExplicitReference[1]),
651
- });
652
- });
653
- }
621
+ /**
622
+ * If there are references that were not explicitly notified to GC, log an error because this should never happen.
623
+ * If it does, this may result in the unreferenced timestamps of these nodes not updated when they were referenced.
624
+ */
625
+ this.telemetryTracker.logIfMissingExplicitReferences(currentGCData, previousGCData, this.newReferencesSinceLastRun, logger);
654
626
  // No references were added since the last run so we don't have to update reference states of any unreferenced
655
627
  // nodes. There is no in between state at this point.
656
628
  if (this.newReferencesSinceLastRun.size === 0) {
@@ -696,52 +668,6 @@ class GarbageCollector {
696
668
  ]);
697
669
  return gcResult.referencedNodeIds;
698
670
  }
699
- /**
700
- * Finds all new references or outbound routes in the current graph that haven't been explicitly notified to GC.
701
- * The principle is that every new reference or outbound route must be notified to GC via the
702
- * addedOutboundReference method. It it hasn't, its a bug and we want to identify these scenarios.
703
- *
704
- * In more simple terms:
705
- * Missing Explicit References = Current References - Previous References - Explicitly Added References;
706
- *
707
- * @param currentGCData - The GC data (reference graph) from the current GC run.
708
- * @param previousGCData - The GC data (reference graph) from the previous GC run.
709
- * @param explicitReferences - New references added explicity between the previous and the current run.
710
- * @returns - a list of missing explicit references
711
- */
712
- findMissingExplicitReferences(currentGCData, previousGCData, explicitReferences) {
713
- (0, common_utils_1.assert)(previousGCData !== undefined, 0x2b7 /* "Can't validate correctness without GC data from last run" */);
714
- const currentGraph = Object.entries(currentGCData.gcNodes);
715
- const missingExplicitReferences = [];
716
- currentGraph.forEach(([nodeId, currentOutboundRoutes]) => {
717
- var _a, _b;
718
- const previousRoutes = (_a = previousGCData.gcNodes[nodeId]) !== null && _a !== void 0 ? _a : [];
719
- const explicitRoutes = (_b = explicitReferences.get(nodeId)) !== null && _b !== void 0 ? _b : [];
720
- const missingExplicitRoutes = [];
721
- /**
722
- * 1. For routes in the current GC data, routes that were not present in previous GC data and did not have
723
- * explicit references should be added to missing explicit routes list.
724
- * 2. Only include data store and blob routes since GC only works for these two.
725
- * Note: Due to a bug with de-duped blobs, only adding data store routes for now.
726
- * 3. Ignore DDS routes to their parent datastores since those were added implicitly. So, there won't be
727
- * explicit routes to them.
728
- */
729
- currentOutboundRoutes.forEach((route) => {
730
- const nodeType = this.runtime.getNodeType(route);
731
- if ((nodeType === gcDefinitions_1.GCNodeType.DataStore || nodeType === gcDefinitions_1.GCNodeType.Blob) &&
732
- !nodeId.startsWith(route) &&
733
- !previousRoutes.includes(route) &&
734
- !explicitRoutes.includes(route)) {
735
- missingExplicitRoutes.push(route);
736
- }
737
- });
738
- if (missingExplicitRoutes.length > 0) {
739
- missingExplicitReferences.push([nodeId, missingExplicitRoutes]);
740
- }
741
- });
742
- // Ideally missingExplicitReferences should always have a size 0
743
- return missingExplicitReferences;
744
- }
745
671
  /**
746
672
  * Generates the stats of a garbage collection run from the given results of the run.
747
673
  * @param gcResult - The result of a GC run.
@@ -798,129 +724,6 @@ class GarbageCollector {
798
724
  }
799
725
  return gcStats;
800
726
  }
801
- /**
802
- * For nodes that are ready to sweep, log an event for now. Until we start running sweep which deletes objects,
803
- * this will give us a view into how much deleted content a container has.
804
- */
805
- logSweepEvents(logger, currentReferenceTimestampMs) {
806
- if (this.mc.config.getBoolean(gcDefinitions_1.disableSweepLogKey) === true ||
807
- this.configs.sweepTimeoutMs === undefined) {
808
- return;
809
- }
810
- this.unreferencedNodesState.forEach((nodeStateTracker, nodeId) => {
811
- if (nodeStateTracker.state !== gcDefinitions_1.UnreferencedState.SweepReady) {
812
- return;
813
- }
814
- const nodeType = this.runtime.getNodeType(nodeId);
815
- if (nodeType !== gcDefinitions_1.GCNodeType.DataStore && nodeType !== gcDefinitions_1.GCNodeType.Blob) {
816
- return;
817
- }
818
- // Log deleted event for each node only once to reduce noise in telemetry.
819
- const uniqueEventId = `Deleted-${nodeId}`;
820
- if (this.loggedUnreferencedEvents.has(uniqueEventId)) {
821
- return;
822
- }
823
- this.loggedUnreferencedEvents.add(uniqueEventId);
824
- logger.sendTelemetryEvent({
825
- eventName: "GCObjectDeleted",
826
- id: nodeId,
827
- type: nodeType,
828
- age: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs,
829
- timeout: this.configs.sweepTimeoutMs,
830
- completedGCRuns: this.completedRuns,
831
- lastSummaryTime: this.getLastSummaryTimestampMs(),
832
- });
833
- });
834
- }
835
- /**
836
- * Called when an inactive node is used after. Queue up an event that will be logged next time GC runs.
837
- */
838
- inactiveNodeUsed(usageType, nodeId, nodeStateTracker, fromNodeId, packagePath, currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs(), requestHeaders) {
839
- // If there is no reference timestamp to work with, no ops have been processed after creation. If so, skip
840
- // logging as nothing interesting would have happened worth logging.
841
- // If the node is active, skip logging.
842
- if (currentReferenceTimestampMs === undefined ||
843
- nodeStateTracker.state === gcDefinitions_1.UnreferencedState.Active) {
844
- return;
845
- }
846
- // We only care about data stores and attachment blobs for this telemetry since GC only marks these objects
847
- // as unreferenced. Also, if an inactive DDS is used, the corresponding data store store will also be used.
848
- const nodeType = this.runtime.getNodeType(nodeId);
849
- if (nodeType !== gcDefinitions_1.GCNodeType.DataStore && nodeType !== gcDefinitions_1.GCNodeType.Blob) {
850
- return;
851
- }
852
- const state = nodeStateTracker.state;
853
- const uniqueEventId = `${state}-${nodeId}-${usageType}`;
854
- if (this.loggedUnreferencedEvents.has(uniqueEventId)) {
855
- return;
856
- }
857
- this.loggedUnreferencedEvents.add(uniqueEventId);
858
- const propsToLog = Object.assign(Object.assign({ id: nodeId, type: nodeType, unrefTime: nodeStateTracker.unreferencedTimestampMs, age: currentReferenceTimestampMs - nodeStateTracker.unreferencedTimestampMs, timeout: nodeStateTracker.state === gcDefinitions_1.UnreferencedState.Inactive
859
- ? this.configs.inactiveTimeoutMs
860
- : this.configs.sweepTimeoutMs, completedGCRuns: this.completedRuns, lastSummaryTime: this.getLastSummaryTimestampMs() }, this.createContainerMetadata), { viaHandle: requestHeaders === null || requestHeaders === void 0 ? void 0 : requestHeaders[containerRuntime_1.RuntimeHeaders.viaHandle], fromId: fromNodeId });
861
- // For summarizer client, queue the event so it is logged the next time GC runs if the event is still valid.
862
- // For non-summarizer client, log the event now since GC won't run on it. This may result in false positives
863
- // but it's a good signal nonetheless and we can consume it with a grain of salt.
864
- // Inactive errors are usages of Objects that are unreferenced for at least a period of 7 days.
865
- // SweepReady errors are usages of Objects that will be deleted by GC Sweep!
866
- if (this.isSummarizerClient) {
867
- this.pendingEventsQueue.push(Object.assign(Object.assign({}, propsToLog), { usageType, state }));
868
- }
869
- else {
870
- // For non-summarizer clients, only log "Loaded" type events since these objects may not be loaded in the
871
- // summarizer clients if they are based off of user actions (such as scrolling to content for these objects)
872
- // Events generated:
873
- // InactiveObject_Loaded, SweepReadyObject_Loaded
874
- if (usageType === "Loaded") {
875
- const event = Object.assign(Object.assign({}, propsToLog), { eventName: `${state}Object_${usageType}`, pkg: (0, runtime_utils_1.packagePathToTelemetryProperty)(packagePath), stack: (0, telemetry_utils_1.generateStack)() });
876
- // Do not log the inactive object x events as error events as they are not the best signal for
877
- // detecting something wrong with GC either from the partner or from the runtime itself.
878
- if (state === gcDefinitions_1.UnreferencedState.Inactive) {
879
- this.mc.logger.sendTelemetryEvent(event);
880
- }
881
- else {
882
- this.mc.logger.sendErrorEvent(event);
883
- }
884
- }
885
- }
886
- }
887
- async logUnreferencedEvents(logger) {
888
- // Events sent come only from the summarizer client. In between summaries, events are pushed to a queue and at
889
- // summary time they are then logged.
890
- // Events generated:
891
- // InactiveObject_Loaded, InactiveObject_Changed, InactiveObject_Revived
892
- // SweepReadyObject_Loaded, SweepReadyObject_Changed, SweepReadyObject_Revived
893
- for (const eventProps of this.pendingEventsQueue) {
894
- const { usageType, state } = eventProps, propsToLog = __rest(eventProps, ["usageType", "state"]);
895
- /**
896
- * Revived event is logged only if the node is active. If the node is not active, the reference to it was
897
- * from another unreferenced node and this scenario is not interesting to log.
898
- * Loaded and Changed events are logged only if the node is not active. If the node is active, it was
899
- * revived and a Revived event will be logged for it.
900
- */
901
- const nodeStateTracker = this.unreferencedNodesState.get(eventProps.id);
902
- const active = nodeStateTracker === undefined ||
903
- nodeStateTracker.state === gcDefinitions_1.UnreferencedState.Active;
904
- if ((usageType === "Revived") === active) {
905
- const pkg = await this.getNodePackagePath(eventProps.id);
906
- const fromPkg = eventProps.fromId
907
- ? await this.getNodePackagePath(eventProps.fromId)
908
- : undefined;
909
- const event = Object.assign(Object.assign({}, propsToLog), { eventName: `${state}Object_${usageType}`, pkg: pkg
910
- ? { value: pkg.join("/"), tag: telemetry_utils_1.TelemetryDataTag.CodeArtifact }
911
- : undefined, fromPkg: fromPkg
912
- ? { value: fromPkg.join("/"), tag: telemetry_utils_1.TelemetryDataTag.CodeArtifact }
913
- : undefined });
914
- if (state === gcDefinitions_1.UnreferencedState.Inactive) {
915
- logger.sendTelemetryEvent(event);
916
- }
917
- else {
918
- logger.sendErrorEvent(event);
919
- }
920
- }
921
- }
922
- this.pendingEventsQueue = [];
923
- }
924
727
  }
925
728
  exports.GarbageCollector = GarbageCollector;
926
729
  //# sourceMappingURL=garbageCollection.js.map