@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,263 @@
1
+ # Configs and feature gates for solving the 1MB limit.
2
+
3
+ ## Introduction
4
+
5
+ There is a current limitation regarding the size of the payload a Fluid client can send and receive. [The limit is 1MB per payload](https://github.com/microsoft/FluidFramework/issues/9023) and it is currently enforced explicitly with the `BatchTooLarge` error which closes the container.
6
+
7
+ There are two features which can be used to work around this size limit, batch compression and compressed batch chunking. This document describes how to enable/disable them, along with a brief description of how they work. The features are enabled by default.
8
+
9
+ By default, the runtime is configured with a max batch size of `716800` bytes, which is lower than the 1MB limit. The reason for the lower value is to account for possible overhead from the op envelope and metadata.
10
+
11
+ ## Table of contents
12
+
13
+ - [Introduction](#introduction)
14
+ - [Compression](#compression)
15
+ - [Grouped batching](#grouped-batching)
16
+ - [Chunking for compression](#chunking-for-compression)
17
+ - [Disabling in case of emergency](#disabling-in-case-of-emergency)
18
+ - [Example configs](#example-configs)
19
+ - [How it works](#how-it-works)
20
+ - [How grouped batching works](#how-grouped-batching-works)
21
+
22
+ ## Compression
23
+
24
+ **Compression targets payloads which exceed the max batch size and it is enabled by default.**. The `IContainerRuntimeOptions.compressionOptions` property, of type `ICompressionRuntimeOptions` is the configuration governing how compression works.
25
+
26
+ `ICompressionRuntimeOptions` has two properties:
27
+
28
+ - `minimumBatchSizeInBytes` – the minimum size of the batch for which compression should kick in. If the payload is too small, compression may not yield too many benefits. To target the original 1MB issue, a good value here would be to match the default maxBatchSizeInBytes (972800), however, experimentally, a good lower value could be at around 614400 bytes. Setting this value to `Number.POSITIVE_INFINITY` will disable compression.
29
+ - `compressionAlgorithm` – currently, only `lz4` is supported.
30
+
31
+ ## Grouped batching
32
+
33
+ **Note: This feature is currently considered experimental and is not ready for production usage.**
34
+
35
+ The `IContainerRuntimeOptions.enableGroupedBatching` option has been added to the container runtime layer and is **off by default**. This option will group all batch messages under a new "grouped" message to be sent to the service. Upon receiving this new "grouped" message, the batch messages will be extracted and given the sequence number of the parent "grouped" message.
36
+
37
+ The purpose for enabling grouped batching on top of compression is that regular compression won't include the empty messages in the chunks. Thus, if we have batches with many messages (i.e. more than 4k), we will go over the batch size limit just on empty op envelopes alone.
38
+
39
+ See [below](#how-grouped-batching-works) for an example.
40
+
41
+ ## Chunking for compression
42
+
43
+ **Op chunking for compression targets payloads which exceed the max batch size after compression.** So, only payloads which are already compressed. By default, the feature is enabled.
44
+
45
+ The `IContainerRuntimeOptions.chunkSizeInBytes` property is the only configuration for chunking and it represents the size of the chunked ops, when chunking is necessary. When chunking is performed, the large op is split into smaller ops (chunks). This config represents both the size of the chunks and the threshold for the feature to activate. The value enables a trade-off between large chunks / few ops and small chunks / many ops. A good value for this would be at around 204800. Setting this value to `Number.POSITIVE_INFINITY` will disable chunking.
46
+
47
+ This config would govern chunking compressed batches only. We will not be enabling chunking across all types of ops/batches but **only when compression is enabled and when the batch is compressed**, and its payload size is more than `IContainerRuntimeOptions.chunkSizeInBytes`.
48
+
49
+ ## Disabling in case of emergency
50
+
51
+ If the features are enabled using the configs, they can be disabled at runtime via feature gates as following:
52
+
53
+ - `Fluid.ContainerRuntime.CompressionDisabled` - if set to true, will disable compression (this has a side effect of also disabling chunking, as chunking is invoked only for compressed payloads).
54
+ - `Fluid.ContainerRuntime.DisableGroupedBatching` - if set to true, will disable grouped batching.
55
+ - `Fluid.ContainerRuntime.CompressionChunkingDisabled` - if set to true, will disable chunking for compression.
56
+
57
+ ## Example configs
58
+
59
+ By default, the runtime is configured with the following values related to compression and chunking:
60
+
61
+ ```
62
+ const runtimeOptions: IContainerRuntimeOptions = {
63
+ compressionOptions: {
64
+ minimumBatchSizeInBytes: 614400,
65
+ compressionAlgorithm: CompressionAlgorithms.lz4,
66
+ },
67
+ chunkSizeInBytes: 204800,
68
+ maxBatchSizeInBytes: 716800,
69
+     }
70
+ ```
71
+
72
+ To use compression but disable chunking:
73
+
74
+ ```
75
+ const runtimeOptions: IContainerRuntimeOptions = {
76
+ chunkSizeInBytes: Number.POSITIVE_INFINITY,
77
+     }
78
+ ```
79
+
80
+ To disable compression (will also disable chunking, as chunking works only for compressed batches):
81
+
82
+ ```
83
+ const runtimeOptions: IContainerRuntimeOptions = {
84
+ compressionOptions: {
85
+ minimumBatchSizeInBytes: Number.POSITIVE_INFINITY,
86
+ compressionAlgorithm: CompressionAlgorithms.lz4,
87
+ },
88
+     }
89
+ ```
90
+
91
+ To enable grouped batching:
92
+
93
+ ```
94
+ const runtimeOptions: IContainerRuntimeOptions = {
95
+ enableGroupedBatching: true,
96
+     }
97
+ ```
98
+
99
+ ## How it works
100
+
101
+ Compression currently works as a runtime layer over the regular op sending/receiving pipeline.
102
+
103
+ If we have a batch with a size larger than the configured minimum required for compression (in the example let’s say it’s 850 bytes), as following:
104
+
105
+ ```
106
+ +-----------+-----------+-----------+-----------+
107
+ | Op 1 | Op 2 | Op 3 | Op 4 |
108
+ | SeqNum: 1 | SeqNum: 2 | SeqNum: 3 | SeqNum: 4 |
109
+ | Size: 100 | Size: 150 | Size: 200 | Size: 400 |
110
+ +-----------+-----------+-----------+-----------+
111
+ ```
112
+
113
+ The total size of the batch is 850 bytes. The client which needs to send the batch would compress the batch to a smaller size (200 bytes) and will send a new batch like the following:
114
+
115
+ ```
116
+ +--------------------+-----------+-----------+-----------+
117
+ | Op 1 | Op 2 | Op 3 | Op 4 |
118
+ | SeqNum: 1 | SeqNum: 2 | SeqNum: 3 | SeqNum: 4 |
119
+ | Size: 200 | Size: 0 | Size: 0 | Size: 0 |
120
+ | Compression: 'lz4' | | | |
121
+ +--------------------+-----------+-----------+-----------+
122
+ ```
123
+
124
+ The first op in the batch is the only one with content (which is opaque due to it being compressed), the rest of the ops serve only to reserve the sequence numbers so that the state machine which rebuilds the original batch on the receiving client can reconstruct the original batch.
125
+
126
+ When the batch is received by a client, it will detect the first op as being compressed, it will decompress it and store it in memory. For each empty op subsequently received, it will fetch the uncompressed content from memory and rebuild the original ops. The original ops are then processed by the runtime and applied accordingly.
127
+ So, compression virtualizes the batch.
128
+
129
+ After compression, the first op in the batch can exceed 1MB, therefore it would still be rejected. In this case, another layer of virtualization is added after compression (and before decompression, symmetrically on the receiving end).
130
+
131
+ The first op in the compressed batch can be chunked into smaller ops which can be sent outside the original batch. However, to conveniently maintain the batch semantics, the last chunk (the chunk which triggers rebuilding the original op) is the first op in the new batch.
132
+
133
+ To illustrate, let’s take the large batch below:
134
+
135
+ ```
136
+ +--------------------+-----------+-----------+-----------+
137
+ | Op 1 | Op 2 | Op 3 | Op 4 |
138
+ | SeqNum: 1 | SeqNum: 2 | SeqNum: 3 | SeqNum: 4 |
139
+ | Size: 900 | Size: 0 | Size: 0 | Size: 0 |
140
+ | Compression: 'lz4' | | | |
141
+ +--------------------+-----------+-----------+-----------+
142
+ ```
143
+
144
+ This will produce the following batches:
145
+
146
+ ```
147
+ +-----------+
148
+ | Chunk 1/3 |
149
+ | SeqNum: 1 |
150
+ | Size: 300 |
151
+ +-----------+
152
+
153
+ ```
154
+
155
+ ```
156
+ +-----------+
157
+ | Chunk 2/3 |
158
+ | SeqNum: 2 |
159
+ | Size: 300 |
160
+ +-----------+
161
+
162
+ ```
163
+
164
+ ```
165
+ +-----------+-----------+-----------+-----------+
166
+ | Chunk 3/3 | Op 2 | Op 3 | Op 4 |
167
+ | SeqNum: 3 | SeqNum: 4 | SeqNum: 5 | SeqNum: 6 |
168
+ | Size: 300 | Size: 0 | Size: 0 | Size: 0 |
169
+ +-----------+-----------+-----------+-----------+
170
+ ```
171
+
172
+ The first 2 chunks are sent in their own batches, while the last chunk is the first op in the last batch which contains the ops reserving the required sequence numbers.
173
+
174
+ Notice that the sequence numbers don’t matter here, as all ops will be based off the same reference sequence number, so the sequence number will be recalculated for all, without additional work.
175
+
176
+ Additionally, as compression preserves the original uncompressed batch layout in terms of the number of ops by using empty ops to reserve the sequence numbers, this ensures that the clients will always receive the exact count of ops to rebuild the uncompressed batch sequentially.
177
+
178
+ On the receiving end, the client will accumulate chunks 1 and 2 and keep them in memory. When chunk 3 is received, the original large, decompressed op will be rebuilt, and the runtime will then process the batch as if it is a compressed batch.
179
+
180
+ ## How grouped batching works
181
+
182
+ **Note: There are plans to replace empty ops with something more efficient when doing grouped batching AB#4092**
183
+
184
+ Given the following baseline batch:
185
+
186
+ ```
187
+ +---------------+---------------+---------------+---------------+---------------+
188
+ | Op 1 | Op 2 | Op 3 | Op 4 | Op 5 |
189
+ | Contents: "a" | Contents: "b" | Contents: "c" | Contents: "d" | Contents: "e" |
190
+ +---------------+---------------+---------------+---------------+---------------+
191
+ ```
192
+
193
+ Compressed batch:
194
+
195
+ ```
196
+ +--------------------+-----------------+-----------------+-----------------+-----------------+
197
+ | Op 1 | Op 2 | Op 3 | Op 4 | Op 5 |
198
+ | Contents: "abcde" | Contents: empty | Contents: empty | Contents: empty | Contents: empty |
199
+ | Compression: 'lz4' | | | | |
200
+ +--------------------+-----------------+-----------------+-----------------+-----------------+
201
+ ```
202
+
203
+ Grouped batch:
204
+
205
+ ```
206
+ +---------------------------------------------------------------------------------------------------------------------------------+
207
+ | Op 1 Contents: +--------------------+-----------------+-----------------+-----------------+-----------------+ |
208
+ | SeqNum: 1 | Op 1 | Op 2 | Op 3 | Op 4 | Op 5 | |
209
+ | Type: "groupedBatch" | Contents: "abcde" | Contents: empty | Contents: empty | Contents: empty | Contents: empty | |
210
+ | | Compression: 'lz4' | | | | | |
211
+ | +--------------------+-----------------+-----------------+-----------------+-----------------+ |
212
+ +---------------------------------------------------------------------------------------------------------------------------------+
213
+ ```
214
+
215
+ Can produce the following chunks:
216
+
217
+ ```
218
+ +-------------------------------------------------+
219
+ | Chunk 1/2 Contents: +----------------------+ |
220
+ | SeqNum: 1 | +-----------------+ | |
221
+ | | | Contents: "abc" | | |
222
+ | | +-----------------+ | |
223
+ | +----------------------+ |
224
+ +-------------------------------------------------+
225
+ ```
226
+
227
+ ```
228
+ +--------------------------------------------------------------------------------------------------------------------------+
229
+ | Chunk 2/2 Contents: +---------------------------------------------------------------------------------------------+ | |
230
+ | SeqNum: 2 | +----------------+-----------------+-----------------+-----------------+-----------------+ | | |
231
+ | | | Contents: "de" | Contents: empty | Contents: empty | Contents: empty | Contents: empty | | | |
232
+ | | +----------------+-----------------+-----------------+-----------------+-----------------+ | | |
233
+ | +---------------------------------------------------------------------------------------------+ | |
234
+ +--------------------------------------------------------------------------------------------------------------------------+
235
+ ```
236
+
237
+ - Send to service
238
+ - Service acks ops sent
239
+ - Receive chunks from service
240
+ - Recompile to the grouped batch step
241
+
242
+ Ungrouped batch:
243
+
244
+ ```
245
+ +--------------------+-----------------+-----------------+-----------------+-----------------+
246
+ | Op 1 | Op 2 | Op 3 | Op 4 | Op 5 |
247
+ | Contents: "abcde" | Contents: empty | Contents: empty | Contents: empty | Contents: empty |
248
+ | SeqNum: 2 | SeqNum: 2 | SeqNum: 2 | SeqNum: 2 | SeqNum: 2 |
249
+ | ClientSeqNum: 1 | ClientSeqNum: 2 | ClientSeqNum: 3 | ClientSeqNum: 4 | ClientSeqNum: 5 |
250
+ | Compression: 'lz4' | | | | |
251
+ +--------------------+-----------------+-----------------+-----------------+-----------------+
252
+ ```
253
+
254
+ Uncompressed batch:
255
+
256
+ ```
257
+ +-----------------+-----------------+-----------------+-----------------+-----------------+
258
+ | Op 1 | Op 2 | Op 3 | Op 4 | Op 5 |
259
+ | Contents: "a" | Contents: "b" | Contents: "c" | Contents: "d" | Contents: "e" |
260
+ | SeqNum: 2 | SeqNum: 2 | SeqNum: 2 | SeqNum: 2 | SeqNum: 2 |
261
+ | ClientSeqNum: 1 | ClientSeqNum: 2 | ClientSeqNum: 3 | ClientSeqNum: 4 | ClientSeqNum: 5 |
262
+ +-----------------+-----------------+-----------------+-----------------+-----------------+
263
+ ```
@@ -3,34 +3,27 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
- import { UsageError } from "@fluidframework/driver-utils";
8
- import { ChildLogger } from "@fluidframework/telemetry-utils";
9
6
  import { ICompressionRuntimeOptions } from "../containerRuntime";
10
7
  import { BatchMessage, IBatch, IBatchCheckpoint } from "./definitions";
11
8
 
12
9
  export interface IBatchManagerOptions {
13
- readonly enableOpReentryCheck?: boolean;
14
10
  readonly hardLimit: number;
15
11
  readonly softLimit?: number;
16
12
  readonly compressionOptions?: ICompressionRuntimeOptions;
17
13
  }
18
14
 
15
+ /**
16
+ * Estimated size of the stringification overhead for an op accumulated
17
+ * from runtime to loader to the service.
18
+ */
19
+ const opOverhead = 200;
20
+
19
21
  /**
20
22
  * Helper class that manages partial batch & rollback.
21
23
  */
22
24
  export class BatchManager {
23
- private readonly logger;
24
25
  private pendingBatch: BatchMessage[] = [];
25
26
  private batchContentSize = 0;
26
- /**
27
- * Track the number of ops which were detected to have a mismatched
28
- * reference sequence number, in order to self-throttle the telemetry events.
29
- *
30
- * This should be removed as part of ADO:2322
31
- */
32
- private readonly maxMismatchedOpsToReport = 5;
33
- private mismatchedOpsReported = 0;
34
27
 
35
28
  public get length() {
36
29
  return this.pendingBatch.length;
@@ -39,13 +32,15 @@ export class BatchManager {
39
32
  return this.batchContentSize;
40
33
  }
41
34
 
42
- constructor(public readonly options: IBatchManagerOptions, logger: ITelemetryLogger) {
43
- this.logger = ChildLogger.create(logger, "BatchManager");
35
+ public get referenceSequenceNumber(): number | undefined {
36
+ return this.pendingBatch.length === 0
37
+ ? undefined
38
+ : this.pendingBatch[this.pendingBatch.length - 1].referenceSequenceNumber;
44
39
  }
45
40
 
46
- public push(message: BatchMessage): boolean {
47
- this.checkReferenceSequenceNumber(message);
41
+ constructor(public readonly options: IBatchManagerOptions) {}
48
42
 
43
+ public push(message: BatchMessage): boolean {
49
44
  const contentSize = this.batchContentSize + (message.contents?.length ?? 0);
50
45
  const opCount = this.pendingBatch.length;
51
46
 
@@ -54,7 +49,7 @@ export class BatchManager {
54
49
  // Also content will be strigified, and that adds a lot of overhead due to a lot of escape characters.
55
50
  // Not taking it into account, as compression work should help there - compressed payload will be
56
51
  // initially stored as base64, and that requires only 2 extra escape characters.
57
- const socketMessageSize = contentSize + 200 * opCount;
52
+ const socketMessageSize = contentSize + opOverhead * opCount;
58
53
 
59
54
  // If we were provided soft limit, check for exceeding it.
60
55
  // But only if we have any ops, as the intention here is to flush existing ops (on exceeding this limit)
@@ -86,6 +81,7 @@ export class BatchManager {
86
81
  const batch: IBatch = {
87
82
  content: this.pendingBatch,
88
83
  contentSizeInBytes: this.batchContentSize,
84
+ referenceSequenceNumber: this.referenceSequenceNumber,
89
85
  };
90
86
 
91
87
  this.pendingBatch = [];
@@ -112,43 +108,6 @@ export class BatchManager {
112
108
  },
113
109
  };
114
110
  }
115
-
116
- private checkReferenceSequenceNumber(message: BatchMessage) {
117
- if (
118
- this.pendingBatch.length === 0 ||
119
- message.referenceSequenceNumber === this.pendingBatch[0].referenceSequenceNumber
120
- ) {
121
- // The reference sequence numbers are stable
122
- return;
123
- }
124
-
125
- const telemetryProperties = {
126
- referenceSequenceNumber: this.pendingBatch[0].referenceSequenceNumber,
127
- messageReferenceSequenceNumber: message.referenceSequenceNumber,
128
- type: message.deserializedContent.type,
129
- length: this.pendingBatch.length,
130
- enableOpReentryCheck: this.options.enableOpReentryCheck === true,
131
- };
132
- const error = new UsageError("Submission of an out of order message");
133
- const eventName = "ReferenceSequenceNumberMismatch";
134
-
135
- if (this.options.enableOpReentryCheck === true) {
136
- this.logger.sendErrorEvent({ eventName, ...telemetryProperties }, error);
137
- throw error;
138
- }
139
-
140
- if (++this.mismatchedOpsReported <= this.maxMismatchedOpsToReport) {
141
- this.logger.sendErrorEvent(
142
- {
143
- eventName,
144
- ...telemetryProperties,
145
- ops: this.mismatchedOpsReported,
146
- maxOps: this.maxMismatchedOpsToReport,
147
- },
148
- error,
149
- );
150
- }
151
- }
152
111
  }
153
112
 
154
113
  const addBatchMetadata = (batch: IBatch): IBatch => {
@@ -165,3 +124,15 @@ const addBatchMetadata = (batch: IBatch): IBatch => {
165
124
 
166
125
  return batch;
167
126
  };
127
+
128
+ /**
129
+ * Estimates the real size in bytes on the socket for a given batch. It assumes that
130
+ * the envelope size (and the size of an empty op) is 200 bytes, taking into account
131
+ * extra overhead from stringification.
132
+ *
133
+ * @param batch - the batch to inspect
134
+ * @returns An estimate of the payload size in bytes which will be produced when the batch is sent over the wire
135
+ */
136
+ export const estimateSocketSize = (batch: IBatch): number => {
137
+ return batch.contentSizeInBytes + opOverhead * batch.content.length;
138
+ };
@@ -30,6 +30,10 @@ export interface IBatch {
30
30
  * All the messages in the batch
31
31
  */
32
32
  readonly content: BatchMessage[];
33
+ /**
34
+ * The reference sequence number for the batch
35
+ */
36
+ readonly referenceSequenceNumber: number | undefined;
33
37
  }
34
38
 
35
39
  export interface IBatchCheckpoint {
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export { BatchManager } from "./batchManager";
6
+ export { BatchManager, estimateSocketSize } from "./batchManager";
7
7
  export {
8
8
  BatchMessage,
9
9
  IBatch,
@@ -16,3 +16,4 @@ export { OpCompressor } from "./opCompressor";
16
16
  export { OpDecompressor } from "./opDecompressor";
17
17
  export { OpSplitter, splitOp } from "./opSplitter";
18
18
  export { RemoteMessageProcessor, unpackRuntimeMessage } from "./remoteMessageProcessor";
19
+ export { OpGroupingManager } from "./opGroupingManager";
@@ -4,11 +4,12 @@
4
4
  */
5
5
 
6
6
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
7
- import { IsoBuffer } from "@fluidframework/common-utils";
7
+ import { assert, IsoBuffer } from "@fluidframework/common-utils";
8
8
  import { UsageError } from "@fluidframework/container-utils";
9
9
  import { ChildLogger } from "@fluidframework/telemetry-utils";
10
10
  import { compress } from "lz4js";
11
11
  import { CompressionAlgorithms } from "../containerRuntime";
12
+ import { estimateSocketSize } from "./batchManager";
12
13
  import { IBatch, BatchMessage } from "./definitions";
13
14
 
14
15
  /**
@@ -24,21 +25,17 @@ export class OpCompressor {
24
25
  }
25
26
 
26
27
  public compressBatch(batch: IBatch): IBatch {
28
+ assert(
29
+ batch.contentSizeInBytes > 0 && batch.content.length > 0,
30
+ 0x5a4 /* Batch should not be empty */,
31
+ );
32
+
27
33
  const compressionStart = Date.now();
28
34
  const contentsAsBuffer = new TextEncoder().encode(this.serializeBatch(batch));
29
35
  const compressedContents = compress(contentsAsBuffer);
30
36
  const compressedContent = IsoBuffer.from(compressedContents).toString("base64");
31
37
  const duration = Date.now() - compressionStart;
32
38
 
33
- if (batch.contentSizeInBytes > 200000) {
34
- this.logger.sendPerformanceEvent({
35
- eventName: "CompressedBatch",
36
- duration,
37
- sizeBeforeCompression: batch.contentSizeInBytes,
38
- sizeAfterCompression: compressedContent.length,
39
- });
40
- }
41
-
42
39
  const messages: BatchMessage[] = [];
43
40
  messages.push({
44
41
  ...batch.content[0],
@@ -47,14 +44,37 @@ export class OpCompressor {
47
44
  compression: CompressionAlgorithms.lz4,
48
45
  });
49
46
 
47
+ // Add empty placeholder messages to reserve the sequence numbers
50
48
  for (const message of batch.content.slice(1)) {
51
- messages.push({ ...message, contents: undefined });
49
+ messages.push({
50
+ deserializedContent: {
51
+ contents: undefined,
52
+ type: message.deserializedContent.type,
53
+ },
54
+ localOpMetadata: message.localOpMetadata,
55
+ metadata: message.metadata,
56
+ referenceSequenceNumber: message.referenceSequenceNumber,
57
+ });
52
58
  }
53
59
 
54
- return {
60
+ const compressedBatch: IBatch = {
55
61
  contentSizeInBytes: compressedContent.length,
56
62
  content: messages,
63
+ referenceSequenceNumber: batch.referenceSequenceNumber,
57
64
  };
65
+
66
+ if (batch.contentSizeInBytes > 200000) {
67
+ this.logger.sendPerformanceEvent({
68
+ eventName: "CompressedBatch",
69
+ duration,
70
+ sizeBeforeCompression: batch.contentSizeInBytes,
71
+ sizeAfterCompression: compressedBatch.contentSizeInBytes,
72
+ opCount: compressedBatch.content.length,
73
+ socketSize: estimateSocketSize(compressedBatch),
74
+ });
75
+ }
76
+
77
+ return compressedBatch;
58
78
  }
59
79
 
60
80
  private serializeBatch(batch: IBatch): string {
@@ -6,6 +6,8 @@
6
6
  import { decompress } from "lz4js";
7
7
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
8
  import { assert, IsoBuffer, Uint8ArrayToString } from "@fluidframework/common-utils";
9
+ import { ChildLogger } from "@fluidframework/telemetry-utils";
10
+ import { ITelemetryLogger } from "@fluidframework/common-definitions";
9
11
  import { CompressionAlgorithms } from "../containerRuntime";
10
12
  import { IMessageProcessingResult } from "./definitions";
11
13
 
@@ -21,6 +23,11 @@ export class OpDecompressor {
21
23
  private activeBatch = false;
22
24
  private rootMessageContents: any | undefined;
23
25
  private processedCount = 0;
26
+ private readonly logger;
27
+
28
+ constructor(logger: ITelemetryLogger) {
29
+ this.logger = ChildLogger.create(logger, "OpDecompressor");
30
+ }
24
31
 
25
32
  public processMessage(message: ISequencedDocumentMessage): IMessageProcessingResult {
26
33
  assert(
@@ -28,7 +35,7 @@ export class OpDecompressor {
28
35
  0x511 /* Only lz4 compression is supported */,
29
36
  );
30
37
 
31
- if (message.metadata?.batch === true && message.compression === CompressionAlgorithms.lz4) {
38
+ if (message.metadata?.batch === true && this.isCompressed(message)) {
32
39
  // Beginning of a compressed batch
33
40
  assert(this.activeBatch === false, 0x4b8 /* shouldn't have multiple active batches */);
34
41
  if (message.compression) {
@@ -84,10 +91,7 @@ export class OpDecompressor {
84
91
  };
85
92
  }
86
93
 
87
- if (
88
- message.metadata?.batch === undefined &&
89
- message.compression === CompressionAlgorithms.lz4
90
- ) {
94
+ if (message.metadata?.batch === undefined && this.isCompressed(message)) {
91
95
  // Single compressed message
92
96
  assert(
93
97
  this.activeBatch === false,
@@ -110,6 +114,47 @@ export class OpDecompressor {
110
114
  state: "Skipped",
111
115
  };
112
116
  }
117
+
118
+ private isCompressed(message: ISequencedDocumentMessage) {
119
+ if (message.compression === CompressionAlgorithms.lz4) {
120
+ return true;
121
+ }
122
+
123
+ /**
124
+ * Back-compat self healing mechanism for ADO:3538, as loaders from
125
+ * version client_v2.0.0-internal.1.2.0 to client_v2.0.0-internal.2.2.0 do not
126
+ * support adding the proper compression metadata to compressed messages submitted
127
+ * by the runtime. Should be removed after the loader reaches sufficient saturation
128
+ * for a version greater or equal than client_v2.0.0-internal.2.2.0.
129
+ *
130
+ * The condition holds true for compressed messages, regardless of metadata. We are ultimately
131
+ * looking for a message with a single property `packedContents` inside `contents`, of type 'string'
132
+ * with a base64 encoded value.
133
+ */
134
+ try {
135
+ if (
136
+ message.contents !== null &&
137
+ typeof message.contents === "object" &&
138
+ Object.keys(message.contents).length === 1 &&
139
+ message.contents?.packedContents !== undefined &&
140
+ typeof message.contents?.packedContents === "string" &&
141
+ message.contents.packedContents.length > 0 &&
142
+ IsoBuffer.from(message.contents.packedContents, "base64").toString("base64") ===
143
+ message.contents.packedContents
144
+ ) {
145
+ this.logger.sendTelemetryEvent({
146
+ eventName: "LegacyCompression",
147
+ type: message.type,
148
+ batch: message.metadata?.batch,
149
+ });
150
+ return true;
151
+ }
152
+ } catch (err) {
153
+ return false;
154
+ }
155
+
156
+ return false;
157
+ }
113
158
  }
114
159
 
115
160
  // We should not be mutating the input message nor its metadata
@@ -0,0 +1,78 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { assert } from "@fluidframework/common-utils";
7
+ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
+ import { ContainerRuntimeMessage } from "..";
9
+ import { IBatch } from "./definitions";
10
+
11
+ interface IGroupedMessage {
12
+ contents?: unknown;
13
+ metadata?: Record<string, unknown>;
14
+ compression?: string;
15
+ }
16
+
17
+ export class OpGroupingManager {
18
+ static groupedBatchOp = "groupedBatch";
19
+
20
+ constructor(private readonly groupedBatchingEnabled: boolean) {}
21
+
22
+ public groupBatch(batch: IBatch): IBatch {
23
+ if (batch.content.length < 2 || !this.groupedBatchingEnabled) {
24
+ return batch;
25
+ }
26
+
27
+ for (const message of batch.content) {
28
+ if (message.metadata) {
29
+ const keys = Object.keys(message.metadata);
30
+ assert(keys.length < 2, 0x5dd /* cannot group ops with metadata */);
31
+ assert(
32
+ keys.length === 0 || keys[0] === "batch",
33
+ 0x5de /* unexpected op metadata */,
34
+ );
35
+ }
36
+ }
37
+
38
+ // Need deserializedContent for back-compat
39
+ const deserializedContent = {
40
+ type: OpGroupingManager.groupedBatchOp,
41
+ contents: batch.content.map<IGroupedMessage>((message) => ({
42
+ contents: message.contents === undefined ? undefined : JSON.parse(message.contents),
43
+ metadata: message.metadata,
44
+ compression: message.compression,
45
+ })),
46
+ };
47
+
48
+ const groupedBatch: IBatch = {
49
+ ...batch,
50
+ content: [
51
+ {
52
+ localOpMetadata: undefined,
53
+ metadata: undefined,
54
+ referenceSequenceNumber: batch.content[0].referenceSequenceNumber,
55
+ deserializedContent: deserializedContent as ContainerRuntimeMessage,
56
+ contents: JSON.stringify(deserializedContent),
57
+ },
58
+ ],
59
+ };
60
+ return groupedBatch;
61
+ }
62
+
63
+ public ungroupOp(op: ISequencedDocumentMessage): ISequencedDocumentMessage[] {
64
+ if (op.contents?.type !== OpGroupingManager.groupedBatchOp) {
65
+ return [op];
66
+ }
67
+
68
+ const messages = op.contents.contents as IGroupedMessage[];
69
+ let fakeCsn = 1;
70
+ return messages.map((subMessage) => ({
71
+ ...op,
72
+ clientSequenceNumber: fakeCsn++,
73
+ contents: subMessage.contents,
74
+ metadata: subMessage.metadata,
75
+ compression: subMessage.compression,
76
+ }));
77
+ }
78
+ }