@fluidframework/container-runtime 2.0.0-dev.3.1.0.125672 → 2.0.0-dev.4.2.0.153917

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 (486) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +69 -0
  3. package/dist/blobManager.d.ts +29 -24
  4. package/dist/blobManager.d.ts.map +1 -1
  5. package/dist/blobManager.js +162 -92
  6. package/dist/blobManager.js.map +1 -1
  7. package/dist/containerRuntime.d.ts +74 -76
  8. package/dist/containerRuntime.d.ts.map +1 -1
  9. package/dist/containerRuntime.js +328 -264
  10. package/dist/containerRuntime.js.map +1 -1
  11. package/dist/dataStoreContext.d.ts +39 -13
  12. package/dist/dataStoreContext.d.ts.map +1 -1
  13. package/dist/dataStoreContext.js +112 -49
  14. package/dist/dataStoreContext.js.map +1 -1
  15. package/dist/dataStores.d.ts +28 -4
  16. package/dist/dataStores.d.ts.map +1 -1
  17. package/dist/dataStores.js +107 -41
  18. package/dist/dataStores.js.map +1 -1
  19. package/dist/deltaManagerSummarizerProxy.d.ts +19 -0
  20. package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -0
  21. package/dist/deltaManagerSummarizerProxy.js +40 -0
  22. package/dist/deltaManagerSummarizerProxy.js.map +1 -0
  23. package/dist/gc/garbageCollection.d.ts +204 -0
  24. package/dist/gc/garbageCollection.d.ts.map +1 -0
  25. package/dist/{garbageCollection.js → gc/garbageCollection.js} +190 -554
  26. package/dist/gc/garbageCollection.js.map +1 -0
  27. package/dist/gc/gcConfigs.d.ts +22 -0
  28. package/dist/gc/gcConfigs.d.ts.map +1 -0
  29. package/dist/gc/gcConfigs.js +143 -0
  30. package/dist/gc/gcConfigs.js.map +1 -0
  31. package/dist/gc/gcDefinitions.d.ts +320 -0
  32. package/dist/gc/gcDefinitions.d.ts.map +1 -0
  33. package/dist/gc/gcDefinitions.js +81 -0
  34. package/dist/gc/gcDefinitions.js.map +1 -0
  35. package/dist/gc/gcHelpers.d.ts +86 -0
  36. package/dist/gc/gcHelpers.d.ts.map +1 -0
  37. package/dist/gc/gcHelpers.js +268 -0
  38. package/dist/gc/gcHelpers.js.map +1 -0
  39. package/dist/gc/gcReferenceGraphAlgorithm.d.ts +16 -0
  40. package/dist/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -0
  41. package/dist/gc/gcReferenceGraphAlgorithm.js +49 -0
  42. package/dist/gc/gcReferenceGraphAlgorithm.js.map +1 -0
  43. package/dist/gc/gcSummaryDefinitions.d.ts +52 -0
  44. package/dist/gc/gcSummaryDefinitions.d.ts.map +1 -0
  45. package/dist/gc/gcSummaryDefinitions.js +7 -0
  46. package/dist/gc/gcSummaryDefinitions.js.map +1 -0
  47. package/dist/gc/gcSummaryStateTracker.d.ts +93 -0
  48. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -0
  49. package/dist/gc/gcSummaryStateTracker.js +239 -0
  50. package/dist/gc/gcSummaryStateTracker.js.map +1 -0
  51. package/dist/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
  52. package/dist/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +2 -2
  53. package/dist/gc/gcSweepReadyUsageDetection.js.map +1 -0
  54. package/dist/gc/gcUnreferencedStateTracker.d.ts +34 -0
  55. package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
  56. package/dist/gc/gcUnreferencedStateTracker.js +94 -0
  57. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -0
  58. package/dist/gc/index.d.ts +13 -0
  59. package/dist/gc/index.d.ts.map +1 -0
  60. package/dist/gc/index.js +50 -0
  61. package/dist/gc/index.js.map +1 -0
  62. package/dist/index.d.ts +3 -7
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +5 -9
  65. package/dist/index.js.map +1 -1
  66. package/dist/opLifecycle/batchManager.d.ts +11 -13
  67. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  68. package/dist/opLifecycle/batchManager.js +26 -38
  69. package/dist/opLifecycle/batchManager.js.map +1 -1
  70. package/dist/opLifecycle/definitions.d.ts +4 -0
  71. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  72. package/dist/opLifecycle/definitions.js.map +1 -1
  73. package/dist/opLifecycle/index.d.ts +2 -1
  74. package/dist/opLifecycle/index.d.ts.map +1 -1
  75. package/dist/opLifecycle/index.js +4 -1
  76. package/dist/opLifecycle/index.js.map +1 -1
  77. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  78. package/dist/opLifecycle/opCompressor.js +25 -10
  79. package/dist/opLifecycle/opCompressor.js.map +1 -1
  80. package/dist/opLifecycle/opDecompressor.d.ts +4 -0
  81. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  82. package/dist/opLifecycle/opDecompressor.js +43 -4
  83. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  84. package/dist/opLifecycle/opGroupingManager.d.ts +14 -0
  85. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -0
  86. package/dist/opLifecycle/opGroupingManager.js +56 -0
  87. package/dist/opLifecycle/opGroupingManager.js.map +1 -0
  88. package/dist/opLifecycle/opSplitter.d.ts +16 -4
  89. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  90. package/dist/opLifecycle/opSplitter.js +39 -15
  91. package/dist/opLifecycle/opSplitter.js.map +1 -1
  92. package/dist/opLifecycle/outbox.d.ts +21 -3
  93. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  94. package/dist/opLifecycle/outbox.js +90 -51
  95. package/dist/opLifecycle/outbox.js.map +1 -1
  96. package/dist/opLifecycle/remoteMessageProcessor.d.ts +4 -2
  97. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  98. package/dist/opLifecycle/remoteMessageProcessor.js +30 -20
  99. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  100. package/dist/packageVersion.d.ts +1 -1
  101. package/dist/packageVersion.js +1 -1
  102. package/dist/packageVersion.js.map +1 -1
  103. package/dist/pendingStateManager.d.ts +3 -3
  104. package/dist/pendingStateManager.d.ts.map +1 -1
  105. package/dist/pendingStateManager.js +20 -21
  106. package/dist/pendingStateManager.js.map +1 -1
  107. package/dist/storageServiceWithAttachBlobs.d.ts +17 -0
  108. package/dist/storageServiceWithAttachBlobs.d.ts.map +1 -0
  109. package/dist/storageServiceWithAttachBlobs.js +32 -0
  110. package/dist/storageServiceWithAttachBlobs.js.map +1 -0
  111. package/dist/summary/index.d.ts +17 -0
  112. package/dist/summary/index.d.ts.map +1 -0
  113. package/dist/summary/index.js +48 -0
  114. package/dist/summary/index.js.map +1 -0
  115. package/dist/summary/orderedClientElection.d.ts.map +1 -0
  116. package/dist/summary/orderedClientElection.js.map +1 -0
  117. package/dist/{runWhileConnectedCoordinator.d.ts → summary/runWhileConnectedCoordinator.d.ts} +3 -2
  118. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
  119. package/dist/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +5 -4
  120. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -0
  121. package/{lib → dist/summary}/runningSummarizer.d.ts +23 -20
  122. package/dist/summary/runningSummarizer.d.ts.map +1 -0
  123. package/dist/{runningSummarizer.js → summary/runningSummarizer.js} +191 -74
  124. package/dist/summary/runningSummarizer.js.map +1 -0
  125. package/dist/{summarizer.d.ts → summary/summarizer.d.ts} +4 -9
  126. package/dist/summary/summarizer.d.ts.map +1 -0
  127. package/dist/{summarizer.js → summary/summarizer.js} +10 -79
  128. package/dist/summary/summarizer.js.map +1 -0
  129. package/dist/summary/summarizerClientElection.d.ts.map +1 -0
  130. package/dist/summary/summarizerClientElection.js.map +1 -0
  131. package/dist/{summarizerHeuristics.d.ts → summary/summarizerHeuristics.d.ts} +2 -1
  132. package/dist/summary/summarizerHeuristics.d.ts.map +1 -0
  133. package/dist/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +6 -3
  134. package/dist/summary/summarizerHeuristics.js.map +1 -0
  135. package/dist/summary/summarizerNode/index.d.ts +8 -0
  136. package/dist/summary/summarizerNode/index.d.ts.map +1 -0
  137. package/dist/summary/summarizerNode/index.js +12 -0
  138. package/dist/summary/summarizerNode/index.js.map +1 -0
  139. package/dist/summary/summarizerNode/summarizerNode.d.ts +149 -0
  140. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -0
  141. package/dist/summary/summarizerNode/summarizerNode.js +531 -0
  142. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -0
  143. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +125 -0
  144. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -0
  145. package/dist/summary/summarizerNode/summarizerNodeUtils.js +132 -0
  146. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -0
  147. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +148 -0
  148. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -0
  149. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +424 -0
  150. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -0
  151. package/{lib → dist/summary}/summarizerTypes.d.ts +21 -19
  152. package/dist/summary/summarizerTypes.d.ts.map +1 -0
  153. package/dist/{summarizerTypes.js → summary/summarizerTypes.js} +0 -5
  154. package/dist/summary/summarizerTypes.js.map +1 -0
  155. package/dist/summary/summaryCollection.d.ts.map +1 -0
  156. package/dist/summary/summaryCollection.js.map +1 -0
  157. package/{lib → dist/summary}/summaryFormat.d.ts +3 -21
  158. package/dist/summary/summaryFormat.d.ts.map +1 -0
  159. package/dist/{summaryFormat.js → summary/summaryFormat.js} +1 -10
  160. package/dist/summary/summaryFormat.js.map +1 -0
  161. package/{lib → dist/summary}/summaryGenerator.d.ts +28 -2
  162. package/dist/summary/summaryGenerator.d.ts.map +1 -0
  163. package/dist/{summaryGenerator.js → summary/summaryGenerator.js} +23 -20
  164. package/dist/summary/summaryGenerator.js.map +1 -0
  165. package/dist/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
  166. package/dist/summary/summaryManager.d.ts.map +1 -0
  167. package/dist/summary/summaryManager.js.map +1 -0
  168. package/lib/blobManager.d.ts +29 -24
  169. package/lib/blobManager.d.ts.map +1 -1
  170. package/lib/blobManager.js +159 -89
  171. package/lib/blobManager.js.map +1 -1
  172. package/lib/containerRuntime.d.ts +74 -76
  173. package/lib/containerRuntime.d.ts.map +1 -1
  174. package/lib/containerRuntime.js +301 -237
  175. package/lib/containerRuntime.js.map +1 -1
  176. package/lib/dataStoreContext.d.ts +39 -13
  177. package/lib/dataStoreContext.d.ts.map +1 -1
  178. package/lib/dataStoreContext.js +101 -38
  179. package/lib/dataStoreContext.js.map +1 -1
  180. package/lib/dataStores.d.ts +28 -4
  181. package/lib/dataStores.d.ts.map +1 -1
  182. package/lib/dataStores.js +100 -34
  183. package/lib/dataStores.js.map +1 -1
  184. package/lib/deltaManagerSummarizerProxy.d.ts +19 -0
  185. package/lib/deltaManagerSummarizerProxy.d.ts.map +1 -0
  186. package/lib/deltaManagerSummarizerProxy.js +36 -0
  187. package/lib/deltaManagerSummarizerProxy.js.map +1 -0
  188. package/lib/gc/garbageCollection.d.ts +204 -0
  189. package/lib/gc/garbageCollection.d.ts.map +1 -0
  190. package/lib/{garbageCollection.js → gc/garbageCollection.js} +172 -535
  191. package/lib/gc/garbageCollection.js.map +1 -0
  192. package/lib/gc/gcConfigs.d.ts +22 -0
  193. package/lib/gc/gcConfigs.d.ts.map +1 -0
  194. package/lib/gc/gcConfigs.js +139 -0
  195. package/lib/gc/gcConfigs.js.map +1 -0
  196. package/lib/gc/gcDefinitions.d.ts +320 -0
  197. package/lib/gc/gcDefinitions.d.ts.map +1 -0
  198. package/lib/gc/gcDefinitions.js +78 -0
  199. package/lib/gc/gcDefinitions.js.map +1 -0
  200. package/lib/gc/gcHelpers.d.ts +86 -0
  201. package/lib/gc/gcHelpers.d.ts.map +1 -0
  202. package/lib/gc/gcHelpers.js +254 -0
  203. package/lib/gc/gcHelpers.js.map +1 -0
  204. package/lib/gc/gcReferenceGraphAlgorithm.d.ts +16 -0
  205. package/lib/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -0
  206. package/lib/gc/gcReferenceGraphAlgorithm.js +45 -0
  207. package/lib/gc/gcReferenceGraphAlgorithm.js.map +1 -0
  208. package/lib/gc/gcSummaryDefinitions.d.ts +52 -0
  209. package/lib/gc/gcSummaryDefinitions.d.ts.map +1 -0
  210. package/lib/gc/gcSummaryDefinitions.js +6 -0
  211. package/lib/gc/gcSummaryDefinitions.js.map +1 -0
  212. package/lib/gc/gcSummaryStateTracker.d.ts +93 -0
  213. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -0
  214. package/lib/gc/gcSummaryStateTracker.js +235 -0
  215. package/lib/gc/gcSummaryStateTracker.js.map +1 -0
  216. package/lib/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
  217. package/lib/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +1 -1
  218. package/lib/gc/gcSweepReadyUsageDetection.js.map +1 -0
  219. package/lib/gc/gcUnreferencedStateTracker.d.ts +34 -0
  220. package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
  221. package/lib/gc/gcUnreferencedStateTracker.js +90 -0
  222. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -0
  223. package/lib/gc/index.d.ts +13 -0
  224. package/lib/gc/index.d.ts.map +1 -0
  225. package/lib/gc/index.js +12 -0
  226. package/lib/gc/index.js.map +1 -0
  227. package/lib/index.d.ts +3 -7
  228. package/lib/index.d.ts.map +1 -1
  229. package/lib/index.js +1 -4
  230. package/lib/index.js.map +1 -1
  231. package/lib/opLifecycle/batchManager.d.ts +11 -13
  232. package/lib/opLifecycle/batchManager.d.ts.map +1 -1
  233. package/lib/opLifecycle/batchManager.js +24 -37
  234. package/lib/opLifecycle/batchManager.js.map +1 -1
  235. package/lib/opLifecycle/definitions.d.ts +4 -0
  236. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  237. package/lib/opLifecycle/definitions.js.map +1 -1
  238. package/lib/opLifecycle/index.d.ts +2 -1
  239. package/lib/opLifecycle/index.d.ts.map +1 -1
  240. package/lib/opLifecycle/index.js +2 -1
  241. package/lib/opLifecycle/index.js.map +1 -1
  242. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  243. package/lib/opLifecycle/opCompressor.js +26 -11
  244. package/lib/opLifecycle/opCompressor.js.map +1 -1
  245. package/lib/opLifecycle/opDecompressor.d.ts +4 -0
  246. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  247. package/lib/opLifecycle/opDecompressor.js +43 -4
  248. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  249. package/lib/opLifecycle/opGroupingManager.d.ts +14 -0
  250. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -0
  251. package/lib/opLifecycle/opGroupingManager.js +52 -0
  252. package/lib/opLifecycle/opGroupingManager.js.map +1 -0
  253. package/lib/opLifecycle/opSplitter.d.ts +16 -4
  254. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  255. package/lib/opLifecycle/opSplitter.js +39 -15
  256. package/lib/opLifecycle/opSplitter.js.map +1 -1
  257. package/lib/opLifecycle/outbox.d.ts +21 -3
  258. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  259. package/lib/opLifecycle/outbox.js +92 -53
  260. package/lib/opLifecycle/outbox.js.map +1 -1
  261. package/lib/opLifecycle/remoteMessageProcessor.d.ts +4 -2
  262. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  263. package/lib/opLifecycle/remoteMessageProcessor.js +30 -20
  264. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  265. package/lib/packageVersion.d.ts +1 -1
  266. package/lib/packageVersion.js +1 -1
  267. package/lib/packageVersion.js.map +1 -1
  268. package/lib/pendingStateManager.d.ts +3 -3
  269. package/lib/pendingStateManager.d.ts.map +1 -1
  270. package/lib/pendingStateManager.js +20 -21
  271. package/lib/pendingStateManager.js.map +1 -1
  272. package/lib/storageServiceWithAttachBlobs.d.ts +17 -0
  273. package/lib/storageServiceWithAttachBlobs.d.ts.map +1 -0
  274. package/lib/storageServiceWithAttachBlobs.js +28 -0
  275. package/lib/storageServiceWithAttachBlobs.js.map +1 -0
  276. package/lib/summary/index.d.ts +17 -0
  277. package/lib/summary/index.d.ts.map +1 -0
  278. package/lib/summary/index.js +16 -0
  279. package/lib/summary/index.js.map +1 -0
  280. package/lib/summary/orderedClientElection.d.ts.map +1 -0
  281. package/lib/summary/orderedClientElection.js.map +1 -0
  282. package/lib/{runWhileConnectedCoordinator.d.ts → summary/runWhileConnectedCoordinator.d.ts} +3 -2
  283. package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
  284. package/lib/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +5 -4
  285. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -0
  286. package/{dist → lib/summary}/runningSummarizer.d.ts +23 -20
  287. package/lib/summary/runningSummarizer.d.ts.map +1 -0
  288. package/lib/{runningSummarizer.js → summary/runningSummarizer.js} +192 -75
  289. package/lib/summary/runningSummarizer.js.map +1 -0
  290. package/lib/{summarizer.d.ts → summary/summarizer.d.ts} +4 -9
  291. package/lib/summary/summarizer.d.ts.map +1 -0
  292. package/lib/{summarizer.js → summary/summarizer.js} +12 -81
  293. package/lib/summary/summarizer.js.map +1 -0
  294. package/lib/summary/summarizerClientElection.d.ts.map +1 -0
  295. package/lib/summary/summarizerClientElection.js.map +1 -0
  296. package/lib/{summarizerHeuristics.d.ts → summary/summarizerHeuristics.d.ts} +2 -1
  297. package/lib/summary/summarizerHeuristics.d.ts.map +1 -0
  298. package/lib/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +6 -3
  299. package/lib/summary/summarizerHeuristics.js.map +1 -0
  300. package/lib/summary/summarizerNode/index.d.ts +8 -0
  301. package/lib/summary/summarizerNode/index.d.ts.map +1 -0
  302. package/lib/summary/summarizerNode/index.js +7 -0
  303. package/lib/summary/summarizerNode/index.js.map +1 -0
  304. package/lib/summary/summarizerNode/summarizerNode.d.ts +149 -0
  305. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -0
  306. package/lib/summary/summarizerNode/summarizerNode.js +526 -0
  307. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -0
  308. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +125 -0
  309. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -0
  310. package/lib/summary/summarizerNode/summarizerNodeUtils.js +125 -0
  311. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -0
  312. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +148 -0
  313. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -0
  314. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +419 -0
  315. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -0
  316. package/{dist → lib/summary}/summarizerTypes.d.ts +21 -19
  317. package/lib/summary/summarizerTypes.d.ts.map +1 -0
  318. package/lib/summary/summarizerTypes.js +6 -0
  319. package/lib/summary/summarizerTypes.js.map +1 -0
  320. package/lib/summary/summaryCollection.d.ts.map +1 -0
  321. package/lib/summary/summaryCollection.js.map +1 -0
  322. package/{dist → lib/summary}/summaryFormat.d.ts +3 -21
  323. package/lib/summary/summaryFormat.d.ts.map +1 -0
  324. package/lib/{summaryFormat.js → summary/summaryFormat.js} +0 -8
  325. package/lib/summary/summaryFormat.js.map +1 -0
  326. package/{dist → lib/summary}/summaryGenerator.d.ts +28 -2
  327. package/lib/summary/summaryGenerator.d.ts.map +1 -0
  328. package/lib/{summaryGenerator.js → summary/summaryGenerator.js} +21 -19
  329. package/lib/summary/summaryGenerator.js.map +1 -0
  330. package/lib/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
  331. package/lib/summary/summaryManager.d.ts.map +1 -0
  332. package/lib/summary/summaryManager.js.map +1 -0
  333. package/package.json +66 -60
  334. package/src/blobManager.ts +196 -110
  335. package/src/containerRuntime.ts +491 -391
  336. package/src/dataStoreContext.ts +140 -49
  337. package/src/dataStores.ts +139 -41
  338. package/src/deltaManagerSummarizerProxy.ts +46 -0
  339. package/{garbageCollection.md → src/gc/garbageCollection.md} +2 -2
  340. package/src/{garbageCollection.ts → gc/garbageCollection.ts} +245 -890
  341. package/src/gc/gcConfigs.ts +193 -0
  342. package/src/gc/gcDefinitions.ts +387 -0
  343. package/src/gc/gcHelpers.ts +335 -0
  344. package/src/gc/gcReferenceGraphAlgorithm.ts +52 -0
  345. package/src/gc/gcSummaryDefinitions.ts +54 -0
  346. package/src/gc/gcSummaryStateTracker.ts +329 -0
  347. package/src/{gcSweepReadyUsageDetection.ts → gc/gcSweepReadyUsageDetection.ts} +1 -1
  348. package/src/gc/gcUnreferencedStateTracker.ts +114 -0
  349. package/src/gc/index.ts +65 -0
  350. package/src/index.ts +10 -22
  351. package/src/opLifecycle/README.md +263 -0
  352. package/src/opLifecycle/batchManager.ts +26 -55
  353. package/src/opLifecycle/definitions.ts +4 -0
  354. package/src/opLifecycle/index.ts +2 -1
  355. package/src/opLifecycle/opCompressor.ts +32 -12
  356. package/src/opLifecycle/opDecompressor.ts +50 -5
  357. package/src/opLifecycle/opGroupingManager.ts +78 -0
  358. package/src/opLifecycle/opSplitter.ts +56 -17
  359. package/src/opLifecycle/outbox.ts +126 -62
  360. package/src/opLifecycle/remoteMessageProcessor.ts +38 -22
  361. package/src/packageVersion.ts +1 -1
  362. package/src/pendingStateManager.ts +34 -27
  363. package/src/storageServiceWithAttachBlobs.ts +38 -0
  364. package/src/summary/index.ts +105 -0
  365. package/src/{runWhileConnectedCoordinator.ts → summary/runWhileConnectedCoordinator.ts} +7 -7
  366. package/src/{runningSummarizer.ts → summary/runningSummarizer.ts} +318 -156
  367. package/src/{summarizer.ts → summary/summarizer.ts} +12 -105
  368. package/src/{summarizerHeuristics.ts → summary/summarizerHeuristics.ts} +13 -4
  369. package/src/summary/summarizerNode/index.ts +12 -0
  370. package/src/summary/summarizerNode/summarizerNode.ts +766 -0
  371. package/src/summary/summarizerNode/summarizerNodeUtils.ts +214 -0
  372. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +644 -0
  373. package/src/{summarizerTypes.ts → summary/summarizerTypes.ts} +28 -25
  374. package/src/{summaryFormat.ts → summary/summaryFormat.ts} +3 -29
  375. package/src/{summaryGenerator.ts → summary/summaryGenerator.ts} +34 -27
  376. package/src/{summaryManager.ts → summary/summaryManager.ts} +1 -1
  377. package/dist/garbageCollection.d.ts +0 -411
  378. package/dist/garbageCollection.d.ts.map +0 -1
  379. package/dist/garbageCollection.js.map +0 -1
  380. package/dist/garbageCollectionConstants.d.ts +0 -23
  381. package/dist/garbageCollectionConstants.d.ts.map +0 -1
  382. package/dist/garbageCollectionConstants.js +0 -36
  383. package/dist/garbageCollectionConstants.js.map +0 -1
  384. package/dist/garbageCollectionHelpers.d.ts +0 -15
  385. package/dist/garbageCollectionHelpers.d.ts.map +0 -1
  386. package/dist/garbageCollectionHelpers.js +0 -27
  387. package/dist/garbageCollectionHelpers.js.map +0 -1
  388. package/dist/gcSweepReadyUsageDetection.d.ts.map +0 -1
  389. package/dist/gcSweepReadyUsageDetection.js.map +0 -1
  390. package/dist/orderedClientElection.d.ts.map +0 -1
  391. package/dist/orderedClientElection.js.map +0 -1
  392. package/dist/runWhileConnectedCoordinator.d.ts.map +0 -1
  393. package/dist/runWhileConnectedCoordinator.js.map +0 -1
  394. package/dist/runningSummarizer.d.ts.map +0 -1
  395. package/dist/runningSummarizer.js.map +0 -1
  396. package/dist/serializedSnapshotStorage.d.ts +0 -58
  397. package/dist/serializedSnapshotStorage.d.ts.map +0 -1
  398. package/dist/serializedSnapshotStorage.js +0 -110
  399. package/dist/serializedSnapshotStorage.js.map +0 -1
  400. package/dist/summarizer.d.ts.map +0 -1
  401. package/dist/summarizer.js.map +0 -1
  402. package/dist/summarizerClientElection.d.ts.map +0 -1
  403. package/dist/summarizerClientElection.js.map +0 -1
  404. package/dist/summarizerHandle.d.ts +0 -12
  405. package/dist/summarizerHandle.d.ts.map +0 -1
  406. package/dist/summarizerHandle.js +0 -22
  407. package/dist/summarizerHandle.js.map +0 -1
  408. package/dist/summarizerHeuristics.d.ts.map +0 -1
  409. package/dist/summarizerHeuristics.js.map +0 -1
  410. package/dist/summarizerTypes.d.ts.map +0 -1
  411. package/dist/summarizerTypes.js.map +0 -1
  412. package/dist/summaryCollection.d.ts.map +0 -1
  413. package/dist/summaryCollection.js.map +0 -1
  414. package/dist/summaryFormat.d.ts.map +0 -1
  415. package/dist/summaryFormat.js.map +0 -1
  416. package/dist/summaryGenerator.d.ts.map +0 -1
  417. package/dist/summaryGenerator.js.map +0 -1
  418. package/dist/summaryManager.d.ts.map +0 -1
  419. package/dist/summaryManager.js.map +0 -1
  420. package/lib/garbageCollection.d.ts +0 -411
  421. package/lib/garbageCollection.d.ts.map +0 -1
  422. package/lib/garbageCollection.js.map +0 -1
  423. package/lib/garbageCollectionConstants.d.ts +0 -23
  424. package/lib/garbageCollectionConstants.d.ts.map +0 -1
  425. package/lib/garbageCollectionConstants.js +0 -33
  426. package/lib/garbageCollectionConstants.js.map +0 -1
  427. package/lib/garbageCollectionHelpers.d.ts +0 -15
  428. package/lib/garbageCollectionHelpers.d.ts.map +0 -1
  429. package/lib/garbageCollectionHelpers.js +0 -23
  430. package/lib/garbageCollectionHelpers.js.map +0 -1
  431. package/lib/gcSweepReadyUsageDetection.d.ts.map +0 -1
  432. package/lib/gcSweepReadyUsageDetection.js.map +0 -1
  433. package/lib/orderedClientElection.d.ts.map +0 -1
  434. package/lib/orderedClientElection.js.map +0 -1
  435. package/lib/runWhileConnectedCoordinator.d.ts.map +0 -1
  436. package/lib/runWhileConnectedCoordinator.js.map +0 -1
  437. package/lib/runningSummarizer.d.ts.map +0 -1
  438. package/lib/runningSummarizer.js.map +0 -1
  439. package/lib/serializedSnapshotStorage.d.ts +0 -58
  440. package/lib/serializedSnapshotStorage.d.ts.map +0 -1
  441. package/lib/serializedSnapshotStorage.js +0 -106
  442. package/lib/serializedSnapshotStorage.js.map +0 -1
  443. package/lib/summarizer.d.ts.map +0 -1
  444. package/lib/summarizer.js.map +0 -1
  445. package/lib/summarizerClientElection.d.ts.map +0 -1
  446. package/lib/summarizerClientElection.js.map +0 -1
  447. package/lib/summarizerHandle.d.ts +0 -12
  448. package/lib/summarizerHandle.d.ts.map +0 -1
  449. package/lib/summarizerHandle.js +0 -18
  450. package/lib/summarizerHandle.js.map +0 -1
  451. package/lib/summarizerHeuristics.d.ts.map +0 -1
  452. package/lib/summarizerHeuristics.js.map +0 -1
  453. package/lib/summarizerTypes.d.ts.map +0 -1
  454. package/lib/summarizerTypes.js +0 -9
  455. package/lib/summarizerTypes.js.map +0 -1
  456. package/lib/summaryCollection.d.ts.map +0 -1
  457. package/lib/summaryCollection.js.map +0 -1
  458. package/lib/summaryFormat.d.ts.map +0 -1
  459. package/lib/summaryFormat.js.map +0 -1
  460. package/lib/summaryGenerator.d.ts.map +0 -1
  461. package/lib/summaryGenerator.js.map +0 -1
  462. package/lib/summaryManager.d.ts.map +0 -1
  463. package/lib/summaryManager.js.map +0 -1
  464. package/src/garbageCollectionConstants.ts +0 -38
  465. package/src/garbageCollectionHelpers.ts +0 -37
  466. package/src/serializedSnapshotStorage.ts +0 -151
  467. package/src/summarizerHandle.ts +0 -23
  468. /package/dist/{gcSweepReadyUsageDetection.d.ts → gc/gcSweepReadyUsageDetection.d.ts} +0 -0
  469. /package/dist/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
  470. /package/dist/{orderedClientElection.js → summary/orderedClientElection.js} +0 -0
  471. /package/dist/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +0 -0
  472. /package/dist/{summarizerClientElection.js → summary/summarizerClientElection.js} +0 -0
  473. /package/dist/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
  474. /package/dist/{summaryCollection.js → summary/summaryCollection.js} +0 -0
  475. /package/dist/{summaryManager.js → summary/summaryManager.js} +0 -0
  476. /package/lib/{gcSweepReadyUsageDetection.d.ts → gc/gcSweepReadyUsageDetection.d.ts} +0 -0
  477. /package/lib/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
  478. /package/lib/{orderedClientElection.js → summary/orderedClientElection.js} +0 -0
  479. /package/lib/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +0 -0
  480. /package/lib/{summarizerClientElection.js → summary/summarizerClientElection.js} +0 -0
  481. /package/lib/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
  482. /package/lib/{summaryCollection.js → summary/summaryCollection.js} +0 -0
  483. /package/lib/{summaryManager.js → summary/summaryManager.js} +0 -0
  484. /package/src/{orderedClientElection.ts → summary/orderedClientElection.ts} +0 -0
  485. /package/src/{summarizerClientElection.ts → summary/summarizerClientElection.ts} +0 -0
  486. /package/src/{summaryCollection.ts → summary/summaryCollection.ts} +0 -0
