@fluidframework/container-runtime 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419
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.
- package/.eslintrc.js +19 -29
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +427 -0
- package/README.md +69 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/container-runtime.api.md +863 -0
- package/dist/{batchTracker.js → batchTracker.cjs} +9 -8
- package/dist/batchTracker.cjs.map +1 -0
- package/dist/batchTracker.d.ts +6 -5
- package/dist/batchTracker.d.ts.map +1 -1
- package/dist/blobManager.cjs +704 -0
- package/dist/blobManager.cjs.map +1 -0
- package/dist/blobManager.d.ts +135 -39
- package/dist/blobManager.d.ts.map +1 -1
- package/dist/connectionTelemetry.cjs +230 -0
- package/dist/connectionTelemetry.cjs.map +1 -0
- package/dist/connectionTelemetry.d.ts +2 -2
- package/dist/connectionTelemetry.d.ts.map +1 -1
- package/dist/container-runtime-alpha.d.ts +1677 -0
- package/dist/container-runtime-beta.d.ts +250 -0
- package/dist/container-runtime-public.d.ts +250 -0
- package/dist/container-runtime-untrimmed.d.ts +1792 -0
- package/dist/{containerHandleContext.js → containerHandleContext.cjs} +4 -2
- package/dist/containerHandleContext.cjs.map +1 -0
- package/dist/containerHandleContext.d.ts.map +1 -1
- package/dist/containerRuntime.cjs +2531 -0
- package/dist/containerRuntime.cjs.map +1 -0
- package/dist/containerRuntime.d.ts +454 -256
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/{dataStore.js → dataStore.cjs} +54 -45
- package/dist/dataStore.cjs.map +1 -0
- package/dist/dataStore.d.ts +2 -2
- package/dist/dataStore.d.ts.map +1 -1
- package/dist/{dataStoreContext.js → dataStoreContext.cjs} +343 -247
- package/dist/dataStoreContext.cjs.map +1 -0
- package/dist/dataStoreContext.d.ts +73 -41
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/{dataStoreContexts.js → dataStoreContexts.cjs} +19 -15
- package/dist/dataStoreContexts.cjs.map +1 -0
- package/dist/dataStoreContexts.d.ts +1 -1
- package/dist/dataStoreContexts.d.ts.map +1 -1
- package/dist/{dataStoreRegistry.js → dataStoreRegistry.cjs} +9 -4
- package/dist/dataStoreRegistry.cjs.map +1 -0
- package/dist/dataStoreRegistry.d.ts +3 -0
- package/dist/dataStoreRegistry.d.ts.map +1 -1
- package/dist/{dataStores.js → dataStores.cjs} +273 -124
- package/dist/dataStores.cjs.map +1 -0
- package/dist/dataStores.d.ts +53 -23
- package/dist/dataStores.d.ts.map +1 -1
- package/dist/deltaManagerProxyBase.cjs +77 -0
- package/dist/deltaManagerProxyBase.cjs.map +1 -0
- package/dist/deltaManagerProxyBase.d.ts +35 -0
- package/dist/deltaManagerProxyBase.d.ts.map +1 -0
- package/dist/deltaManagerSummarizerProxy.cjs +42 -0
- package/dist/deltaManagerSummarizerProxy.cjs.map +1 -0
- package/dist/deltaManagerSummarizerProxy.d.ts +19 -0
- package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -0
- package/dist/{deltaScheduler.js → deltaScheduler.cjs} +25 -18
- package/dist/deltaScheduler.cjs.map +1 -0
- package/dist/deltaScheduler.d.ts +8 -6
- package/dist/deltaScheduler.d.ts.map +1 -1
- package/dist/error.cjs +21 -0
- package/dist/error.cjs.map +1 -0
- package/dist/error.d.ts +14 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/gc/garbageCollection.cjs +861 -0
- package/dist/gc/garbageCollection.cjs.map +1 -0
- package/dist/gc/garbageCollection.d.ts +224 -0
- package/dist/gc/garbageCollection.d.ts.map +1 -0
- package/dist/gc/gcConfigs.cjs +153 -0
- package/dist/gc/gcConfigs.cjs.map +1 -0
- package/dist/gc/gcConfigs.d.ts +23 -0
- package/dist/gc/gcConfigs.d.ts.map +1 -0
- package/dist/gc/gcDefinitions.cjs +96 -0
- package/dist/gc/gcDefinitions.cjs.map +1 -0
- package/dist/gc/gcDefinitions.d.ts +437 -0
- package/dist/gc/gcDefinitions.d.ts.map +1 -0
- package/dist/gc/gcHelpers.cjs +235 -0
- package/dist/gc/gcHelpers.cjs.map +1 -0
- package/dist/gc/gcHelpers.d.ts +71 -0
- package/dist/gc/gcHelpers.d.ts.map +1 -0
- package/dist/gc/gcReferenceGraphAlgorithm.cjs +49 -0
- package/dist/gc/gcReferenceGraphAlgorithm.cjs.map +1 -0
- package/dist/gc/gcReferenceGraphAlgorithm.d.ts +16 -0
- package/dist/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -0
- package/dist/{summarizerTypes.js → gc/gcSummaryDefinitions.cjs} +1 -6
- package/dist/gc/gcSummaryDefinitions.cjs.map +1 -0
- package/dist/gc/gcSummaryDefinitions.d.ts +52 -0
- package/dist/gc/gcSummaryDefinitions.d.ts.map +1 -0
- package/dist/gc/gcSummaryStateTracker.cjs +213 -0
- package/dist/gc/gcSummaryStateTracker.cjs.map +1 -0
- package/dist/gc/gcSummaryStateTracker.d.ts +94 -0
- package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -0
- package/dist/gc/gcTelemetry.cjs +298 -0
- package/dist/gc/gcTelemetry.cjs.map +1 -0
- package/dist/gc/gcTelemetry.d.ts +92 -0
- package/dist/gc/gcTelemetry.d.ts.map +1 -0
- package/dist/gc/gcUnreferencedStateTracker.cjs +118 -0
- package/dist/gc/gcUnreferencedStateTracker.cjs.map +1 -0
- package/dist/gc/gcUnreferencedStateTracker.d.ts +40 -0
- package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
- package/dist/gc/index.cjs +44 -0
- package/dist/gc/index.cjs.map +1 -0
- package/dist/gc/index.d.ts +13 -0
- package/dist/gc/index.d.ts.map +1 -0
- package/dist/index.cjs +47 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/messageTypes.cjs +37 -0
- package/dist/messageTypes.cjs.map +1 -0
- package/dist/messageTypes.d.ts +142 -0
- package/dist/messageTypes.d.ts.map +1 -0
- package/dist/metadata.cjs +7 -0
- package/dist/metadata.cjs.map +1 -0
- package/dist/metadata.d.ts +24 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/opLifecycle/batchManager.cjs +139 -0
- package/dist/opLifecycle/batchManager.cjs.map +1 -0
- package/dist/opLifecycle/batchManager.d.ts +48 -0
- package/dist/opLifecycle/batchManager.d.ts.map +1 -0
- package/dist/opLifecycle/definitions.cjs +7 -0
- package/dist/opLifecycle/definitions.cjs.map +1 -0
- package/dist/opLifecycle/definitions.d.ts +83 -0
- package/dist/opLifecycle/definitions.d.ts.map +1 -0
- package/dist/opLifecycle/index.cjs +26 -0
- package/dist/opLifecycle/index.cjs.map +1 -0
- package/dist/opLifecycle/index.d.ts +13 -0
- package/dist/opLifecycle/index.d.ts.map +1 -0
- package/dist/opLifecycle/opCompressor.cjs +84 -0
- package/dist/opLifecycle/opCompressor.cjs.map +1 -0
- package/dist/opLifecycle/opCompressor.d.ts +18 -0
- package/dist/opLifecycle/opCompressor.d.ts.map +1 -0
- package/dist/opLifecycle/opDecompressor.cjs +132 -0
- package/dist/opLifecycle/opDecompressor.cjs.map +1 -0
- package/dist/opLifecycle/opDecompressor.d.ts +25 -0
- package/dist/opLifecycle/opDecompressor.d.ts.map +1 -0
- package/dist/opLifecycle/opGroupingManager.cjs +95 -0
- package/dist/opLifecycle/opGroupingManager.cjs.map +1 -0
- package/dist/opLifecycle/opGroupingManager.d.ts +22 -0
- package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -0
- package/dist/opLifecycle/opSplitter.cjs +202 -0
- package/dist/opLifecycle/opSplitter.cjs.map +1 -0
- package/dist/opLifecycle/opSplitter.d.ts +61 -0
- package/dist/opLifecycle/opSplitter.d.ts.map +1 -0
- package/dist/opLifecycle/outbox.cjs +323 -0
- package/dist/opLifecycle/outbox.cjs.map +1 -0
- package/dist/opLifecycle/outbox.d.ts +104 -0
- package/dist/opLifecycle/outbox.d.ts.map +1 -0
- package/dist/opLifecycle/remoteMessageProcessor.cjs +136 -0
- package/dist/opLifecycle/remoteMessageProcessor.cjs.map +1 -0
- package/dist/opLifecycle/remoteMessageProcessor.d.ts +47 -0
- package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -0
- package/dist/opProperties.cjs +17 -0
- package/dist/opProperties.cjs.map +1 -0
- package/dist/opProperties.d.ts +7 -0
- package/dist/opProperties.d.ts.map +1 -0
- package/dist/{packageVersion.js → packageVersion.cjs} +2 -2
- package/dist/packageVersion.cjs.map +1 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/pendingStateManager.cjs +282 -0
- package/dist/pendingStateManager.cjs.map +1 -0
- package/dist/pendingStateManager.d.ts +32 -69
- package/dist/pendingStateManager.d.ts.map +1 -1
- package/dist/scheduleManager.cjs +258 -0
- package/dist/scheduleManager.cjs.map +1 -0
- package/dist/scheduleManager.d.ts +31 -0
- package/dist/scheduleManager.d.ts.map +1 -0
- package/dist/storageServiceWithAttachBlobs.cjs +32 -0
- package/dist/storageServiceWithAttachBlobs.cjs.map +1 -0
- package/dist/storageServiceWithAttachBlobs.d.ts +17 -0
- package/dist/storageServiceWithAttachBlobs.d.ts.map +1 -0
- package/dist/summary/index.cjs +51 -0
- package/dist/summary/index.cjs.map +1 -0
- package/dist/summary/index.d.ts +17 -0
- package/dist/summary/index.d.ts.map +1 -0
- package/dist/{orderedClientElection.js → summary/orderedClientElection.cjs} +100 -84
- package/dist/summary/orderedClientElection.cjs.map +1 -0
- package/{lib → dist/summary}/orderedClientElection.d.ts +41 -18
- package/dist/summary/orderedClientElection.d.ts.map +1 -0
- package/dist/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.cjs} +12 -10
- package/dist/summary/runWhileConnectedCoordinator.cjs.map +1 -0
- package/{lib → dist/summary}/runWhileConnectedCoordinator.d.ts +8 -2
- package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
- package/dist/summary/runningSummarizer.cjs +679 -0
- package/dist/summary/runningSummarizer.cjs.map +1 -0
- package/dist/summary/runningSummarizer.d.ts +128 -0
- package/dist/summary/runningSummarizer.d.ts.map +1 -0
- package/dist/summary/summarizer.cjs +263 -0
- package/dist/summary/summarizer.cjs.map +1 -0
- package/dist/{summarizer.d.ts → summary/summarizer.d.ts} +18 -33
- package/dist/summary/summarizer.d.ts.map +1 -0
- package/dist/{summarizerClientElection.js → summary/summarizerClientElection.cjs} +15 -46
- package/dist/summary/summarizerClientElection.cjs.map +1 -0
- package/{lib → dist/summary}/summarizerClientElection.d.ts +4 -4
- package/dist/summary/summarizerClientElection.d.ts.map +1 -0
- package/dist/summary/summarizerHeuristics.cjs +156 -0
- package/dist/summary/summarizerHeuristics.cjs.map +1 -0
- package/{lib → dist/summary}/summarizerHeuristics.d.ts +28 -6
- package/dist/summary/summarizerHeuristics.d.ts.map +1 -0
- package/dist/summary/summarizerNode/index.cjs +12 -0
- package/dist/summary/summarizerNode/index.cjs.map +1 -0
- package/dist/summary/summarizerNode/index.d.ts +8 -0
- package/dist/summary/summarizerNode/index.d.ts.map +1 -0
- package/dist/summary/summarizerNode/summarizerNode.cjs +526 -0
- package/dist/summary/summarizerNode/summarizerNode.cjs.map +1 -0
- package/dist/summary/summarizerNode/summarizerNode.d.ts +167 -0
- package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -0
- package/dist/summary/summarizerNode/summarizerNodeUtils.cjs +130 -0
- package/dist/summary/summarizerNode/summarizerNodeUtils.cjs.map +1 -0
- package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +121 -0
- package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -0
- package/dist/summary/summarizerNode/summarizerNodeWithGc.cjs +375 -0
- package/dist/summary/summarizerNode/summarizerNodeWithGc.cjs.map +1 -0
- package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +153 -0
- package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -0
- package/dist/summary/summarizerTypes.cjs +7 -0
- package/dist/summary/summarizerTypes.cjs.map +1 -0
- package/{lib → dist/summary}/summarizerTypes.d.ts +233 -83
- package/dist/summary/summarizerTypes.d.ts.map +1 -0
- package/dist/{summaryCollection.js → summary/summaryCollection.cjs} +80 -49
- package/dist/summary/summaryCollection.cjs.map +1 -0
- package/dist/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +23 -5
- package/dist/summary/summaryCollection.d.ts.map +1 -0
- package/dist/{summaryFormat.js → summary/summaryFormat.cjs} +29 -26
- package/dist/summary/summaryFormat.cjs.map +1 -0
- package/{lib → dist/summary}/summaryFormat.d.ts +25 -30
- package/dist/summary/summaryFormat.d.ts.map +1 -0
- package/dist/{summaryGenerator.js → summary/summaryGenerator.cjs} +162 -74
- package/dist/summary/summaryGenerator.cjs.map +1 -0
- package/dist/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +53 -11
- package/dist/summary/summaryGenerator.d.ts.map +1 -0
- package/dist/{summaryManager.js → summary/summaryManager.cjs} +98 -55
- package/dist/summary/summaryManager.cjs.map +1 -0
- package/{lib → dist/summary}/summaryManager.d.ts +13 -11
- package/dist/summary/summaryManager.d.ts.map +1 -0
- package/dist/{throttler.js → throttler.cjs} +21 -21
- package/dist/throttler.cjs.map +1 -0
- package/dist/throttler.d.ts +2 -2
- package/dist/throttler.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/{batchTracker.d.ts → batchTracker.d.mts} +6 -5
- package/lib/batchTracker.d.mts.map +1 -0
- package/lib/{batchTracker.js → batchTracker.mjs} +9 -8
- package/lib/batchTracker.mjs.map +1 -0
- package/lib/blobManager.d.mts +191 -0
- package/lib/blobManager.d.mts.map +1 -0
- package/lib/blobManager.mjs +699 -0
- package/lib/blobManager.mjs.map +1 -0
- package/lib/{connectionTelemetry.d.ts → connectionTelemetry.d.mts} +2 -2
- package/lib/connectionTelemetry.d.mts.map +1 -0
- package/lib/connectionTelemetry.mjs +226 -0
- package/lib/connectionTelemetry.mjs.map +1 -0
- package/lib/container-runtime-alpha.d.mts +1677 -0
- package/lib/container-runtime-beta.d.mts +250 -0
- package/lib/container-runtime-public.d.mts +250 -0
- package/lib/container-runtime-untrimmed.d.mts +1792 -0
- package/lib/{containerHandleContext.d.ts → containerHandleContext.d.mts} +1 -1
- package/lib/containerHandleContext.d.mts.map +1 -0
- package/lib/{containerHandleContext.js → containerHandleContext.mjs} +4 -2
- package/lib/containerHandleContext.mjs.map +1 -0
- package/lib/containerRuntime.d.mts +809 -0
- package/lib/containerRuntime.d.mts.map +1 -0
- package/lib/containerRuntime.mjs +2526 -0
- package/lib/containerRuntime.mjs.map +1 -0
- package/lib/{dataStore.d.ts → dataStore.d.mts} +4 -4
- package/lib/dataStore.d.mts.map +1 -0
- package/lib/{dataStore.js → dataStore.mjs} +52 -43
- package/lib/dataStore.mjs.map +1 -0
- package/lib/{dataStoreContext.d.ts → dataStoreContext.d.mts} +74 -42
- package/lib/dataStoreContext.d.mts.map +1 -0
- package/lib/{dataStoreContext.js → dataStoreContext.mjs} +309 -213
- package/lib/dataStoreContext.mjs.map +1 -0
- package/lib/{dataStoreContexts.d.ts → dataStoreContexts.d.mts} +2 -2
- package/lib/dataStoreContexts.d.mts.map +1 -0
- package/lib/{dataStoreContexts.js → dataStoreContexts.mjs} +12 -8
- package/lib/dataStoreContexts.mjs.map +1 -0
- package/lib/{dataStoreRegistry.d.ts → dataStoreRegistry.d.mts} +3 -0
- package/lib/dataStoreRegistry.d.mts.map +1 -0
- package/lib/{dataStoreRegistry.js → dataStoreRegistry.mjs} +7 -6
- package/lib/dataStoreRegistry.mjs.map +1 -0
- package/lib/{dataStores.d.ts → dataStores.d.mts} +56 -26
- package/lib/dataStores.d.mts.map +1 -0
- package/lib/{dataStores.js → dataStores.mjs} +254 -105
- package/lib/dataStores.mjs.map +1 -0
- package/lib/deltaManagerProxyBase.d.mts +35 -0
- package/lib/deltaManagerProxyBase.d.mts.map +1 -0
- package/lib/deltaManagerProxyBase.mjs +73 -0
- package/lib/deltaManagerProxyBase.mjs.map +1 -0
- package/lib/deltaManagerSummarizerProxy.d.mts +19 -0
- package/lib/deltaManagerSummarizerProxy.d.mts.map +1 -0
- package/lib/deltaManagerSummarizerProxy.mjs +38 -0
- package/lib/deltaManagerSummarizerProxy.mjs.map +1 -0
- package/lib/{deltaScheduler.d.ts → deltaScheduler.d.mts} +8 -6
- package/lib/deltaScheduler.d.mts.map +1 -0
- package/lib/{deltaScheduler.js → deltaScheduler.mjs} +22 -15
- package/lib/deltaScheduler.mjs.map +1 -0
- package/lib/error.d.mts +14 -0
- package/lib/error.d.mts.map +1 -0
- package/lib/error.mjs +17 -0
- package/lib/error.mjs.map +1 -0
- package/lib/gc/garbageCollection.d.mts +224 -0
- package/lib/gc/garbageCollection.d.mts.map +1 -0
- package/lib/gc/garbageCollection.mjs +857 -0
- package/lib/gc/garbageCollection.mjs.map +1 -0
- package/lib/gc/gcConfigs.d.mts +23 -0
- package/lib/gc/gcConfigs.d.mts.map +1 -0
- package/lib/gc/gcConfigs.mjs +149 -0
- package/lib/gc/gcConfigs.mjs.map +1 -0
- package/lib/gc/gcDefinitions.d.mts +437 -0
- package/lib/gc/gcDefinitions.d.mts.map +1 -0
- package/lib/gc/gcDefinitions.mjs +93 -0
- package/lib/gc/gcDefinitions.mjs.map +1 -0
- package/lib/gc/gcHelpers.d.mts +71 -0
- package/lib/gc/gcHelpers.d.mts.map +1 -0
- package/lib/gc/gcHelpers.mjs +222 -0
- package/lib/gc/gcHelpers.mjs.map +1 -0
- package/lib/gc/gcReferenceGraphAlgorithm.d.mts +16 -0
- package/lib/gc/gcReferenceGraphAlgorithm.d.mts.map +1 -0
- package/lib/gc/gcReferenceGraphAlgorithm.mjs +45 -0
- package/lib/gc/gcReferenceGraphAlgorithm.mjs.map +1 -0
- package/lib/gc/gcSummaryDefinitions.d.mts +52 -0
- package/lib/gc/gcSummaryDefinitions.d.mts.map +1 -0
- package/lib/gc/gcSummaryDefinitions.mjs +6 -0
- package/lib/gc/gcSummaryDefinitions.mjs.map +1 -0
- package/lib/gc/gcSummaryStateTracker.d.mts +94 -0
- package/lib/gc/gcSummaryStateTracker.d.mts.map +1 -0
- package/lib/gc/gcSummaryStateTracker.mjs +209 -0
- package/lib/gc/gcSummaryStateTracker.mjs.map +1 -0
- package/lib/gc/gcTelemetry.d.mts +92 -0
- package/lib/gc/gcTelemetry.d.mts.map +1 -0
- package/lib/gc/gcTelemetry.mjs +293 -0
- package/lib/gc/gcTelemetry.mjs.map +1 -0
- package/lib/gc/gcUnreferencedStateTracker.d.mts +40 -0
- package/lib/gc/gcUnreferencedStateTracker.d.mts.map +1 -0
- package/lib/gc/gcUnreferencedStateTracker.mjs +114 -0
- package/lib/gc/gcUnreferencedStateTracker.mjs.map +1 -0
- package/lib/gc/index.d.mts +13 -0
- package/lib/gc/index.d.mts.map +1 -0
- package/lib/gc/index.mjs +12 -0
- package/lib/gc/index.mjs.map +1 -0
- package/lib/index.d.mts +25 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +24 -0
- package/lib/index.mjs.map +1 -0
- package/lib/messageTypes.d.mts +142 -0
- package/lib/messageTypes.d.mts.map +1 -0
- package/lib/messageTypes.mjs +34 -0
- package/lib/messageTypes.mjs.map +1 -0
- package/lib/metadata.d.mts +24 -0
- package/lib/metadata.d.mts.map +1 -0
- package/lib/metadata.mjs +6 -0
- package/lib/metadata.mjs.map +1 -0
- package/lib/opLifecycle/batchManager.d.mts +48 -0
- package/lib/opLifecycle/batchManager.d.mts.map +1 -0
- package/lib/opLifecycle/batchManager.mjs +133 -0
- package/lib/opLifecycle/batchManager.mjs.map +1 -0
- package/lib/opLifecycle/definitions.d.mts +83 -0
- package/lib/opLifecycle/definitions.d.mts.map +1 -0
- package/lib/opLifecycle/definitions.mjs +6 -0
- package/lib/opLifecycle/definitions.mjs.map +1 -0
- package/lib/opLifecycle/index.d.mts +13 -0
- package/lib/opLifecycle/index.d.mts.map +1 -0
- package/lib/opLifecycle/index.mjs +12 -0
- package/lib/opLifecycle/index.mjs.map +1 -0
- package/lib/opLifecycle/opCompressor.d.mts +18 -0
- package/lib/opLifecycle/opCompressor.d.mts.map +1 -0
- package/lib/opLifecycle/opCompressor.mjs +80 -0
- package/lib/opLifecycle/opCompressor.mjs.map +1 -0
- package/lib/opLifecycle/opDecompressor.d.mts +25 -0
- package/lib/opLifecycle/opDecompressor.d.mts.map +1 -0
- package/lib/opLifecycle/opDecompressor.mjs +128 -0
- package/lib/opLifecycle/opDecompressor.mjs.map +1 -0
- package/lib/opLifecycle/opGroupingManager.d.mts +22 -0
- package/lib/opLifecycle/opGroupingManager.d.mts.map +1 -0
- package/lib/opLifecycle/opGroupingManager.mjs +91 -0
- package/lib/opLifecycle/opGroupingManager.mjs.map +1 -0
- package/lib/opLifecycle/opSplitter.d.mts +61 -0
- package/lib/opLifecycle/opSplitter.d.mts.map +1 -0
- package/lib/opLifecycle/opSplitter.mjs +197 -0
- package/lib/opLifecycle/opSplitter.mjs.map +1 -0
- package/lib/opLifecycle/outbox.d.mts +104 -0
- package/lib/opLifecycle/outbox.d.mts.map +1 -0
- package/lib/opLifecycle/outbox.mjs +318 -0
- package/lib/opLifecycle/outbox.mjs.map +1 -0
- package/lib/opLifecycle/remoteMessageProcessor.d.mts +47 -0
- package/lib/opLifecycle/remoteMessageProcessor.d.mts.map +1 -0
- package/lib/opLifecycle/remoteMessageProcessor.mjs +131 -0
- package/lib/opLifecycle/remoteMessageProcessor.mjs.map +1 -0
- package/lib/opProperties.d.mts +7 -0
- package/lib/opProperties.d.mts.map +1 -0
- package/lib/opProperties.mjs +13 -0
- package/lib/opProperties.mjs.map +1 -0
- package/lib/{packageVersion.d.ts → packageVersion.d.mts} +1 -1
- package/lib/{packageVersion.d.ts.map → packageVersion.d.mts.map} +1 -1
- package/lib/{packageVersion.js → packageVersion.mjs} +2 -2
- package/lib/packageVersion.mjs.map +1 -0
- package/lib/{pendingStateManager.d.ts → pendingStateManager.d.mts} +32 -69
- package/lib/pendingStateManager.d.mts.map +1 -0
- package/lib/pendingStateManager.mjs +275 -0
- package/lib/pendingStateManager.mjs.map +1 -0
- package/lib/scheduleManager.d.mts +27 -0
- package/lib/scheduleManager.d.mts.map +1 -0
- package/lib/scheduleManager.mjs +254 -0
- package/lib/scheduleManager.mjs.map +1 -0
- package/lib/storageServiceWithAttachBlobs.d.mts +17 -0
- package/lib/storageServiceWithAttachBlobs.d.mts.map +1 -0
- package/lib/storageServiceWithAttachBlobs.mjs +28 -0
- package/lib/storageServiceWithAttachBlobs.mjs.map +1 -0
- package/lib/summary/index.d.mts +17 -0
- package/lib/summary/index.d.mts.map +1 -0
- package/lib/summary/index.mjs +16 -0
- package/lib/summary/index.mjs.map +1 -0
- package/{dist/orderedClientElection.d.ts → lib/summary/orderedClientElection.d.mts} +41 -22
- package/lib/summary/orderedClientElection.d.mts.map +1 -0
- package/lib/{orderedClientElection.js → summary/orderedClientElection.mjs} +95 -79
- package/lib/summary/orderedClientElection.mjs.map +1 -0
- package/{dist/runWhileConnectedCoordinator.d.ts → lib/summary/runWhileConnectedCoordinator.d.mts} +9 -3
- package/lib/summary/runWhileConnectedCoordinator.d.mts.map +1 -0
- package/lib/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.mjs} +12 -10
- package/lib/summary/runWhileConnectedCoordinator.mjs.map +1 -0
- package/lib/summary/runningSummarizer.d.mts +128 -0
- package/lib/summary/runningSummarizer.d.mts.map +1 -0
- package/lib/summary/runningSummarizer.mjs +675 -0
- package/lib/summary/runningSummarizer.mjs.map +1 -0
- package/lib/{summarizer.d.ts → summary/summarizer.d.mts} +20 -35
- package/lib/summary/summarizer.d.mts.map +1 -0
- package/lib/summary/summarizer.mjs +257 -0
- package/lib/summary/summarizer.mjs.map +1 -0
- package/{dist/summarizerClientElection.d.ts → lib/summary/summarizerClientElection.d.mts} +6 -6
- package/lib/summary/summarizerClientElection.d.mts.map +1 -0
- package/lib/{summarizerClientElection.js → summary/summarizerClientElection.mjs} +14 -45
- package/lib/summary/summarizerClientElection.mjs.map +1 -0
- package/{dist/summarizerHeuristics.d.ts → lib/summary/summarizerHeuristics.d.mts} +29 -7
- package/lib/summary/summarizerHeuristics.d.mts.map +1 -0
- package/lib/summary/summarizerHeuristics.mjs +151 -0
- package/lib/summary/summarizerHeuristics.mjs.map +1 -0
- package/lib/summary/summarizerNode/index.d.mts +8 -0
- package/lib/summary/summarizerNode/index.d.mts.map +1 -0
- package/lib/summary/summarizerNode/index.mjs +7 -0
- package/lib/summary/summarizerNode/index.mjs.map +1 -0
- package/lib/summary/summarizerNode/summarizerNode.d.mts +167 -0
- package/lib/summary/summarizerNode/summarizerNode.d.mts.map +1 -0
- package/lib/summary/summarizerNode/summarizerNode.mjs +521 -0
- package/lib/summary/summarizerNode/summarizerNode.mjs.map +1 -0
- package/lib/summary/summarizerNode/summarizerNodeUtils.d.mts +121 -0
- package/lib/summary/summarizerNode/summarizerNodeUtils.d.mts.map +1 -0
- package/lib/summary/summarizerNode/summarizerNodeUtils.mjs +123 -0
- package/lib/summary/summarizerNode/summarizerNodeUtils.mjs.map +1 -0
- package/lib/summary/summarizerNode/summarizerNodeWithGc.d.mts +153 -0
- package/lib/summary/summarizerNode/summarizerNodeWithGc.d.mts.map +1 -0
- package/lib/summary/summarizerNode/summarizerNodeWithGc.mjs +370 -0
- package/lib/summary/summarizerNode/summarizerNodeWithGc.mjs.map +1 -0
- package/{dist/summarizerTypes.d.ts → lib/summary/summarizerTypes.d.mts} +234 -84
- package/lib/summary/summarizerTypes.d.mts.map +1 -0
- package/lib/summary/summarizerTypes.mjs +6 -0
- package/lib/summary/summarizerTypes.mjs.map +1 -0
- package/lib/{summaryCollection.d.ts → summary/summaryCollection.d.mts} +23 -5
- package/lib/summary/summaryCollection.d.mts.map +1 -0
- package/lib/{summaryCollection.js → summary/summaryCollection.mjs} +76 -45
- package/lib/summary/summaryCollection.mjs.map +1 -0
- package/{dist/summaryFormat.d.ts → lib/summary/summaryFormat.d.mts} +25 -30
- package/lib/summary/summaryFormat.d.mts.map +1 -0
- package/lib/{summaryFormat.js → summary/summaryFormat.mjs} +30 -26
- package/lib/summary/summaryFormat.mjs.map +1 -0
- package/lib/summary/summaryGenerator.d.mts +127 -0
- package/lib/summary/summaryGenerator.d.mts.map +1 -0
- package/lib/{summaryGenerator.js → summary/summaryGenerator.mjs} +153 -67
- package/lib/summary/summaryGenerator.mjs.map +1 -0
- package/{dist/summaryManager.d.ts → lib/summary/summaryManager.d.mts} +15 -13
- package/lib/summary/summaryManager.d.mts.map +1 -0
- package/lib/{summaryManager.js → summary/summaryManager.mjs} +94 -51
- package/lib/summary/summaryManager.mjs.map +1 -0
- package/lib/{throttler.d.ts → throttler.d.mts} +2 -2
- package/lib/throttler.d.mts.map +1 -0
- package/lib/{throttler.js → throttler.mjs} +21 -21
- package/lib/throttler.mjs.map +1 -0
- package/package.json +173 -72
- package/prettier.config.cjs +8 -0
- package/src/batchTracker.ts +59 -54
- package/src/blobManager.ts +937 -294
- package/src/connectionTelemetry.ts +342 -252
- package/src/containerHandleContext.ts +27 -29
- package/src/containerRuntime.ts +3879 -3143
- package/src/dataStore.ts +170 -140
- package/src/dataStoreContext.ts +1166 -986
- package/src/dataStoreContexts.ts +176 -163
- package/src/dataStoreRegistry.ts +29 -21
- package/src/dataStores.ts +921 -678
- package/src/deltaManagerProxyBase.ts +111 -0
- package/src/deltaManagerSummarizerProxy.ts +49 -0
- package/src/deltaScheduler.ts +161 -156
- package/src/error.ts +21 -0
- package/src/gc/garbageCollection.md +106 -0
- package/src/gc/garbageCollection.ts +1153 -0
- package/src/gc/gcConfigs.ts +216 -0
- package/src/gc/gcDefinitions.ts +502 -0
- package/src/gc/gcHelpers.ts +284 -0
- package/src/gc/gcReferenceGraphAlgorithm.ts +52 -0
- package/src/gc/gcSummaryDefinitions.ts +54 -0
- package/src/gc/gcSummaryStateTracker.ts +299 -0
- package/src/gc/gcTelemetry.ts +423 -0
- package/src/gc/gcUnreferencedStateTracker.ts +153 -0
- package/src/gc/index.ts +59 -0
- package/src/index.ts +101 -74
- package/src/messageTypes.ts +238 -0
- package/src/metadata.ts +26 -0
- package/src/opLifecycle/README.md +321 -0
- package/src/opLifecycle/batchManager.ts +179 -0
- package/src/opLifecycle/definitions.ts +89 -0
- package/src/opLifecycle/index.ts +19 -0
- package/src/opLifecycle/opCompressor.ts +99 -0
- package/src/opLifecycle/opDecompressor.ts +190 -0
- package/src/opLifecycle/opGroupingManager.ts +133 -0
- package/src/opLifecycle/opSplitter.ts +279 -0
- package/src/opLifecycle/outbox.ts +471 -0
- package/src/opLifecycle/remoteMessageProcessor.ts +175 -0
- package/src/opProperties.ts +21 -0
- package/src/packageVersion.ts +1 -1
- package/src/pendingStateManager.ts +396 -465
- package/src/scheduleManager.ts +358 -0
- package/src/storageServiceWithAttachBlobs.ts +38 -0
- package/src/summary/index.ts +109 -0
- package/src/summary/orderedClientElection.ts +571 -0
- package/src/summary/runWhileConnectedCoordinator.ts +117 -0
- package/src/summary/runningSummarizer.ts +920 -0
- package/src/summary/summarizer.ts +352 -0
- package/src/summary/summarizerClientElection.ts +140 -0
- package/src/summary/summarizerHeuristics.ts +227 -0
- package/src/summary/summarizerNode/index.ts +12 -0
- package/src/summary/summarizerNode/summarizerNode.ts +725 -0
- package/src/summary/summarizerNode/summarizerNodeUtils.ts +206 -0
- package/src/summary/summarizerNode/summarizerNodeWithGc.ts +571 -0
- package/src/summary/summarizerTypes.ts +631 -0
- package/src/summary/summaryCollection.ts +474 -0
- package/src/summary/summaryFormat.ts +249 -0
- package/src/summary/summaryGenerator.ts +539 -0
- package/src/summary/summaryManager.ts +452 -0
- package/src/throttler.ts +131 -122
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +11 -13
- package/dist/batchTracker.js.map +0 -1
- package/dist/blobManager.js +0 -249
- package/dist/blobManager.js.map +0 -1
- package/dist/connectionTelemetry.js +0 -178
- package/dist/connectionTelemetry.js.map +0 -1
- package/dist/containerHandleContext.js.map +0 -1
- package/dist/containerRuntime.js +0 -2174
- package/dist/containerRuntime.js.map +0 -1
- package/dist/dataStore.js.map +0 -1
- package/dist/dataStoreContext.js.map +0 -1
- package/dist/dataStoreContexts.js.map +0 -1
- package/dist/dataStoreRegistry.js.map +0 -1
- package/dist/dataStores.js.map +0 -1
- package/dist/deltaScheduler.js.map +0 -1
- package/dist/garbageCollection.d.ts +0 -319
- package/dist/garbageCollection.d.ts.map +0 -1
- package/dist/garbageCollection.js +0 -993
- package/dist/garbageCollection.js.map +0 -1
- package/dist/index.js +0 -33
- package/dist/index.js.map +0 -1
- package/dist/opTelemetry.d.ts +0 -22
- package/dist/opTelemetry.d.ts.map +0 -1
- package/dist/opTelemetry.js +0 -60
- package/dist/opTelemetry.js.map +0 -1
- package/dist/orderedClientElection.d.ts.map +0 -1
- package/dist/orderedClientElection.js.map +0 -1
- package/dist/packageVersion.js.map +0 -1
- package/dist/pendingStateManager.js +0 -346
- package/dist/pendingStateManager.js.map +0 -1
- package/dist/runWhileConnectedCoordinator.d.ts.map +0 -1
- package/dist/runWhileConnectedCoordinator.js.map +0 -1
- package/dist/runningSummarizer.d.ts +0 -93
- package/dist/runningSummarizer.d.ts.map +0 -1
- package/dist/runningSummarizer.js +0 -384
- package/dist/runningSummarizer.js.map +0 -1
- package/dist/serializedSnapshotStorage.d.ts +0 -58
- package/dist/serializedSnapshotStorage.d.ts.map +0 -1
- package/dist/serializedSnapshotStorage.js +0 -108
- package/dist/serializedSnapshotStorage.js.map +0 -1
- package/dist/summarizer.d.ts.map +0 -1
- package/dist/summarizer.js +0 -348
- package/dist/summarizer.js.map +0 -1
- package/dist/summarizerClientElection.d.ts.map +0 -1
- package/dist/summarizerClientElection.js.map +0 -1
- package/dist/summarizerHandle.d.ts +0 -12
- package/dist/summarizerHandle.d.ts.map +0 -1
- package/dist/summarizerHandle.js +0 -22
- package/dist/summarizerHandle.js.map +0 -1
- package/dist/summarizerHeuristics.d.ts.map +0 -1
- package/dist/summarizerHeuristics.js +0 -84
- package/dist/summarizerHeuristics.js.map +0 -1
- package/dist/summarizerTypes.d.ts.map +0 -1
- package/dist/summarizerTypes.js.map +0 -1
- package/dist/summaryCollection.d.ts.map +0 -1
- package/dist/summaryCollection.js.map +0 -1
- package/dist/summaryFormat.d.ts.map +0 -1
- package/dist/summaryFormat.js.map +0 -1
- package/dist/summaryGenerator.d.ts.map +0 -1
- package/dist/summaryGenerator.js.map +0 -1
- package/dist/summaryManager.d.ts.map +0 -1
- package/dist/summaryManager.js.map +0 -1
- package/dist/throttler.js.map +0 -1
- package/garbageCollection.md +0 -41
- package/lib/batchTracker.d.ts.map +0 -1
- package/lib/batchTracker.js.map +0 -1
- package/lib/blobManager.d.ts +0 -95
- package/lib/blobManager.d.ts.map +0 -1
- package/lib/blobManager.js +0 -244
- package/lib/blobManager.js.map +0 -1
- package/lib/connectionTelemetry.d.ts.map +0 -1
- package/lib/connectionTelemetry.js +0 -174
- package/lib/connectionTelemetry.js.map +0 -1
- package/lib/containerHandleContext.d.ts.map +0 -1
- package/lib/containerHandleContext.js.map +0 -1
- package/lib/containerRuntime.d.ts +0 -615
- package/lib/containerRuntime.d.ts.map +0 -1
- package/lib/containerRuntime.js +0 -2166
- package/lib/containerRuntime.js.map +0 -1
- package/lib/dataStore.d.ts.map +0 -1
- package/lib/dataStore.js.map +0 -1
- package/lib/dataStoreContext.d.ts.map +0 -1
- package/lib/dataStoreContext.js.map +0 -1
- package/lib/dataStoreContexts.d.ts.map +0 -1
- package/lib/dataStoreContexts.js.map +0 -1
- package/lib/dataStoreRegistry.d.ts.map +0 -1
- package/lib/dataStoreRegistry.js.map +0 -1
- package/lib/dataStores.d.ts.map +0 -1
- package/lib/dataStores.js.map +0 -1
- package/lib/deltaScheduler.d.ts.map +0 -1
- package/lib/deltaScheduler.js.map +0 -1
- package/lib/garbageCollection.d.ts +0 -319
- package/lib/garbageCollection.d.ts.map +0 -1
- package/lib/garbageCollection.js +0 -989
- package/lib/garbageCollection.js.map +0 -1
- package/lib/index.d.ts +0 -14
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -13
- package/lib/index.js.map +0 -1
- package/lib/opTelemetry.d.ts +0 -22
- package/lib/opTelemetry.d.ts.map +0 -1
- package/lib/opTelemetry.js +0 -56
- package/lib/opTelemetry.js.map +0 -1
- package/lib/orderedClientElection.d.ts.map +0 -1
- package/lib/orderedClientElection.js.map +0 -1
- package/lib/packageVersion.js.map +0 -1
- package/lib/pendingStateManager.d.ts.map +0 -1
- package/lib/pendingStateManager.js +0 -339
- package/lib/pendingStateManager.js.map +0 -1
- package/lib/runWhileConnectedCoordinator.d.ts.map +0 -1
- package/lib/runWhileConnectedCoordinator.js.map +0 -1
- package/lib/runningSummarizer.d.ts +0 -93
- package/lib/runningSummarizer.d.ts.map +0 -1
- package/lib/runningSummarizer.js +0 -380
- package/lib/runningSummarizer.js.map +0 -1
- package/lib/serializedSnapshotStorage.d.ts +0 -58
- package/lib/serializedSnapshotStorage.d.ts.map +0 -1
- package/lib/serializedSnapshotStorage.js +0 -104
- package/lib/serializedSnapshotStorage.js.map +0 -1
- package/lib/summarizer.d.ts.map +0 -1
- package/lib/summarizer.js +0 -342
- package/lib/summarizer.js.map +0 -1
- package/lib/summarizerClientElection.d.ts.map +0 -1
- package/lib/summarizerClientElection.js.map +0 -1
- package/lib/summarizerHandle.d.ts +0 -12
- package/lib/summarizerHandle.d.ts.map +0 -1
- package/lib/summarizerHandle.js +0 -18
- package/lib/summarizerHandle.js.map +0 -1
- package/lib/summarizerHeuristics.d.ts.map +0 -1
- package/lib/summarizerHeuristics.js +0 -79
- package/lib/summarizerHeuristics.js.map +0 -1
- package/lib/summarizerTypes.d.ts.map +0 -1
- package/lib/summarizerTypes.js +0 -9
- package/lib/summarizerTypes.js.map +0 -1
- package/lib/summaryCollection.d.ts.map +0 -1
- package/lib/summaryCollection.js.map +0 -1
- package/lib/summaryFormat.d.ts.map +0 -1
- package/lib/summaryFormat.js.map +0 -1
- package/lib/summaryGenerator.d.ts +0 -85
- package/lib/summaryGenerator.d.ts.map +0 -1
- package/lib/summaryGenerator.js.map +0 -1
- package/lib/summaryManager.d.ts.map +0 -1
- package/lib/summaryManager.js.map +0 -1
- package/lib/throttler.d.ts.map +0 -1
- package/lib/throttler.js.map +0 -1
- package/src/garbageCollection.ts +0 -1434
- package/src/opTelemetry.ts +0 -71
- package/src/orderedClientElection.ts +0 -511
- package/src/runWhileConnectedCoordinator.ts +0 -106
- package/src/runningSummarizer.ts +0 -550
- package/src/serializedSnapshotStorage.ts +0 -146
- package/src/summarizer.ts +0 -438
- package/src/summarizerClientElection.ts +0 -161
- package/src/summarizerHandle.ts +0 -21
- package/src/summarizerHeuristics.ts +0 -108
- package/src/summarizerTypes.ts +0 -462
- package/src/summaryCollection.ts +0 -406
- package/src/summaryFormat.ts +0 -239
- package/src/summaryGenerator.ts +0 -427
- package/src/summaryManager.ts +0 -368
- package/tsconfig.esnext.json +0 -7
|
@@ -0,0 +1,857 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { assert, LazyPromise, Timer } from "@fluidframework/core-utils";
|
|
6
|
+
import { gcTreeKey, } from "@fluidframework/runtime-definitions";
|
|
7
|
+
import { createResponseError, responseToException } from "@fluidframework/runtime-utils";
|
|
8
|
+
import { createChildLogger, createChildMonitoringContext, DataProcessingError, PerformanceEvent, } from "@fluidframework/telemetry-utils";
|
|
9
|
+
import { InactiveResponseHeaderKey, TombstoneResponseHeaderKey, } from "../containerRuntime.mjs";
|
|
10
|
+
import { ClientSessionExpiredError } from "../error.mjs";
|
|
11
|
+
import { ContainerMessageType } from "../messageTypes.mjs";
|
|
12
|
+
import { generateGCConfigs } from "./gcConfigs.mjs";
|
|
13
|
+
import { GCNodeType, UnreferencedState, GarbageCollectionMessageType, } from "./gcDefinitions.mjs";
|
|
14
|
+
import { cloneGCData, compatBehaviorAllowsGCMessageType, concatGarbageCollectionData, getGCDataFromSnapshot, } from "./gcHelpers.mjs";
|
|
15
|
+
import { runGarbageCollection } from "./gcReferenceGraphAlgorithm.mjs";
|
|
16
|
+
import { GCSummaryStateTracker } from "./gcSummaryStateTracker.mjs";
|
|
17
|
+
import { UnreferencedStateTracker } from "./gcUnreferencedStateTracker.mjs";
|
|
18
|
+
import { GCTelemetryTracker } from "./gcTelemetry.mjs";
|
|
19
|
+
/**
|
|
20
|
+
* The garbage collector for the container runtime. It consolidates the garbage collection functionality and maintains
|
|
21
|
+
* its state across summaries.
|
|
22
|
+
*
|
|
23
|
+
* Node - represented as nodeId, it's a node on the GC graph
|
|
24
|
+
*
|
|
25
|
+
* Outbound Route - a path from one node to another node, think `nodeA` -\> `nodeB`
|
|
26
|
+
*
|
|
27
|
+
* Graph - all nodes with their respective routes
|
|
28
|
+
*
|
|
29
|
+
* ```
|
|
30
|
+
* GC Graph
|
|
31
|
+
*
|
|
32
|
+
* Node
|
|
33
|
+
* NodeId = "datastore1"
|
|
34
|
+
* / \\
|
|
35
|
+
* OutboundRoute OutboundRoute
|
|
36
|
+
* / \\
|
|
37
|
+
* Node Node
|
|
38
|
+
* NodeId = "dds1" NodeId = "dds2"
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export class GarbageCollector {
|
|
42
|
+
static create(createParams) {
|
|
43
|
+
return new GarbageCollector(createParams);
|
|
44
|
+
}
|
|
45
|
+
get shouldRunGC() {
|
|
46
|
+
return this.configs.shouldRunGC;
|
|
47
|
+
}
|
|
48
|
+
/** If false, loading or using a Tombstoned object should merely log, not fail */
|
|
49
|
+
get tombstoneEnforcementAllowed() {
|
|
50
|
+
return this.configs.sweepEnabled;
|
|
51
|
+
}
|
|
52
|
+
/** If true, throw an error when a tombstone data store is retrieved */
|
|
53
|
+
get throwOnTombstoneLoad() {
|
|
54
|
+
return this.configs.throwOnTombstoneLoad;
|
|
55
|
+
}
|
|
56
|
+
/** If true, throw an error when a tombstone data store is used */
|
|
57
|
+
get throwOnTombstoneUsage() {
|
|
58
|
+
return this.configs.throwOnTombstoneUsage;
|
|
59
|
+
}
|
|
60
|
+
get summaryStateNeedsReset() {
|
|
61
|
+
return this.summaryStateTracker.doesSummaryStateNeedReset;
|
|
62
|
+
}
|
|
63
|
+
/** Returns the count of data stores whose GC state updated since the last summary. */
|
|
64
|
+
get updatedDSCountSinceLastSummary() {
|
|
65
|
+
return this.summaryStateTracker.updatedDSCountSinceLastSummary;
|
|
66
|
+
}
|
|
67
|
+
constructor(createParams) {
|
|
68
|
+
// Keeps a list of references (edges in the GC graph) between GC runs. Each entry has a node id and a list of
|
|
69
|
+
// outbound routes from that node.
|
|
70
|
+
this.newReferencesSinceLastRun = new Map();
|
|
71
|
+
// A list of nodes that have been tombstoned.
|
|
72
|
+
this.tombstones = [];
|
|
73
|
+
// A list of nodes that have been deleted during sweep phase.
|
|
74
|
+
this.deletedNodes = new Set();
|
|
75
|
+
// Map of node ids to their unreferenced state tracker.
|
|
76
|
+
this.unreferencedNodesState = new Map();
|
|
77
|
+
// The number of times GC has successfully completed on this instance of GarbageCollector.
|
|
78
|
+
this.completedRuns = 0;
|
|
79
|
+
this.runtime = createParams.runtime;
|
|
80
|
+
this.isSummarizerClient = createParams.isSummarizerClient;
|
|
81
|
+
this.getNodePackagePath = createParams.getNodePackagePath;
|
|
82
|
+
this.getLastSummaryTimestampMs = createParams.getLastSummaryTimestampMs;
|
|
83
|
+
this.submitMessage = createParams.submitMessage;
|
|
84
|
+
const baseSnapshot = createParams.baseSnapshot;
|
|
85
|
+
const readAndParseBlob = createParams.readAndParseBlob;
|
|
86
|
+
this.mc = createChildMonitoringContext({
|
|
87
|
+
logger: createParams.baseLogger,
|
|
88
|
+
namespace: "GarbageCollector",
|
|
89
|
+
properties: {
|
|
90
|
+
all: { completedGCRuns: () => this.completedRuns },
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
this.configs = generateGCConfigs(this.mc, createParams);
|
|
94
|
+
// If session expiry is enabled, we need to close the container when the session expiry timeout expires.
|
|
95
|
+
if (this.configs.sessionExpiryTimeoutMs !== undefined) {
|
|
96
|
+
// If Test Override config is set, override Session Expiry timeout.
|
|
97
|
+
const overrideSessionExpiryTimeoutMs = this.mc.config.getNumber("Fluid.GarbageCollection.TestOverride.SessionExpiryMs");
|
|
98
|
+
const timeoutMs = overrideSessionExpiryTimeoutMs ?? this.configs.sessionExpiryTimeoutMs;
|
|
99
|
+
this.sessionExpiryTimer = new Timer(timeoutMs, () => {
|
|
100
|
+
this.runtime.closeFn(new ClientSessionExpiredError(`Client session expired.`, timeoutMs));
|
|
101
|
+
});
|
|
102
|
+
this.sessionExpiryTimer.start();
|
|
103
|
+
}
|
|
104
|
+
this.summaryStateTracker = new GCSummaryStateTracker(this.configs, baseSnapshot?.trees[gcTreeKey] !== undefined /* wasGCRunInBaseSnapshot */);
|
|
105
|
+
this.telemetryTracker = new GCTelemetryTracker(this.mc, this.configs, this.isSummarizerClient, createParams.createContainerMetadata, (nodeId) => this.runtime.getNodeType(nodeId), (nodeId) => this.unreferencedNodesState.get(nodeId), this.getNodePackagePath);
|
|
106
|
+
// Get the GC data from the base snapshot. Use LazyPromise because we only want to do this once since it
|
|
107
|
+
// it involves fetching blobs from storage which is expensive.
|
|
108
|
+
this.baseSnapshotDataP = new LazyPromise(async () => {
|
|
109
|
+
if (baseSnapshot === undefined) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
// For newer documents, GC data should be present in the GC tree in the root of the snapshot.
|
|
114
|
+
const gcSnapshotTree = baseSnapshot.trees[gcTreeKey];
|
|
115
|
+
if (gcSnapshotTree === undefined) {
|
|
116
|
+
// back-compat - Older documents get their gc data reset for simplicity as there are few of them
|
|
117
|
+
// incremental gc summary will not work with older gc data as well
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
const snapshotData = await getGCDataFromSnapshot(gcSnapshotTree, readAndParseBlob);
|
|
121
|
+
// If the GC version in base snapshot does not match the GC version currently in effect, the GC data
|
|
122
|
+
// in the snapshot cannot be interpreted correctly. Set everything to undefined except for
|
|
123
|
+
// deletedNodes because irrespective of GC versions, these nodes have been deleted and cannot be
|
|
124
|
+
// brought back. The deletedNodes info is needed to identify when these nodes are used.
|
|
125
|
+
if (this.configs.gcVersionInEffect !== this.configs.gcVersionInBaseSnapshot) {
|
|
126
|
+
return {
|
|
127
|
+
gcState: undefined,
|
|
128
|
+
tombstones: undefined,
|
|
129
|
+
deletedNodes: snapshotData.deletedNodes,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return snapshotData;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
const dpe = DataProcessingError.wrapIfUnrecognized(error, "FailedToInitializeGC");
|
|
136
|
+
dpe.addTelemetryProperties({
|
|
137
|
+
gcConfigs: JSON.stringify(this.configs),
|
|
138
|
+
});
|
|
139
|
+
throw dpe;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
/**
|
|
143
|
+
* Set up the initializer which initializes the GC state from the data in base snapshot. It sets up GC data
|
|
144
|
+
* from the base GC state and starts tracking the state of unreferenced nodes.
|
|
145
|
+
*
|
|
146
|
+
* Must only be called if there is a current reference timestamp.
|
|
147
|
+
*/
|
|
148
|
+
this.initializeGCStateFromBaseSnapshotP = new LazyPromise(async () => {
|
|
149
|
+
const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
|
|
150
|
+
assert(currentReferenceTimestampMs !== undefined, "Trying to initialize GC state without current timestamp");
|
|
151
|
+
/**
|
|
152
|
+
* The base snapshot data will not be present if the container is loaded from:
|
|
153
|
+
* 1. The first summary created by the detached container.
|
|
154
|
+
* 2. A summary that was generated with GC disabled.
|
|
155
|
+
* 3. A summary that was generated before GC even existed.
|
|
156
|
+
*/
|
|
157
|
+
const baseSnapshotData = await this.baseSnapshotDataP;
|
|
158
|
+
this.summaryStateTracker.initializeBaseState(baseSnapshotData);
|
|
159
|
+
if (baseSnapshotData?.gcState === undefined) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
// Update unreferenced state tracking as per the GC state in the snapshot data and update gcDataFromLastRun
|
|
163
|
+
// to the GC data from the snapshot data.
|
|
164
|
+
const gcNodes = {};
|
|
165
|
+
for (const [nodeId, nodeData] of Object.entries(baseSnapshotData.gcState.gcNodes)) {
|
|
166
|
+
if (nodeData.unreferencedTimestampMs !== undefined) {
|
|
167
|
+
this.unreferencedNodesState.set(nodeId, new UnreferencedStateTracker(nodeData.unreferencedTimestampMs, this.configs.inactiveTimeoutMs, currentReferenceTimestampMs, this.configs.sweepTimeoutMs, this.configs.sweepGracePeriodMs));
|
|
168
|
+
}
|
|
169
|
+
gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);
|
|
170
|
+
}
|
|
171
|
+
this.gcDataFromLastRun = { gcNodes };
|
|
172
|
+
});
|
|
173
|
+
// Get the GC details from the GC state in the base summary. This is returned in getBaseGCDetails which is
|
|
174
|
+
// used to initialize the GC state of all the nodes in the container.
|
|
175
|
+
this.baseGCDetailsP = new LazyPromise(async () => {
|
|
176
|
+
const baseSnapshotData = await this.baseSnapshotDataP;
|
|
177
|
+
if (baseSnapshotData?.gcState === undefined) {
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
180
|
+
const gcNodes = {};
|
|
181
|
+
for (const [nodeId, nodeData] of Object.entries(baseSnapshotData.gcState.gcNodes)) {
|
|
182
|
+
gcNodes[nodeId] = Array.from(nodeData.outboundRoutes);
|
|
183
|
+
}
|
|
184
|
+
// Run GC on the nodes in the base summary to get the routes used in each node in the container.
|
|
185
|
+
// This is an optimization for space (vs performance) wherein we don't need to store the used routes of
|
|
186
|
+
// each node in the summary.
|
|
187
|
+
const usedRoutes = runGarbageCollection(gcNodes, ["/"]).referencedNodeIds;
|
|
188
|
+
return { gcData: { gcNodes }, usedRoutes };
|
|
189
|
+
});
|
|
190
|
+
// Log all the GC options and the state determined by the garbage collector.
|
|
191
|
+
// This is useful even for interactive clients since they track unreferenced nodes and log errors.
|
|
192
|
+
this.mc.logger.sendTelemetryEvent({
|
|
193
|
+
eventName: "GarbageCollectorLoaded",
|
|
194
|
+
gcConfigs: JSON.stringify(this.configs),
|
|
195
|
+
gcOptions: JSON.stringify(createParams.gcOptions),
|
|
196
|
+
...createParams.createContainerMetadata,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Called during container initialization. Initializes the tombstone and deleted nodes state from the base snapshot.
|
|
201
|
+
* Also, initializes the GC state including unreferenced nodes tracking if a current reference timestamp exists.
|
|
202
|
+
* Note that if there is any GC state in the base snapshot, then there will definitely be a reference timestamp
|
|
203
|
+
* to work with - The GC state would have been generated using a timestamp which is part of the snapshot.
|
|
204
|
+
*/
|
|
205
|
+
async initializeBaseState() {
|
|
206
|
+
const baseSnapshotData = await this.baseSnapshotDataP;
|
|
207
|
+
/**
|
|
208
|
+
* The base snapshot data will not be present if the container is loaded from:
|
|
209
|
+
* 1. The first summary created by the detached container.
|
|
210
|
+
* 2. A summary that was generated with GC disabled.
|
|
211
|
+
* 3. A summary that was generated before GC even existed.
|
|
212
|
+
*/
|
|
213
|
+
if (baseSnapshotData === undefined) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
// Initialize the deleted nodes from the snapshot. This is done irrespective of whether sweep is enabled or not
|
|
217
|
+
// to identify deleted nodes' usage.
|
|
218
|
+
if (baseSnapshotData.deletedNodes !== undefined) {
|
|
219
|
+
this.deletedNodes = new Set(baseSnapshotData.deletedNodes);
|
|
220
|
+
}
|
|
221
|
+
// If running in tombstone mode, initialize the tombstone state from the snapshot. Also, notify the runtime of
|
|
222
|
+
// tombstone routes.
|
|
223
|
+
if (this.configs.tombstoneMode && baseSnapshotData.tombstones !== undefined) {
|
|
224
|
+
// Create a copy since we are writing from a source we don't control
|
|
225
|
+
this.tombstones = Array.from(baseSnapshotData.tombstones);
|
|
226
|
+
this.runtime.updateTombstonedRoutes(this.tombstones);
|
|
227
|
+
}
|
|
228
|
+
await this.initializeOrUpdateGCState();
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Initialize the GC state if not already initialized. If GC state is already initialized, update the unreferenced
|
|
232
|
+
* state tracking as per the current reference timestamp.
|
|
233
|
+
*/
|
|
234
|
+
async initializeOrUpdateGCState() {
|
|
235
|
+
const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
|
|
236
|
+
if (currentReferenceTimestampMs === undefined) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
// If the GC state hasn't been initialized yet, initialize it and return.
|
|
240
|
+
if (this.gcDataFromLastRun === undefined) {
|
|
241
|
+
await this.initializeGCStateFromBaseSnapshotP;
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
// If the GC state has been initialized, update the tracking of unreferenced nodes as per the current
|
|
245
|
+
// reference timestamp.
|
|
246
|
+
for (const [, nodeStateTracker] of this.unreferencedNodesState) {
|
|
247
|
+
nodeStateTracker.updateTracking(currentReferenceTimestampMs);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Called when the connection state of the runtime changes, i.e., it connects or disconnects. GC subscribes to this
|
|
252
|
+
* to initialize or update the unreference state tracking.
|
|
253
|
+
* @param connected - Whether the runtime connected / disconnected.
|
|
254
|
+
* @param clientId - The clientId of this runtime.
|
|
255
|
+
*/
|
|
256
|
+
setConnectionState(connected, clientId) {
|
|
257
|
+
/**
|
|
258
|
+
* When the client connects (or reconnects), attempt to initialize or update the GC state. This will keep
|
|
259
|
+
* the unreferenced state tracking updated as per the reference timestamp at the time of connection.
|
|
260
|
+
*
|
|
261
|
+
* During GC initialization and during connections in read mode, it is possible that either no ops are
|
|
262
|
+
* processed or only trailing ops are processed. This means that the GC state is not initialized or initialized
|
|
263
|
+
* with an older reference timestamp. So, doing this on every connection will keep the unreferenced state
|
|
264
|
+
* tracking up-to-date.
|
|
265
|
+
*/
|
|
266
|
+
if (connected && this.configs.shouldRunGC) {
|
|
267
|
+
this.initializeOrUpdateGCState().catch((error) => {
|
|
268
|
+
this.mc.logger.sendErrorEvent({
|
|
269
|
+
eventName: "GCInitializationOrUpdateFailed",
|
|
270
|
+
gcConfigs: JSON.stringify(this.configs),
|
|
271
|
+
}, error);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Returns a the GC details generated from the base summary. This is used to initialize the GC state of the nodes
|
|
277
|
+
* in the container.
|
|
278
|
+
*/
|
|
279
|
+
async getBaseGCDetails() {
|
|
280
|
+
return this.baseGCDetailsP;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Runs garbage collection and updates the reference / used state of the nodes in the container.
|
|
284
|
+
* @returns stats of the GC run or undefined if GC did not run.
|
|
285
|
+
*/
|
|
286
|
+
async collectGarbage(options, telemetryContext) {
|
|
287
|
+
const fullGC = options.fullGC ??
|
|
288
|
+
(this.configs.runFullGC === true || this.summaryStateTracker.doesSummaryStateNeedReset);
|
|
289
|
+
// Add the options that are used to run GC to the telemetry context.
|
|
290
|
+
telemetryContext?.setMultiple("fluid_GC", "Options", {
|
|
291
|
+
fullGC,
|
|
292
|
+
runSweep: options.runSweep,
|
|
293
|
+
});
|
|
294
|
+
const logger = options.logger
|
|
295
|
+
? createChildLogger({
|
|
296
|
+
logger: options.logger,
|
|
297
|
+
properties: {
|
|
298
|
+
all: { completedGCRuns: () => this.completedRuns },
|
|
299
|
+
},
|
|
300
|
+
})
|
|
301
|
+
: this.mc.logger;
|
|
302
|
+
/**
|
|
303
|
+
* If there is no current reference timestamp, skip running GC. We need the current timestamp to track
|
|
304
|
+
* how long objects have been unreferenced and if they should be deleted.
|
|
305
|
+
*
|
|
306
|
+
* Note that the only scenario where GC is called and there is no reference timestamp is when no ops have ever
|
|
307
|
+
* been processed for this container and it is in read mode. In this scenario, there is no point in running GC
|
|
308
|
+
* anyway because references in the container do not change without any ops, i.e., there is nothing to collect.
|
|
309
|
+
*/
|
|
310
|
+
const currentReferenceTimestampMs = this.runtime.getCurrentReferenceTimestampMs();
|
|
311
|
+
if (currentReferenceTimestampMs === undefined) {
|
|
312
|
+
// Log an event so we can evaluate how often we run into this scenario.
|
|
313
|
+
logger.sendErrorEvent({
|
|
314
|
+
eventName: "CollectGarbageCalledWithoutTimestamp",
|
|
315
|
+
gcConfigs: JSON.stringify(this.configs),
|
|
316
|
+
});
|
|
317
|
+
return undefined;
|
|
318
|
+
}
|
|
319
|
+
return PerformanceEvent.timedExecAsync(logger, { eventName: "GarbageCollection" }, async (event) => {
|
|
320
|
+
/** Pre-GC steps */
|
|
321
|
+
// Ensure that state has been initialized from the base snapshot data.
|
|
322
|
+
await this.initializeGCStateFromBaseSnapshotP;
|
|
323
|
+
// Let the runtime update its pending state before GC runs.
|
|
324
|
+
await this.runtime.updateStateBeforeGC();
|
|
325
|
+
/** GC step */
|
|
326
|
+
const gcStats = await this.runGC(fullGC, currentReferenceTimestampMs, logger);
|
|
327
|
+
event.end({
|
|
328
|
+
...gcStats,
|
|
329
|
+
timestamp: currentReferenceTimestampMs,
|
|
330
|
+
sweep: this.configs.shouldRunSweep,
|
|
331
|
+
});
|
|
332
|
+
/** Post-GC steps */
|
|
333
|
+
// Log pending unreferenced events such as a node being used after inactive. This is done after GC runs and
|
|
334
|
+
// updates its state so that we don't send false positives based on intermediate state. For example, we may get
|
|
335
|
+
// reference to an unreferenced node from another unreferenced node which means the node wasn't revived.
|
|
336
|
+
await this.telemetryTracker.logPendingEvents(logger);
|
|
337
|
+
// Update the state of summary state tracker from this run's stats.
|
|
338
|
+
this.summaryStateTracker.updateStateFromGCRunStats(gcStats);
|
|
339
|
+
this.newReferencesSinceLastRun.clear();
|
|
340
|
+
this.completedRuns++;
|
|
341
|
+
return gcStats;
|
|
342
|
+
}, { end: true, cancel: "error" });
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Runs garbage collection. It does the following:
|
|
346
|
+
*
|
|
347
|
+
* 1. It generates / analyzes the runtime's reference graph.
|
|
348
|
+
*
|
|
349
|
+
* 2. Generates mark phase stats.
|
|
350
|
+
*
|
|
351
|
+
* 3. Runs Mark phase.
|
|
352
|
+
*
|
|
353
|
+
* 4. Runs Sweep phase.
|
|
354
|
+
*
|
|
355
|
+
* 5. Generates sweep phase stats.
|
|
356
|
+
*/
|
|
357
|
+
async runGC(fullGC, currentReferenceTimestampMs, logger) {
|
|
358
|
+
// 1. Generate / analyze the runtime's reference graph.
|
|
359
|
+
// Get the reference graph (gcData) and run GC algorithm to get referenced / unreferenced nodes.
|
|
360
|
+
const gcData = await this.runtime.getGCData(fullGC);
|
|
361
|
+
const gcResult = runGarbageCollection(gcData.gcNodes, ["/"]);
|
|
362
|
+
// Get all referenced nodes - References in this run + references between the previous and current runs.
|
|
363
|
+
const allReferencedNodeIds = this.findAllNodesReferencedBetweenGCs(gcData, this.gcDataFromLastRun, logger) ??
|
|
364
|
+
gcResult.referencedNodeIds;
|
|
365
|
+
// 2. Get the mark phase stats based on the previous / current GC state.
|
|
366
|
+
// This is done before running mark phase because we need the previous GC state before it is updated.
|
|
367
|
+
const markPhaseStats = this.getMarkPhaseStats(gcResult);
|
|
368
|
+
// 3. Run the Mark phase.
|
|
369
|
+
// It will mark nodes as referenced / unreferenced and return lists of tombstone-ready and sweep-ready nodes.
|
|
370
|
+
const { tombstoneReadyNodeIds, sweepReadyNodeIds } = this.runMarkPhase(gcResult, allReferencedNodeIds, currentReferenceTimestampMs);
|
|
371
|
+
// 4. Run the Sweep phase.
|
|
372
|
+
// It will tombstone any tombstone-ready nodes, and initiate the deletion of sweep-ready nodes by sending a
|
|
373
|
+
// sweep op. All clients, including this one, will delete these nodes once it processes the op.
|
|
374
|
+
this.runSweepPhase(gcResult, tombstoneReadyNodeIds, sweepReadyNodeIds);
|
|
375
|
+
this.gcDataFromLastRun = cloneGCData(gcData);
|
|
376
|
+
// 5. Get the sweep phase stats.
|
|
377
|
+
const sweepPhaseStats = this.getSweepPhaseStats(this.deletedNodes, sweepReadyNodeIds, markPhaseStats);
|
|
378
|
+
return { ...markPhaseStats, ...sweepPhaseStats };
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Runs the GC Mark phase. It does the following:
|
|
382
|
+
*
|
|
383
|
+
* 1. Marks all referenced nodes in this run by clearing tracking for them.
|
|
384
|
+
*
|
|
385
|
+
* 2. Marks unreferenced nodes in this run by starting tracking for them.
|
|
386
|
+
*
|
|
387
|
+
* 3. Calls the runtime to update nodes that were marked referenced.
|
|
388
|
+
*
|
|
389
|
+
* @param gcResult - The result of the GC run on the gcData.
|
|
390
|
+
* @param allReferencedNodeIds - Nodes referenced in this GC run + referenced between previous and current GC run.
|
|
391
|
+
* @param currentReferenceTimestampMs - The timestamp to be used for unreferenced nodes' timestamp.
|
|
392
|
+
* @returns The sets of tombstone-ready and sweep-ready nodes, i.e., nodes that ready to be tombstoned or deleted.
|
|
393
|
+
*/
|
|
394
|
+
runMarkPhase(gcResult, allReferencedNodeIds, currentReferenceTimestampMs) {
|
|
395
|
+
// 1. Marks all referenced nodes by clearing their unreferenced tracker, if any.
|
|
396
|
+
for (const nodeId of allReferencedNodeIds) {
|
|
397
|
+
const nodeStateTracker = this.unreferencedNodesState.get(nodeId);
|
|
398
|
+
if (nodeStateTracker !== undefined) {
|
|
399
|
+
// Stop tracking so as to clear out any running timers.
|
|
400
|
+
nodeStateTracker.stopTracking();
|
|
401
|
+
// Delete the node as we don't need to track it any more.
|
|
402
|
+
this.unreferencedNodesState.delete(nodeId);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
// 2. Mark unreferenced nodes in this run by starting unreferenced tracking for them.
|
|
406
|
+
const tombstoneReadyNodeIds = new Set();
|
|
407
|
+
const sweepReadyNodeIds = new Set();
|
|
408
|
+
for (const nodeId of gcResult.deletedNodeIds) {
|
|
409
|
+
const nodeStateTracker = this.unreferencedNodesState.get(nodeId);
|
|
410
|
+
if (nodeStateTracker === undefined) {
|
|
411
|
+
this.unreferencedNodesState.set(nodeId, new UnreferencedStateTracker(currentReferenceTimestampMs, this.configs.inactiveTimeoutMs, currentReferenceTimestampMs, this.configs.sweepTimeoutMs, this.configs.sweepGracePeriodMs));
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
// If a node was already unreferenced, update its tracking information. Since the current reference time
|
|
415
|
+
// is from the ops seen, this will ensure that we keep updating unreferenced state as time moves forward.
|
|
416
|
+
nodeStateTracker.updateTracking(currentReferenceTimestampMs);
|
|
417
|
+
// If a node is tombstone or sweep-ready, store it so it can be returned.
|
|
418
|
+
if (nodeStateTracker.state === UnreferencedState.TombstoneReady) {
|
|
419
|
+
tombstoneReadyNodeIds.add(nodeId);
|
|
420
|
+
}
|
|
421
|
+
if (nodeStateTracker.state === UnreferencedState.SweepReady) {
|
|
422
|
+
sweepReadyNodeIds.add(nodeId);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// 3. Call the runtime to update referenced nodes in this run.
|
|
427
|
+
this.runtime.updateUsedRoutes(gcResult.referencedNodeIds);
|
|
428
|
+
return { tombstoneReadyNodeIds, sweepReadyNodeIds };
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Runs the GC Sweep phase. It does the following:
|
|
432
|
+
*
|
|
433
|
+
* 1. Marks tombstone-ready nodes as tombstones.
|
|
434
|
+
*
|
|
435
|
+
* 2. Sends a sweep op to delete nodes that are sweep-ready. Once the op is ack'd, these nodes will be deleted.
|
|
436
|
+
*
|
|
437
|
+
* @param gcResult - The result of the GC run on the gcData.
|
|
438
|
+
* @param tombstoneReadyNodes - List of nodes that are tombstone-ready.
|
|
439
|
+
* @param sweepReadyNodes - List of nodes that are sweep-ready.
|
|
440
|
+
*/
|
|
441
|
+
runSweepPhase(gcResult, tombstoneReadyNodes, sweepReadyNodes) {
|
|
442
|
+
/**
|
|
443
|
+
* Under "Test Mode", unreferenced nodes are immediately deleted without waiting for them to be sweep-ready.
|
|
444
|
+
*
|
|
445
|
+
* Otherwise, depending on how long it's been since the node was unreferenced, it will either be
|
|
446
|
+
* marked as Tombstone, or deleted by Sweep.
|
|
447
|
+
*/
|
|
448
|
+
if (this.configs.testMode) {
|
|
449
|
+
// If we are running in GC test mode, unreferenced nodes (gcResult.deletedNodeIds) are deleted.
|
|
450
|
+
this.runtime.updateUnusedRoutes(gcResult.deletedNodeIds);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
// If sweep is disabled, we'll tombstone both tombstone-ready and sweep-ready nodes.
|
|
454
|
+
// This is important because a container may never load during a node's Sweep Grace Period,
|
|
455
|
+
// so that node would directly become sweep-ready skipping over tombstone-ready state,
|
|
456
|
+
// but should be Tombstoned since Sweep is disabled.
|
|
457
|
+
const { nodesToTombstone, nodesToDelete } = this.configs.shouldRunSweep
|
|
458
|
+
? {
|
|
459
|
+
nodesToTombstone: [...tombstoneReadyNodes],
|
|
460
|
+
nodesToDelete: [...sweepReadyNodes],
|
|
461
|
+
}
|
|
462
|
+
: {
|
|
463
|
+
nodesToTombstone: [...tombstoneReadyNodes, ...sweepReadyNodes],
|
|
464
|
+
nodesToDelete: [],
|
|
465
|
+
};
|
|
466
|
+
if (this.configs.tombstoneMode) {
|
|
467
|
+
this.tombstones = nodesToTombstone;
|
|
468
|
+
// If we are running in GC tombstone mode, update tombstoned routes.
|
|
469
|
+
this.runtime.updateTombstonedRoutes(this.tombstones);
|
|
470
|
+
}
|
|
471
|
+
if (this.configs.shouldRunSweep && nodesToDelete.length > 0) {
|
|
472
|
+
// Do not send DDS node ids in the GC op. This is an optimization to reduce its size. Since GC applies to
|
|
473
|
+
// to data store only, all its DDSes are deleted along with it. The DDS ids will be retrieved from the
|
|
474
|
+
// local state when processing the op.
|
|
475
|
+
const sweepReadyDSAndBlobs = nodesToDelete.filter((nodeId) => {
|
|
476
|
+
const nodeType = this.runtime.getNodeType(nodeId);
|
|
477
|
+
return nodeType === GCNodeType.DataStore || nodeType === GCNodeType.Blob;
|
|
478
|
+
});
|
|
479
|
+
const contents = {
|
|
480
|
+
type: GarbageCollectionMessageType.Sweep,
|
|
481
|
+
deletedNodeIds: sweepReadyDSAndBlobs,
|
|
482
|
+
};
|
|
483
|
+
// Its fine for older clients to ignore this op because it doesn't have any functional impact. This op
|
|
484
|
+
// is an optimization to ensure that all clients are in sync when it comes to deleted nodes to prevent their
|
|
485
|
+
// accidental usage. The clients will sync without the delete op too but it may take longer.
|
|
486
|
+
const containerGCMessage = {
|
|
487
|
+
type: ContainerMessageType.GC,
|
|
488
|
+
contents,
|
|
489
|
+
compatDetails: { behavior: "Ignore" },
|
|
490
|
+
};
|
|
491
|
+
this.submitMessage(containerGCMessage);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Since GC runs periodically, the GC data that is generated only tells us the state of the world at that point in
|
|
497
|
+
* time. There can be nodes that were referenced in between two runs and their unreferenced state needs to be
|
|
498
|
+
* updated. For example, in the following scenarios not updating the unreferenced timestamp can lead to deletion of
|
|
499
|
+
* these objects while there can be in-memory referenced to it:
|
|
500
|
+
* 1. A node transitions from `unreferenced -> referenced -> unreferenced` between two runs. When the reference is
|
|
501
|
+
* added, the object may have been accessed and in-memory reference to it added.
|
|
502
|
+
* 2. A reference is added from one unreferenced node to one or more unreferenced nodes. Even though the node[s] were
|
|
503
|
+
* unreferenced, they could have been accessed and in-memory reference to them added.
|
|
504
|
+
*
|
|
505
|
+
* This function identifies nodes that were referenced since the last run.
|
|
506
|
+
* If these nodes are currently unreferenced, they will be assigned new unreferenced state by the current run.
|
|
507
|
+
*
|
|
508
|
+
* @returns A list of all nodes referenced from the last local summary until now.
|
|
509
|
+
*/
|
|
510
|
+
findAllNodesReferencedBetweenGCs(currentGCData, previousGCData, logger) {
|
|
511
|
+
// If we haven't run GC before there is nothing to do.
|
|
512
|
+
// No previousGCData, means nothing is unreferenced, and there are no reference state trackers to clear
|
|
513
|
+
if (previousGCData === undefined) {
|
|
514
|
+
return undefined;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* If there are references that were not explicitly notified to GC, log an error because this should never happen.
|
|
518
|
+
* If it does, this may result in the unreferenced timestamps of these nodes not updated when they were referenced.
|
|
519
|
+
*/
|
|
520
|
+
this.telemetryTracker.logIfMissingExplicitReferences(currentGCData, previousGCData, this.newReferencesSinceLastRun, logger);
|
|
521
|
+
// No references were added since the last run so we don't have to update reference states of any unreferenced
|
|
522
|
+
// nodes. There is no in between state at this point.
|
|
523
|
+
if (this.newReferencesSinceLastRun.size === 0) {
|
|
524
|
+
return undefined;
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* Generate a super set of the GC data that contains the nodes and edges from last run, plus any new node and
|
|
528
|
+
* edges that have been added since then. To do this, combine the GC data from the last run and the current
|
|
529
|
+
* run, and then add the references since last run.
|
|
530
|
+
*
|
|
531
|
+
* Note on why we need to combine the data from previous run, current run and all references in between -
|
|
532
|
+
* 1. We need data from last run because some of its references may have been deleted since then. If those
|
|
533
|
+
* references added new outbound references before they were deleted, we need to detect them.
|
|
534
|
+
*
|
|
535
|
+
* 2. We need new outbound references since last run because some of them may have been deleted later. If those
|
|
536
|
+
* references added new outbound references before they were deleted, we need to detect them.
|
|
537
|
+
*
|
|
538
|
+
* 3. We need data from the current run because currently we may not detect when DDSes are referenced:
|
|
539
|
+
* - We don't require DDSes handles to be stored in a referenced DDS.
|
|
540
|
+
* - A new data store may have "root" DDSes already created and we don't detect them today.
|
|
541
|
+
*/
|
|
542
|
+
const gcDataSuperSet = concatGarbageCollectionData(previousGCData, currentGCData);
|
|
543
|
+
const newOutboundRoutesSinceLastRun = [];
|
|
544
|
+
this.newReferencesSinceLastRun.forEach((outboundRoutes, sourceNodeId) => {
|
|
545
|
+
if (gcDataSuperSet.gcNodes[sourceNodeId] === undefined) {
|
|
546
|
+
gcDataSuperSet.gcNodes[sourceNodeId] = outboundRoutes;
|
|
547
|
+
}
|
|
548
|
+
else {
|
|
549
|
+
gcDataSuperSet.gcNodes[sourceNodeId].push(...outboundRoutes);
|
|
550
|
+
}
|
|
551
|
+
newOutboundRoutesSinceLastRun.push(...outboundRoutes);
|
|
552
|
+
});
|
|
553
|
+
/**
|
|
554
|
+
* Run GC on the above reference graph starting with root and all new outbound routes. This will generate a
|
|
555
|
+
* list of all nodes that could have been referenced since the last run. If any of these nodes are unreferenced,
|
|
556
|
+
* unreferenced, stop tracking them and remove from unreferenced list.
|
|
557
|
+
* Note that some of these nodes may be unreferenced now and if so, the current run will mark them as
|
|
558
|
+
* unreferenced and add unreferenced state.
|
|
559
|
+
*/
|
|
560
|
+
const gcResult = runGarbageCollection(gcDataSuperSet.gcNodes, [
|
|
561
|
+
"/",
|
|
562
|
+
...newOutboundRoutesSinceLastRun,
|
|
563
|
+
]);
|
|
564
|
+
return gcResult.referencedNodeIds;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Summarizes the GC data and returns it as a summary tree.
|
|
568
|
+
* We current write the entire GC state in a single blob. This can be modified later to write multiple
|
|
569
|
+
* blobs. All the blob keys should start with `gcBlobPrefix`.
|
|
570
|
+
*/
|
|
571
|
+
summarize(fullTree, trackState, telemetryContext) {
|
|
572
|
+
if (!this.configs.shouldRunGC || this.gcDataFromLastRun === undefined) {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
const gcState = { gcNodes: {} };
|
|
576
|
+
for (const [nodeId, outboundRoutes] of Object.entries(this.gcDataFromLastRun.gcNodes)) {
|
|
577
|
+
gcState.gcNodes[nodeId] = {
|
|
578
|
+
outboundRoutes,
|
|
579
|
+
unreferencedTimestampMs: this.unreferencedNodesState.get(nodeId)?.unreferencedTimestampMs,
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
return this.summaryStateTracker.summarize(fullTree, trackState, gcState, this.deletedNodes, this.tombstones);
|
|
583
|
+
}
|
|
584
|
+
getMetadata() {
|
|
585
|
+
return {
|
|
586
|
+
/**
|
|
587
|
+
* If GC is enabled, the GC data is written using the GC version in effect and that is the gcFeature that goes
|
|
588
|
+
* into the metadata blob. If GC is disabled, the gcFeature is 0.
|
|
589
|
+
*/
|
|
590
|
+
gcFeature: this.configs.gcEnabled ? this.configs.gcVersionInEffect : 0,
|
|
591
|
+
gcFeatureMatrix: this.configs.persistedGcFeatureMatrix,
|
|
592
|
+
sessionExpiryTimeoutMs: this.configs.sessionExpiryTimeoutMs,
|
|
593
|
+
sweepEnabled: false,
|
|
594
|
+
sweepTimeoutMs: this.configs.sweepTimeoutMs,
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Called to refresh the latest summary state. This happens when either a pending summary is acked.
|
|
599
|
+
*/
|
|
600
|
+
async refreshLatestSummary(result) {
|
|
601
|
+
return this.summaryStateTracker.refreshLatestSummary(result);
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Process a GC message.
|
|
605
|
+
* @param message - The GC message from the container runtime.
|
|
606
|
+
* @param local - Whether it was send by this client.
|
|
607
|
+
*/
|
|
608
|
+
processMessage(message, local) {
|
|
609
|
+
switch (message.contents.type) {
|
|
610
|
+
case "Sweep": {
|
|
611
|
+
// Delete the nodes whose ids are present in the contents.
|
|
612
|
+
this.deleteSweepReadyNodes(message.contents.deletedNodeIds);
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
default: {
|
|
616
|
+
if (!compatBehaviorAllowsGCMessageType(message.contents.type, message.compatDetails?.behavior)) {
|
|
617
|
+
const error = DataProcessingError.create(`Garbage collection message of unknown type ${message.contents.type}`, "processMessage");
|
|
618
|
+
throw error;
|
|
619
|
+
}
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
/**
|
|
625
|
+
* Delete nodes that are sweep-ready. Call the runtime to delete these nodes and clear the unreferenced state
|
|
626
|
+
* tracking for nodes that are actually deleted by the runtime.
|
|
627
|
+
* @param sweepReadyNodeIds - The ids of nodes that are ready to be deleted.
|
|
628
|
+
*/
|
|
629
|
+
deleteSweepReadyNodes(sweepReadyNodeIds) {
|
|
630
|
+
// Use a set for lookup because its much faster than array or map.
|
|
631
|
+
const sweepReadyNodesSet = new Set(sweepReadyNodeIds);
|
|
632
|
+
// The ids in the sweep-ready nodes do not contain DDS node ids. This is an optimization to reduce the size
|
|
633
|
+
// of the GC op. Since GC applies to data store only, all its DDSes are deleted along with it. So, get the
|
|
634
|
+
// DDS nodes ID from the unreferenced nodes state.
|
|
635
|
+
const allSweepReadyNodeIds = Array.from(sweepReadyNodeIds);
|
|
636
|
+
for (const [id] of this.unreferencedNodesState) {
|
|
637
|
+
// Ignore data store nodes since they would already be in the list.
|
|
638
|
+
const pathParts = id.split("/");
|
|
639
|
+
if (pathParts.length <= 2) {
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
// Get the data store id part. Note that this may include blobs but that's okay since the part would just
|
|
643
|
+
// be "_blobs" and it won't be found.
|
|
644
|
+
const dsId = `/${pathParts[1]}`;
|
|
645
|
+
if (sweepReadyNodesSet.has(dsId)) {
|
|
646
|
+
allSweepReadyNodeIds.push(id);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const deletedNodeIds = this.runtime.deleteSweepReadyNodes(allSweepReadyNodeIds);
|
|
650
|
+
// Clear unreferenced state tracking for deleted nodes.
|
|
651
|
+
for (const nodeId of deletedNodeIds) {
|
|
652
|
+
const nodeStateTracker = this.unreferencedNodesState.get(nodeId);
|
|
653
|
+
if (nodeStateTracker !== undefined) {
|
|
654
|
+
// Stop tracking so as to clear out any running timers.
|
|
655
|
+
nodeStateTracker.stopTracking();
|
|
656
|
+
// Delete the node as we don't need to track it any more.
|
|
657
|
+
this.unreferencedNodesState.delete(nodeId);
|
|
658
|
+
}
|
|
659
|
+
this.deletedNodes.add(nodeId);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Called when a node with the given id is updated. If the node is inactive or tombstoned, this will log an error
|
|
664
|
+
* or throw an error if failing on incorrect usage is configured.
|
|
665
|
+
* @param nodePath - The path of the node that changed.
|
|
666
|
+
* @param reason - Whether the node was loaded or changed.
|
|
667
|
+
* @param timestampMs - The timestamp when the node changed.
|
|
668
|
+
* @param packagePath - The package path of the node. This may not be available if the node hasn't been loaded yet.
|
|
669
|
+
* @param request - The original request for loads to preserve it in telemetry.
|
|
670
|
+
* @param requestHeaders - If the node was loaded via request path, the headers in the request.
|
|
671
|
+
*/
|
|
672
|
+
nodeUpdated(nodePath, reason, timestampMs, packagePath, request, headerData) {
|
|
673
|
+
if (!this.configs.shouldRunGC) {
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
const isTombstoned = this.tombstones.includes(nodePath);
|
|
677
|
+
// This will log if appropriate
|
|
678
|
+
this.telemetryTracker.nodeUsed({
|
|
679
|
+
id: nodePath,
|
|
680
|
+
usageType: reason,
|
|
681
|
+
currentReferenceTimestampMs: timestampMs ?? this.runtime.getCurrentReferenceTimestampMs(),
|
|
682
|
+
packagePath,
|
|
683
|
+
completedGCRuns: this.completedRuns,
|
|
684
|
+
isTombstoned,
|
|
685
|
+
lastSummaryTime: this.getLastSummaryTimestampMs(),
|
|
686
|
+
headers: headerData,
|
|
687
|
+
});
|
|
688
|
+
const nodeType = this.runtime.getNodeType(nodePath);
|
|
689
|
+
// Unless this is a Loaded event for a Blob or DataStore, we're done after telemetry tracking
|
|
690
|
+
if (reason !== "Loaded" || ![GCNodeType.Blob, GCNodeType.DataStore].includes(nodeType)) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
const errorRequest = request ?? { url: nodePath };
|
|
694
|
+
// If the object is tombstoned and tombstone enforcement is configured, throw an error.
|
|
695
|
+
if (isTombstoned && this.throwOnTombstoneLoad && headerData?.allowTombstone !== true) {
|
|
696
|
+
// The requested data store is removed by gc. Create a 404 gc response exception.
|
|
697
|
+
throw responseToException(createResponseError(404, `${nodeType} was tombstoned`, errorRequest, {
|
|
698
|
+
[TombstoneResponseHeaderKey]: true,
|
|
699
|
+
}), errorRequest);
|
|
700
|
+
}
|
|
701
|
+
// If the object is inactive and inactive enforcement is configured, throw an error.
|
|
702
|
+
if (this.unreferencedNodesState.get(nodePath)?.state === "Inactive") {
|
|
703
|
+
const shouldThrowOnInactiveLoad = !this.isSummarizerClient &&
|
|
704
|
+
this.configs.throwOnInactiveLoad === true &&
|
|
705
|
+
headerData?.allowInactive !== true;
|
|
706
|
+
if (shouldThrowOnInactiveLoad) {
|
|
707
|
+
throw responseToException(createResponseError(404, `${nodeType} is inactive`, errorRequest, {
|
|
708
|
+
[InactiveResponseHeaderKey]: true,
|
|
709
|
+
}), errorRequest);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Called when an outbound reference is added to a node. This is used to identify all nodes that have been
|
|
715
|
+
* referenced between summaries so that their unreferenced timestamp can be reset.
|
|
716
|
+
*
|
|
717
|
+
* @param fromNodePath - The node from which the reference is added.
|
|
718
|
+
* @param toNodePath - The node to which the reference is added.
|
|
719
|
+
*/
|
|
720
|
+
addedOutboundReference(fromNodePath, toNodePath) {
|
|
721
|
+
if (!this.configs.shouldRunGC) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
const outboundRoutes = this.newReferencesSinceLastRun.get(fromNodePath) ?? [];
|
|
725
|
+
outboundRoutes.push(toNodePath);
|
|
726
|
+
this.newReferencesSinceLastRun.set(fromNodePath, outboundRoutes);
|
|
727
|
+
this.telemetryTracker.nodeUsed({
|
|
728
|
+
id: toNodePath,
|
|
729
|
+
usageType: "Revived",
|
|
730
|
+
currentReferenceTimestampMs: this.runtime.getCurrentReferenceTimestampMs(),
|
|
731
|
+
packagePath: undefined,
|
|
732
|
+
completedGCRuns: this.completedRuns,
|
|
733
|
+
isTombstoned: this.tombstones.includes(toNodePath),
|
|
734
|
+
lastSummaryTime: this.getLastSummaryTimestampMs(),
|
|
735
|
+
fromId: fromNodePath,
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Returns whether a node with the given path has been deleted or not. This can be used by the runtime to identify
|
|
740
|
+
* cases where objects are used after they are deleted and throw / log errors accordingly.
|
|
741
|
+
*/
|
|
742
|
+
isNodeDeleted(nodePath) {
|
|
743
|
+
return this.deletedNodes.has(nodePath);
|
|
744
|
+
}
|
|
745
|
+
dispose() {
|
|
746
|
+
this.sessionExpiryTimer?.clear();
|
|
747
|
+
this.sessionExpiryTimer = undefined;
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* Generates the stats of a garbage collection mark phase run.
|
|
751
|
+
* @param gcResult - The result of the current GC run.
|
|
752
|
+
* @returns the stats of the mark phase run.
|
|
753
|
+
*/
|
|
754
|
+
getMarkPhaseStats(gcResult) {
|
|
755
|
+
const markPhaseStats = {
|
|
756
|
+
nodeCount: 0,
|
|
757
|
+
dataStoreCount: 0,
|
|
758
|
+
attachmentBlobCount: 0,
|
|
759
|
+
unrefNodeCount: 0,
|
|
760
|
+
unrefDataStoreCount: 0,
|
|
761
|
+
unrefAttachmentBlobCount: 0,
|
|
762
|
+
updatedNodeCount: 0,
|
|
763
|
+
updatedDataStoreCount: 0,
|
|
764
|
+
updatedAttachmentBlobCount: 0,
|
|
765
|
+
};
|
|
766
|
+
const updateNodeStats = (nodeId, referenced) => {
|
|
767
|
+
markPhaseStats.nodeCount++;
|
|
768
|
+
// If there is no previous GC data, every node's state is generated and is considered as updated.
|
|
769
|
+
// Otherwise, find out if any node went from referenced to unreferenced or vice-versa.
|
|
770
|
+
const stateUpdated = this.gcDataFromLastRun === undefined ||
|
|
771
|
+
this.unreferencedNodesState.has(nodeId) === referenced;
|
|
772
|
+
if (stateUpdated) {
|
|
773
|
+
markPhaseStats.updatedNodeCount++;
|
|
774
|
+
}
|
|
775
|
+
if (!referenced) {
|
|
776
|
+
markPhaseStats.unrefNodeCount++;
|
|
777
|
+
}
|
|
778
|
+
if (this.runtime.getNodeType(nodeId) === GCNodeType.DataStore) {
|
|
779
|
+
markPhaseStats.dataStoreCount++;
|
|
780
|
+
if (stateUpdated) {
|
|
781
|
+
markPhaseStats.updatedDataStoreCount++;
|
|
782
|
+
}
|
|
783
|
+
if (!referenced) {
|
|
784
|
+
markPhaseStats.unrefDataStoreCount++;
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
if (this.runtime.getNodeType(nodeId) === GCNodeType.Blob) {
|
|
788
|
+
markPhaseStats.attachmentBlobCount++;
|
|
789
|
+
if (stateUpdated) {
|
|
790
|
+
markPhaseStats.updatedAttachmentBlobCount++;
|
|
791
|
+
}
|
|
792
|
+
if (!referenced) {
|
|
793
|
+
markPhaseStats.unrefAttachmentBlobCount++;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
for (const nodeId of gcResult.referencedNodeIds) {
|
|
798
|
+
updateNodeStats(nodeId, true /* referenced */);
|
|
799
|
+
}
|
|
800
|
+
for (const nodeId of gcResult.deletedNodeIds) {
|
|
801
|
+
updateNodeStats(nodeId, false /* referenced */);
|
|
802
|
+
}
|
|
803
|
+
return markPhaseStats;
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Generates the stats of a garbage collection sweep phase run.
|
|
807
|
+
* @param deletedNodes - The nodes that have been deleted until this run.
|
|
808
|
+
* @param sweepReadyNodes - The nodes that are sweep-ready in this GC run.
|
|
809
|
+
* @param markPhaseStats - The stats of the mark phase run.
|
|
810
|
+
* @returns the stats of the sweep phase run.
|
|
811
|
+
*/
|
|
812
|
+
getSweepPhaseStats(deletedNodes, sweepReadyNodes, markPhaseStats) {
|
|
813
|
+
// Initialize the life time node counts to the mark phase node counts. If sweep is not enabled,
|
|
814
|
+
// these will be the life time node count for this container.
|
|
815
|
+
const sweepPhaseStats = {
|
|
816
|
+
lifetimeNodeCount: markPhaseStats.nodeCount,
|
|
817
|
+
lifetimeDataStoreCount: markPhaseStats.dataStoreCount,
|
|
818
|
+
lifetimeAttachmentBlobCount: markPhaseStats.attachmentBlobCount,
|
|
819
|
+
deletedNodeCount: 0,
|
|
820
|
+
deletedDataStoreCount: 0,
|
|
821
|
+
deletedAttachmentBlobCount: 0,
|
|
822
|
+
};
|
|
823
|
+
for (const nodeId of deletedNodes) {
|
|
824
|
+
sweepPhaseStats.deletedNodeCount++;
|
|
825
|
+
const nodeType = this.runtime.getNodeType(nodeId);
|
|
826
|
+
if (nodeType === GCNodeType.DataStore) {
|
|
827
|
+
sweepPhaseStats.deletedDataStoreCount++;
|
|
828
|
+
}
|
|
829
|
+
else if (nodeType === GCNodeType.Blob) {
|
|
830
|
+
sweepPhaseStats.deletedAttachmentBlobCount++;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
// If sweep is enabled, the counts from the mark phase stats do not include nodes that have been
|
|
834
|
+
// deleted in previous runs. So, add the deleted node counts to life time stats.
|
|
835
|
+
sweepPhaseStats.lifetimeNodeCount += sweepPhaseStats.deletedNodeCount;
|
|
836
|
+
sweepPhaseStats.lifetimeDataStoreCount += sweepPhaseStats.deletedDataStoreCount;
|
|
837
|
+
sweepPhaseStats.lifetimeAttachmentBlobCount += sweepPhaseStats.deletedAttachmentBlobCount;
|
|
838
|
+
if (this.configs.shouldRunSweep) {
|
|
839
|
+
return sweepPhaseStats;
|
|
840
|
+
}
|
|
841
|
+
// If sweep is not enabled, the current sweep-ready node stats should be added to deleted stats since this
|
|
842
|
+
// is the final state the node will be in.
|
|
843
|
+
// If sweep is enabled, this will happen in the run after the GC op round trips back.
|
|
844
|
+
for (const nodeId of sweepReadyNodes) {
|
|
845
|
+
sweepPhaseStats.deletedNodeCount++;
|
|
846
|
+
const nodeType = this.runtime.getNodeType(nodeId);
|
|
847
|
+
if (nodeType === GCNodeType.DataStore) {
|
|
848
|
+
sweepPhaseStats.deletedDataStoreCount++;
|
|
849
|
+
}
|
|
850
|
+
else if (nodeType === GCNodeType.Blob) {
|
|
851
|
+
sweepPhaseStats.deletedAttachmentBlobCount++;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
return sweepPhaseStats;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
//# sourceMappingURL=garbageCollection.mjs.map
|