@@ -0,0 +1,193 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { UsageError } from "@fluidframework/container-utils";
7
+ import { MonitoringContext } from "@fluidframework/telemetry-utils";
8
+ import { IContainerRuntimeMetadata } from "../summary";
9
+ import {
10
+ currentGCVersion,
11
+ defaultInactiveTimeoutMs,
12
+ defaultSessionExpiryDurationMs,
13
+ disableTombstoneKey,
14
+ GCFeatureMatrix,
15
+ gcSweepGenerationOptionName,
16
+ gcTestModeKey,
17
+ gcTombstoneGenerationOptionName,
18
+ GCVersion,
19
+ gcVersionUpgradeToV3Key,
20
+ IGarbageCollectorConfigs,
21
+ IGCRuntimeOptions,
22
+ maxSnapshotCacheExpiryMs,
23
+ oneDayMs,
24
+ runGCKey,
25
+ runSessionExpiryKey,
26
+ runSweepKey,
27
+ stableGCVersion,
28
+ } from "./gcDefinitions";
29
+ import { getGCVersion, shouldAllowGcSweep } from "./gcHelpers";
30
+
31
+ /**
32
+ * Generates configurations for the Garbage Collector that it uses to determine what to run and how.
33
+ * @param mc - The monitoring context for reading configs from the config provider.
34
+ * @param createParams - The creation params:
35
+ * gcOptions - The garbage collector runtime options.
36
+ * metadata - The container runtime's createParams.metadata.
37
+ * existing - Whether the container is new or an existing one.
38
+ * @returns The garbage collector configurations.
39
+ */
40
+ export function generateGCConfigs(
41
+ mc: MonitoringContext,
42
+ createParams: {
43
+ gcOptions: IGCRuntimeOptions;
44
+ metadata: IContainerRuntimeMetadata | undefined;
45
+ existing: boolean;
46
+ },
47
+ ): IGarbageCollectorConfigs {
48
+ let gcEnabled: boolean;
49
+ let sessionExpiryTimeoutMs: number | undefined;
50
+ let sweepTimeoutMs: number | undefined;
51
+ let persistedGcFeatureMatrix: GCFeatureMatrix | undefined;
52
+ let gcVersionInBaseSnapshot: GCVersion | undefined;
53
+
54
+ /**
55
+ * The following GC state is enabled during container creation and cannot be changed throughout its lifetime:
56
+ * 1. Whether running GC mark phase is allowed or not.
57
+ * 2. Whether running GC sweep phase is allowed or not.
58
+ * 3. Whether GC session expiry is enabled or not.
59
+ * For existing containers, we get this information from the createParams.metadata blob of its summary.
60
+ */
61
+ if (createParams.existing) {
62
+ gcVersionInBaseSnapshot = getGCVersion(createParams.metadata);
63
+ // Existing documents which did not have createParams.metadata blob or had GC disabled have version as 0. For all
64
+ // other existing documents, GC is enabled.
65
+ gcEnabled = gcVersionInBaseSnapshot > 0;
66
+ sessionExpiryTimeoutMs = createParams.metadata?.sessionExpiryTimeoutMs;
67
+ sweepTimeoutMs =
68
+ createParams.metadata?.sweepTimeoutMs ?? computeSweepTimeout(sessionExpiryTimeoutMs); // Backfill old documents that didn't persist this
69
+ persistedGcFeatureMatrix = createParams.metadata?.gcFeatureMatrix;
70
+ } else {
71
+ const tombstoneGeneration = createParams.gcOptions[gcTombstoneGenerationOptionName];
72
+ const sweepGeneration = createParams.gcOptions[gcSweepGenerationOptionName];
73
+
74
+ // Sweep should not be enabled (via sweepGeneration value) without enabling GC mark phase.
75
+ if (sweepGeneration !== undefined && createParams.gcOptions.gcAllowed === false) {
76
+ throw new UsageError("GC sweep phase cannot be enabled without enabling GC mark phase");
77
+ }
78
+
79
+ // This Test Override only applies for new containers
80
+ const testOverrideSweepTimeoutMs = mc.config.getNumber(
81
+ "Fluid.GarbageCollection.TestOverride.SweepTimeoutMs",
82
+ );
83
+
84
+ // For new documents, GC is enabled by default. It can be explicitly disabled by setting the gcAllowed
85
+ // flag in GC options to false.
86
+ gcEnabled = createParams.gcOptions.gcAllowed !== false;
87
+
88
+ // Set the Session Expiry if GC is enabled and session expiry flag isn't explicitly set to false.
89
+ if (gcEnabled && mc.config.getBoolean(runSessionExpiryKey) !== false) {
90
+ sessionExpiryTimeoutMs =
91
+ createParams.gcOptions.sessionExpiryTimeoutMs ?? defaultSessionExpiryDurationMs;
92
+ }
93
+ sweepTimeoutMs = testOverrideSweepTimeoutMs ?? computeSweepTimeout(sessionExpiryTimeoutMs);
94
+
95
+ if (tombstoneGeneration !== undefined || sweepGeneration !== undefined) {
96
+ persistedGcFeatureMatrix = {
97
+ tombstoneGeneration,
98
+ sweepGeneration,
99
+ };
100
+ }
101
+ }
102
+
103
+ // Is sweepEnabled for this document?
104
+ const sweepEnabled = shouldAllowGcSweep(
105
+ persistedGcFeatureMatrix ?? {} /* persistedGenerations */,
106
+ createParams.gcOptions[gcSweepGenerationOptionName] /* currentGeneration */,
107
+ );
108
+
109
+ /**
110
+ * Whether GC should run or not. The following conditions have to be met to run sweep:
111
+ *
112
+ * 1. GC should be enabled for this container.
113
+ *
114
+ * 2. GC should not be disabled via disableGC GC option.
115
+ *
116
+ * These conditions can be overridden via runGCKey feature flag.
117
+ */
118
+ const shouldRunGC =
119
+ mc.config.getBoolean(runGCKey) ??
120
+ // GC must be enabled for the document.
121
+ (gcEnabled &&
122
+ // GC must not be disabled via GC options.
123
+ !createParams.gcOptions.disableGC);
124
+
125
+ /**
126
+ * Whether sweep should run or not. The following conditions have to be met to run sweep:
127
+ *
128
+ * 1. Overall GC or mark phase must be enabled (this.configs.shouldRunGC).
129
+ * 2. Sweep timeout should be available. Without this, we wouldn't know when an object should be deleted.
130
+ * 3. The driver must implement the policy limiting the age of snapshots used for loading. Otherwise
131
+ * the Sweep Timeout calculation is not valid. We use the persisted value to ensure consistency over time.
132
+ * 4. Sweep should be enabled for this container. This can be overridden via runSweep
133
+ * feature flag.
134
+ */
135
+ const shouldRunSweep =
136
+ shouldRunGC &&
137
+ sweepTimeoutMs !== undefined &&
138
+ (mc.config.getBoolean(runSweepKey) ?? sweepEnabled);
139
+
140
+ // Override inactive timeout if test config or gc options to override it is set.
141
+ const inactiveTimeoutMs =
142
+ mc.config.getNumber("Fluid.GarbageCollection.TestOverride.InactiveTimeoutMs") ??
143
+ createParams.gcOptions.inactiveTimeoutMs ??
144
+ defaultInactiveTimeoutMs;
145
+
146
+ // Inactive timeout must be greater than sweep timeout since a node goes from active -> inactive -> sweep ready.
147
+ if (sweepTimeoutMs !== undefined && inactiveTimeoutMs > sweepTimeoutMs) {
148
+ throw new UsageError("inactive timeout should not be greater than the sweep timeout");
149
+ }
150
+
151
+ // Whether we are running in test mode. In this mode, unreferenced nodes are immediately deleted.
152
+ const testMode =
153
+ mc.config.getBoolean(gcTestModeKey) ?? createParams.gcOptions.runGCInTestMode === true;
154
+ // Whether we are running in tombstone mode. This is enabled by default if sweep won't run. It can be disabled
155
+ // via feature flags.
156
+ const tombstoneMode = !shouldRunSweep && mc.config.getBoolean(disableTombstoneKey) !== true;
157
+ const runFullGC = createParams.gcOptions.runFullGC;
158
+
159
+ // If version upgrade is not enabled, fall back to the stable GC version.
160
+ const gcVersionInEffect =
161
+ mc.config.getBoolean(gcVersionUpgradeToV3Key) === false
162
+ ? stableGCVersion
163
+ : currentGCVersion;
164
+
165
+ return {
166
+ gcEnabled,
167
+ sweepEnabled,
168
+ shouldRunGC,
169
+ shouldRunSweep,
170
+ runFullGC,
171
+ testMode,
172
+ tombstoneMode,
173
+ sessionExpiryTimeoutMs,
174
+ sweepTimeoutMs,
175
+ inactiveTimeoutMs,
176
+ persistedGcFeatureMatrix,
177
+ gcVersionInBaseSnapshot,
178
+ gcVersionInEffect,
179
+ };
180
+ }
181
+
182
+ /**
183
+ * Sweep timeout is the time after which unreferenced content can be swept.
184
+ * Sweep timeout = session expiry timeout + snapshot cache expiry timeout + one day buffer.
185
+ *
186
+ * The snapshot cache expiry timeout cannot be known precisely but the upper bound is 5 days.
187
+ * The buffer is added to account for any clock skew or other edge cases.
188
+ * We use server timestamps throughout so the skew should be minimal but make it 1 day to be safe.
189
+ */
190
+ function computeSweepTimeout(sessionExpiryTimeoutMs: number | undefined): number | undefined {
191
+ const bufferMs = oneDayMs;
192
+ return sessionExpiryTimeoutMs && sessionExpiryTimeoutMs + maxSnapshotCacheExpiryMs + bufferMs;
193
+ }
@@ -0,0 +1,387 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { ICriticalContainerError } from "@fluidframework/container-definitions";
7
+ import { IRequestHeader } from "@fluidframework/core-interfaces";
8
+ import { ISnapshotTree } from "@fluidframework/protocol-definitions";
9
+ import {
10
+ IGarbageCollectionData,
11
+ IGarbageCollectionDetailsBase,
12
+ ISummarizeResult,
13
+ ITelemetryContext,
14
+ } from "@fluidframework/runtime-definitions";
15
+ import { ReadAndParseBlob } from "@fluidframework/runtime-utils";
16
+ import { ITelemetryLogger } from "@fluidframework/common-definitions";
17
+ import {
18
+ IContainerRuntimeMetadata,
19
+ ICreateContainerMetadata,
20
+ RefreshSummaryResult,
21
+ } from "../summary";
22
+
23
+ export type GCVersion = number;
24
+
25
+ /** The stable version of garbage collection in production. */
26
+ export const stableGCVersion: GCVersion = 1;
27
+ /** The current version of garbage collection. */
28
+ export const currentGCVersion: GCVersion = 3;
29
+
30
+ /**
31
+ * This undocumented GC Option (on ContainerRuntime Options) allows an app to disable enforcing GC on old documents by incrementing this value
32
+ *
33
+ * If unset, GC Tombstone phase will operate as otherwise configured
34
+ * Otherwise, only enforce GC Tombstone if the passed in value matches the persisted value
35
+ */
36
+ export const gcTombstoneGenerationOptionName = "gcTombstoneGeneration";
37
+ /**
38
+ * This GC Option (on ContainerRuntime Options) allows an app to disable GC Sweep on old documents by incrementing this value.
39
+ *
40
+ * If unset altogether, Sweep will be disabled.
41
+ * If 0 is passed in, Sweep will be enabled for any document with gcSweepGeneration OR gcTombstoneGeneration as 0.
42
+ * If any other number is passed in, Sweep will be enabled only for documents with the same value persisted.
43
+ */
44
+ export const gcSweepGenerationOptionName = "gcSweepGeneration";
45
+
46
+ // Feature gate key to turn GC on / off.
47
+ export const runGCKey = "Fluid.GarbageCollection.RunGC";
48
+ // Feature gate key to turn GC sweep on / off.
49
+ export const runSweepKey = "Fluid.GarbageCollection.RunSweep";
50
+ // Feature gate key to turn GC test mode on / off.
51
+ export const gcTestModeKey = "Fluid.GarbageCollection.GCTestMode";
52
+ // Feature gate key to expire a session after a set period of time.
53
+ export const runSessionExpiryKey = "Fluid.GarbageCollection.RunSessionExpiry";
54
+ // Feature gate key to turn GC sweep log off.
55
+ export const disableSweepLogKey = "Fluid.GarbageCollection.DisableSweepLog";
56
+ // Feature gate key to disable the tombstone feature, i.e., tombstone information is not read / written into summary.
57
+ export const disableTombstoneKey = "Fluid.GarbageCollection.DisableTombstone";
58
+ // Feature gate to enable throwing an error when tombstone object is loaded (requested).
59
+ export const throwOnTombstoneLoadKey = "Fluid.GarbageCollection.ThrowOnTombstoneLoad";
60
+ // Feature gate to enable throwing an error when tombstone object is used (e.g. outgoing or incoming ops).
61
+ export const throwOnTombstoneUsageKey = "Fluid.GarbageCollection.ThrowOnTombstoneUsage";
62
+ // Feature gate to enable GC version upgrade.
63
+ export const gcVersionUpgradeToV3Key = "Fluid.GarbageCollection.GCVersionUpgradeToV3";
64
+ // Feature gate to enable GC sweep for datastores.
65
+ // TODO: Remove Test from the flag when we are confident to turn on sweep
66
+ export const sweepDatastoresKey = "Fluid.GarbageCollection.Test.SweepDataStores";
67
+ // Feature gate to enable GC sweep for attachment blobs.
68
+ export const sweepAttachmentBlobsKey = "Fluid.GarbageCollection.Test.SweepAttachmentBlobs";
69
+
70
+ // One day in milliseconds.
71
+ export const oneDayMs = 1 * 24 * 60 * 60 * 1000;
72
+
73
+ /**
74
+ * The maximum snapshot cache expiry in the driver. This is used to calculate the sweep timeout.
75
+ * Sweep timeout = session expiry timeout + snapshot cache expiry timeout + a buffer.
76
+ * The snapshot cache expiry timeout cannot be known precisely but the upper bound is 5 days, i.e., any snapshot
77
+ * in cache will be invalidated before 5 days.
78
+ */
79
+ export const maxSnapshotCacheExpiryMs = 5 * oneDayMs;
80
+
81
+ export const defaultInactiveTimeoutMs = 7 * oneDayMs; // 7 days
82
+ export const defaultSessionExpiryDurationMs = 30 * oneDayMs; // 30 days
83
+
84
+ /** @see IGCMetadata.gcFeatureMatrix */
85
+ export interface GCFeatureMatrix {
86
+ /**
87
+ * The Tombstone Generation value in effect when this file was created.
88
+ * Gives a way for an app to disqualify old files from GC Tombstone enforcement.
89
+ * Provided via Container Runtime Options.
90
+ */
91
+ tombstoneGeneration?: number;
92
+ /**
93
+ * The Sweep Generation value in effect when this file was created.
94
+ * Gives a way for an app to disqualify old files from GC Sweep.
95
+ * Provided via Container Runtime Options.
96
+ */
97
+ sweepGeneration?: number;
98
+ }
99
+
100
+ export interface IGCMetadata {
101
+ /**
102
+ * The version of the GC code that was run to generate the GC data that is written in the summary.
103
+ * If the persisted value doesn't match the current value in the code, saved GC data will be discarded and regenerated from scratch.
104
+ * Also, used to determine whether GC is enabled for this container or not:
105
+ * - A value of 0 or undefined means GC is disabled.
106
+ * - A value greater than 0 means GC is enabled.
107
+ */
108
+ readonly gcFeature?: GCVersion;
109
+
110
+ /**
111
+ * A collection of different numerical "Generations" for different features,
112
+ * used to determine feature availability over time.
113
+ * This info may come from multiple sources (FF code, config service, app via Container Runtime Options),
114
+ * and pertains to aspects of the document that may be fixed for its lifetime.
115
+ *
116
+ * For each dimension, if the persisted value doesn't match the currently provided value,
117
+ * then this file does not support the corresponding feature as currently implemented.
118
+ *
119
+ * Guidance is that if no value is provided at runtime, it should result in the current default behavior.
120
+ */
121
+ readonly gcFeatureMatrix?: GCFeatureMatrix;
122
+ /**
123
+ * @deprecated - @see GCFeatureMatrix.sweepGeneration
124
+ *
125
+ * Tells whether the GC sweep phase is enabled for this container.
126
+ * - True means sweep phase is enabled.
127
+ * - False means sweep phase is disabled. If GC is disabled as per gcFeature, sweep is also disabled.
128
+ */
129
+ readonly sweepEnabled?: boolean;
130
+ /** If this is present, the session for this container will expire after this time and the container will close */
131
+ readonly sessionExpiryTimeoutMs?: number;
132
+ /** How long to wait after an object is unreferenced before deleting it via GC Sweep */
133
+ readonly sweepTimeoutMs?: number;
134
+ }
135
+
136
+ /** The statistics of the system state after a garbage collection run. */
137
+ export interface IGCStats {
138
+ /** The number of nodes in the container. */
139
+ nodeCount: number;
140
+ /** The number of data stores in the container. */
141
+ dataStoreCount: number;
142
+ /** The number of attachment blobs in the container. */
143
+ attachmentBlobCount: number;
144
+ /** The number of unreferenced nodes in the container. */
145
+ unrefNodeCount: number;
146
+ /** The number of unreferenced data stores in the container. */
147
+ unrefDataStoreCount: number;
148
+ /** The number of unreferenced attachment blobs in the container. */
149
+ unrefAttachmentBlobCount: number;
150
+ /** The number of nodes whose reference state updated since last GC run. */
151
+ updatedNodeCount: number;
152
+ /** The number of data stores whose reference state updated since last GC run. */
153
+ updatedDataStoreCount: number;
154
+ /** The number of attachment blobs whose reference state updated since last GC run. */
155
+ updatedAttachmentBlobCount: number;
156
+ }
157
+
158
+ /** The types of GC nodes in the GC reference graph. */
159
+ export const GCNodeType = {
160
+ // Nodes that are for data stores.
161
+ DataStore: "DataStore",
162
+ // Nodes that are within a data store. For example, DDS nodes.
163
+ SubDataStore: "SubDataStore",
164
+ // Nodes that are for attachment blobs, i.e., blobs uploaded via BlobManager.
165
+ Blob: "Blob",
166
+ // Nodes that are neither of the above. For example, root node.
167
+ Other: "Other",
168
+ };
169
+ export type GCNodeType = typeof GCNodeType[keyof typeof GCNodeType];
170
+
171
+ /**
172
+ * Defines the APIs for the runtime object to be passed to the garbage collector.
173
+ */
174
+ export interface IGarbageCollectionRuntime {
175
+ /** Before GC runs, called to notify the runtime to update any pending GC state. */
176
+ updateStateBeforeGC(): Promise<void>;
177
+ /** Returns the garbage collection data of the runtime. */
178
+ getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
179
+ /** After GC has run, called to notify the runtime of routes that are used in it. */
180
+ updateUsedRoutes(usedRoutes: string[]): void;
181
+ /** After GC has run, called to notify the runtime of routes that are unused in it. */
182
+ updateUnusedRoutes(unusedRoutes: string[]): void;
183
+ /**
184
+ * After GC has run and identified nodes that are sweep ready, called to delete the sweep ready nodes. The runtime
185
+ * should return the routes of nodes that were deleted.
186
+ * @param sweepReadyRoutes - The routes of nodes that are sweep ready and should be deleted.
187
+ */
188
+ deleteSweepReadyNodes(sweepReadyRoutes: string[]): string[];
189
+ /** Called to notify the runtime of routes that are tombstones. */
190
+ updateTombstonedRoutes(tombstoneRoutes: string[]): void;
191
+ /** Returns a referenced timestamp to be used to track unreferenced nodes. */
192
+ getCurrentReferenceTimestampMs(): number | undefined;
193
+ /** Returns the type of the GC node. */
194
+ getNodeType(nodePath: string): GCNodeType;
195
+ /** Called when the runtime should close because of an error. */
196
+ closeFn: (error?: ICriticalContainerError) => void;
197
+ /** If false, loading or using a Tombstoned object should merely log, not fail */
198
+ gcTombstoneEnforcementAllowed: boolean;
199
+ }
200
+
201
+ /** Defines the contract for the garbage collector. */
202
+ export interface IGarbageCollector {
203
+ /** Tells whether GC should run or not. */
204
+ readonly shouldRunGC: boolean;
205
+ /** Tells whether the GC state in summary needs to be reset in the next summary. */
206
+ readonly summaryStateNeedsReset: boolean;
207
+ /** Initialize the state from the base snapshot after its creation. */
208
+ initializeBaseState(): Promise<void>;
209
+ /** Run garbage collection and update the reference / used state of the system. */
210
+ collectGarbage(
211
+ options: {
212
+ logger?: ITelemetryLogger;
213
+ runSweep?: boolean;
214
+ fullGC?: boolean;
215
+ },
216
+ telemetryContext?: ITelemetryContext,
217
+ ): Promise<IGCStats | undefined>;
218
+ /** Summarizes the GC data and returns it as a summary tree. */
219
+ summarize(
220
+ fullTree: boolean,
221
+ trackState: boolean,
222
+ telemetryContext?: ITelemetryContext,
223
+ ): ISummarizeResult | undefined;
224
+ /** Returns the garbage collector specific metadata to be written into the summary. */
225
+ getMetadata(): IGCMetadata;
226
+ /** Returns the GC details generated from the base snapshot. */
227
+ getBaseGCDetails(): Promise<IGarbageCollectionDetailsBase>;
228
+ /** Called when the latest summary of the system has been refreshed. */
229
+ refreshLatestSummary(
230
+ proposalHandle: string | undefined,
231
+ result: RefreshSummaryResult,
232
+ readAndParseBlob: ReadAndParseBlob,
233
+ ): Promise<void>;
234
+ /** Called when a node is updated. Used to detect and log when an inactive node is changed or loaded. */
235
+ nodeUpdated(
236
+ nodePath: string,
237
+ reason: "Loaded" | "Changed",
238
+ timestampMs?: number,
239
+ packagePath?: readonly string[],
240
+ requestHeaders?: IRequestHeader,
241
+ ): void;
242
+ /** Called when a reference is added to a node. Used to identify nodes that were referenced between summaries. */
243
+ addedOutboundReference(fromNodePath: string, toNodePath: string): void;
244
+ /** Returns true if this node has been deleted by GC during sweep phase. */
245
+ isNodeDeleted(nodePath: string): boolean;
246
+ setConnectionState(connected: boolean, clientId?: string): void;
247
+ dispose(): void;
248
+ }
249
+
250
+ /** Parameters necessary for creating a GarbageCollector. */
251
+ export interface IGarbageCollectorCreateParams {
252
+ readonly runtime: IGarbageCollectionRuntime;
253
+ readonly gcOptions: IGCRuntimeOptions;
254
+ readonly baseLogger: ITelemetryLogger;
255
+ readonly existing: boolean;
256
+ readonly metadata: IContainerRuntimeMetadata | undefined;
257
+ readonly createContainerMetadata: ICreateContainerMetadata;
258
+ readonly baseSnapshot: ISnapshotTree | undefined;
259
+ readonly isSummarizerClient: boolean;
260
+ readonly getNodePackagePath: (nodePath: string) => Promise<readonly string[] | undefined>;
261
+ readonly getLastSummaryTimestampMs: () => number | undefined;
262
+ readonly readAndParseBlob: ReadAndParseBlob;
263
+ readonly activeConnection: () => boolean;
264
+ readonly getContainerDiagnosticId: () => string;
265
+ }
266
+
267
+ export interface IGCRuntimeOptions {
268
+ /**
269
+ * Flag that if true, will enable running garbage collection (GC) for a new container.
270
+ *
271
+ * GC has mark phase and sweep phase. In mark phase, unreferenced objects are identified
272
+ * and marked as such in the summary. This option enables the mark phase.
273
+ * In sweep phase, unreferenced objects are eventually deleted from the container if they meet certain conditions.
274
+ * Sweep phase can be enabled via the "sweepAllowed" option.
275
+ *
276
+ * Note: This setting is persisted in the container's summary and cannot be changed.
277
+ */
278
+ gcAllowed?: boolean;
279
+
280
+ /**
281
+ * @deprecated - @see gcSweepGenerationOptionName and @see GCFeatureMatrix.sweepGeneration
282
+ *
283
+ * Flag that if true, enables GC's sweep phase for a new container.
284
+ *
285
+ * This will allow GC to eventually delete unreferenced objects from the container.
286
+ * This flag should only be set to true if "gcAllowed" is true.
287
+ *
288
+ * Note: This setting is persisted in the container's summary and cannot be changed.
289
+ */
290
+ sweepAllowed?: boolean;
291
+
292
+ /**
293
+ * Flag that if true, will disable garbage collection for the session.
294
+ * Can be used to disable running GC on containers where it is allowed via the gcAllowed option.
295
+ */
296
+ disableGC?: boolean;
297
+
298
+ /**
299
+ * Flag that will bypass optimizations and generate GC data for all nodes irrespective of whether a node
300
+ * changed or not.
301
+ */
302
+ runFullGC?: boolean;
303
+
304
+ /**
305
+ * Maximum session duration for a new container. If not present, a default value will be used.
306
+ *
307
+ * Note: This setting is persisted in the container's summary and cannot be changed.
308
+ */
309
+ sessionExpiryTimeoutMs?: number;
310
+
311
+ /**
312
+ * Allows additional GC options to be passed.
313
+ */
314
+ [key: string]: any;
315
+ }
316
+
317
+ /**
318
+ * The configurations for Garbage Collector that determines what runs and how.
319
+ */
320
+ export interface IGarbageCollectorConfigs {
321
+ /**
322
+ * Tracks if GC is enabled for this document. This is specified during document creation and doesn't change
323
+ * throughout its lifetime.
324
+ */
325
+ readonly gcEnabled: boolean;
326
+ /**
327
+ * Tracks if sweep phase is enabled for this document. This is specified during document creation and doesn't change
328
+ * throughout its lifetime.
329
+ */
330
+ readonly sweepEnabled: boolean;
331
+ /**
332
+ * Tracks if GC should run or not. Even if GC is enabled for a document (see gcEnabled), it can be explicitly
333
+ * disabled via runtime options or feature flags.
334
+ */
335
+ readonly shouldRunGC: boolean;
336
+ /**
337
+ * Tracks if sweep phase should run or not. Even if the sweep phase is enabled for a document (see sweepEnabled), it
338
+ * can be explicitly disabled via feature flags. It also won't run if session expiry is not enabled.
339
+ */
340
+ readonly shouldRunSweep: boolean;
341
+ /**
342
+ * If true, bypass optimizations and generate GC data for all nodes irrespective of whether a node changed or not.
343
+ */
344
+ readonly runFullGC: boolean | undefined;
345
+ /** The time in ms to expire a session for a client for gc. */
346
+ readonly sessionExpiryTimeoutMs: number | undefined;
347
+ /** The time after which an unreferenced node is ready to be swept. */
348
+ readonly sweepTimeoutMs: number | undefined;
349
+ /** The time after which an unreferenced node is inactive. */
350
+ readonly inactiveTimeoutMs: number;
351
+ /** Tracks whether GC should run in test mode. In this mode, unreferenced objects are deleted immediately. */
352
+ readonly testMode: boolean;
353
+ /**
354
+ * Tracks whether GC should run in tombstone mode. In this mode, sweep ready objects are marked as tombstones.
355
+ * In interactive (non-summarizer) clients, tombstone objects behave as if they are deleted, i.e., access to them
356
+ * is not allowed. However, these objects can be accessed after referencing them first. It is used as a staging
357
+ * step for sweep where accidental sweep ready objects can be recovered.
358
+ */
359
+ readonly tombstoneMode: boolean;
360
+ /** @see GCFeatureMatrix. */
361
+ readonly persistedGcFeatureMatrix: GCFeatureMatrix | undefined;
362
+ /** The version of GC in the base snapshot. */
363
+ readonly gcVersionInBaseSnapshot: GCVersion | undefined;
364
+ /** The current version of GC data in the running code */
365
+ readonly gcVersionInEffect: GCVersion;
366
+ }
367
+
368
+ /** The state of node that is unreferenced. */
369
+ export const UnreferencedState = {
370
+ /** The node is active, i.e., it can become referenced again. */
371
+ Active: "Active",
372
+ /** The node is inactive, i.e., it should not become referenced. */
373
+ Inactive: "Inactive",
374
+ /** The node is ready to be deleted by the sweep phase. */
375
+ SweepReady: "SweepReady",
376
+ } as const;
377
+ export type UnreferencedState = typeof UnreferencedState[keyof typeof UnreferencedState];
378
+
379
+ /**
380
+ * Represents the result of a GC run.
381
+ */
382
+ export interface IGCResult {
383
+ /** The ids of nodes that are referenced in the referenced graph */
384
+ referencedNodeIds: string[];
385
+ /** The ids of nodes that are not-referenced or deleted in the referenced graph */
386
+ deletedNodeIds: string[];
387
+ }