@fluidframework/container-runtime 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229

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 (563) hide show
  1. package/.eslintrc.js +21 -10
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/batchTracker.d.ts +1 -2
  5. package/dist/batchTracker.d.ts.map +1 -1
  6. package/dist/batchTracker.js +2 -1
  7. package/dist/batchTracker.js.map +1 -1
  8. package/dist/blobManager.d.ts +74 -42
  9. package/dist/blobManager.d.ts.map +1 -1
  10. package/dist/blobManager.js +321 -152
  11. package/dist/blobManager.js.map +1 -1
  12. package/dist/connectionTelemetry.d.ts.map +1 -1
  13. package/dist/connectionTelemetry.js +11 -9
  14. package/dist/connectionTelemetry.js.map +1 -1
  15. package/dist/containerHandleContext.d.ts.map +1 -1
  16. package/dist/containerHandleContext.js +3 -1
  17. package/dist/containerHandleContext.js.map +1 -1
  18. package/dist/containerRuntime.d.ts +148 -114
  19. package/dist/containerRuntime.d.ts.map +1 -1
  20. package/dist/containerRuntime.js +534 -342
  21. package/dist/containerRuntime.js.map +1 -1
  22. package/dist/dataStore.d.ts.map +1 -1
  23. package/dist/dataStore.js +11 -9
  24. package/dist/dataStore.js.map +1 -1
  25. package/dist/dataStoreContext.d.ts +40 -13
  26. package/dist/dataStoreContext.d.ts.map +1 -1
  27. package/dist/dataStoreContext.js +146 -66
  28. package/dist/dataStoreContext.js.map +1 -1
  29. package/dist/dataStoreContexts.d.ts.map +1 -1
  30. package/dist/dataStoreContexts.js +7 -3
  31. package/dist/dataStoreContexts.js.map +1 -1
  32. package/dist/dataStoreRegistry.d.ts.map +1 -1
  33. package/dist/dataStoreRegistry.js +3 -1
  34. package/dist/dataStoreRegistry.js.map +1 -1
  35. package/dist/dataStores.d.ts +39 -12
  36. package/dist/dataStores.d.ts.map +1 -1
  37. package/dist/dataStores.js +164 -76
  38. package/dist/dataStores.js.map +1 -1
  39. package/dist/deltaManagerSummarizerProxy.d.ts +19 -0
  40. package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -0
  41. package/dist/deltaManagerSummarizerProxy.js +40 -0
  42. package/dist/deltaManagerSummarizerProxy.js.map +1 -0
  43. package/dist/deltaScheduler.d.ts.map +1 -1
  44. package/dist/deltaScheduler.js +8 -3
  45. package/dist/deltaScheduler.js.map +1 -1
  46. package/dist/gc/garbageCollection.d.ts +204 -0
  47. package/dist/gc/garbageCollection.d.ts.map +1 -0
  48. package/dist/gc/garbageCollection.js +926 -0
  49. package/dist/gc/garbageCollection.js.map +1 -0
  50. package/dist/gc/gcConfigs.d.ts +22 -0
  51. package/dist/gc/gcConfigs.d.ts.map +1 -0
  52. package/dist/gc/gcConfigs.js +143 -0
  53. package/dist/gc/gcConfigs.js.map +1 -0
  54. package/dist/gc/gcDefinitions.d.ts +320 -0
  55. package/dist/gc/gcDefinitions.d.ts.map +1 -0
  56. package/dist/gc/gcDefinitions.js +81 -0
  57. package/dist/gc/gcDefinitions.js.map +1 -0
  58. package/dist/gc/gcHelpers.d.ts +86 -0
  59. package/dist/gc/gcHelpers.d.ts.map +1 -0
  60. package/dist/gc/gcHelpers.js +268 -0
  61. package/dist/gc/gcHelpers.js.map +1 -0
  62. package/dist/gc/gcReferenceGraphAlgorithm.d.ts +16 -0
  63. package/dist/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -0
  64. package/dist/gc/gcReferenceGraphAlgorithm.js +49 -0
  65. package/dist/gc/gcReferenceGraphAlgorithm.js.map +1 -0
  66. package/dist/gc/gcSummaryDefinitions.d.ts +52 -0
  67. package/dist/gc/gcSummaryDefinitions.d.ts.map +1 -0
  68. package/dist/gc/gcSummaryDefinitions.js +7 -0
  69. package/dist/gc/gcSummaryDefinitions.js.map +1 -0
  70. package/dist/gc/gcSummaryStateTracker.d.ts +93 -0
  71. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -0
  72. package/dist/gc/gcSummaryStateTracker.js +239 -0
  73. package/dist/gc/gcSummaryStateTracker.js.map +1 -0
  74. package/{lib → dist/gc}/gcSweepReadyUsageDetection.d.ts +5 -5
  75. package/dist/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
  76. package/dist/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +15 -11
  77. package/dist/gc/gcSweepReadyUsageDetection.js.map +1 -0
  78. package/dist/gc/gcUnreferencedStateTracker.d.ts +34 -0
  79. package/dist/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
  80. package/dist/gc/gcUnreferencedStateTracker.js +94 -0
  81. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -0
  82. package/dist/gc/index.d.ts +13 -0
  83. package/dist/gc/index.d.ts.map +1 -0
  84. package/dist/gc/index.js +50 -0
  85. package/dist/gc/index.js.map +1 -0
  86. package/dist/index.d.ts +3 -8
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +7 -13
  89. package/dist/index.js.map +1 -1
  90. package/dist/opLifecycle/batchManager.d.ts +10 -0
  91. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  92. package/dist/opLifecycle/batchManager.js +37 -8
  93. package/dist/opLifecycle/batchManager.js.map +1 -1
  94. package/dist/opLifecycle/definitions.d.ts +29 -1
  95. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  96. package/dist/opLifecycle/definitions.js.map +1 -1
  97. package/dist/opLifecycle/index.d.ts +3 -3
  98. package/dist/opLifecycle/index.d.ts.map +1 -1
  99. package/dist/opLifecycle/index.js +3 -1
  100. package/dist/opLifecycle/index.js.map +1 -1
  101. package/dist/opLifecycle/opCompressor.d.ts +1 -1
  102. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  103. package/dist/opLifecycle/opCompressor.js +46 -17
  104. package/dist/opLifecycle/opCompressor.js.map +1 -1
  105. package/dist/opLifecycle/opDecompressor.d.ts +6 -1
  106. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  107. package/dist/opLifecycle/opDecompressor.js +72 -18
  108. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  109. package/dist/opLifecycle/opSplitter.d.ts +46 -2
  110. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  111. package/dist/opLifecycle/opSplitter.js +142 -5
  112. package/dist/opLifecycle/opSplitter.js.map +1 -1
  113. package/dist/opLifecycle/outbox.d.ts +23 -2
  114. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  115. package/dist/opLifecycle/outbox.js +101 -51
  116. package/dist/opLifecycle/outbox.js.map +1 -1
  117. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  118. package/dist/opLifecycle/remoteMessageProcessor.js +17 -2
  119. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  120. package/dist/opProperties.d.ts.map +1 -1
  121. package/dist/opProperties.js +1 -3
  122. package/dist/opProperties.js.map +1 -1
  123. package/dist/packageVersion.d.ts +1 -1
  124. package/dist/packageVersion.js +1 -1
  125. package/dist/packageVersion.js.map +1 -1
  126. package/dist/pendingStateManager.d.ts +6 -15
  127. package/dist/pendingStateManager.d.ts.map +1 -1
  128. package/dist/pendingStateManager.js +137 -165
  129. package/dist/pendingStateManager.js.map +1 -1
  130. package/dist/scheduleManager.d.ts +0 -1
  131. package/dist/scheduleManager.d.ts.map +1 -1
  132. package/dist/scheduleManager.js +11 -21
  133. package/dist/scheduleManager.js.map +1 -1
  134. package/dist/storageServiceWithAttachBlobs.d.ts +17 -0
  135. package/dist/storageServiceWithAttachBlobs.d.ts.map +1 -0
  136. package/dist/storageServiceWithAttachBlobs.js +32 -0
  137. package/dist/storageServiceWithAttachBlobs.js.map +1 -0
  138. package/dist/summary/index.d.ts +17 -0
  139. package/dist/summary/index.d.ts.map +1 -0
  140. package/dist/summary/index.js +46 -0
  141. package/dist/summary/index.js.map +1 -0
  142. package/dist/summary/orderedClientElection.d.ts.map +1 -0
  143. package/dist/{orderedClientElection.js → summary/orderedClientElection.js} +10 -4
  144. package/dist/summary/orderedClientElection.js.map +1 -0
  145. package/{lib → dist/summary}/runWhileConnectedCoordinator.d.ts +3 -2
  146. package/dist/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
  147. package/dist/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +5 -4
  148. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -0
  149. package/{lib → dist/summary}/runningSummarizer.d.ts +19 -18
  150. package/dist/summary/runningSummarizer.d.ts.map +1 -0
  151. package/dist/{runningSummarizer.js → summary/runningSummarizer.js} +191 -77
  152. package/dist/summary/runningSummarizer.js.map +1 -0
  153. package/dist/{summarizer.d.ts → summary/summarizer.d.ts} +6 -12
  154. package/dist/summary/summarizer.d.ts.map +1 -0
  155. package/dist/{summarizer.js → summary/summarizer.js} +32 -76
  156. package/dist/summary/summarizer.js.map +1 -0
  157. package/dist/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +1 -2
  158. package/dist/summary/summarizerClientElection.d.ts.map +1 -0
  159. package/dist/{summarizerClientElection.js → summary/summarizerClientElection.js} +3 -30
  160. package/dist/summary/summarizerClientElection.js.map +1 -0
  161. package/dist/{summarizerHeuristics.d.ts → summary/summarizerHeuristics.d.ts} +1 -1
  162. package/dist/summary/summarizerHeuristics.d.ts.map +1 -0
  163. package/dist/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +9 -12
  164. package/dist/summary/summarizerHeuristics.js.map +1 -0
  165. package/dist/summary/summarizerNode/index.d.ts +8 -0
  166. package/dist/summary/summarizerNode/index.d.ts.map +1 -0
  167. package/dist/summary/summarizerNode/index.js +12 -0
  168. package/dist/summary/summarizerNode/index.js.map +1 -0
  169. package/dist/summary/summarizerNode/summarizerNode.d.ts +149 -0
  170. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -0
  171. package/dist/summary/summarizerNode/summarizerNode.js +531 -0
  172. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -0
  173. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +125 -0
  174. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -0
  175. package/dist/summary/summarizerNode/summarizerNodeUtils.js +132 -0
  176. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -0
  177. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +22 -0
  178. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -0
  179. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +423 -0
  180. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -0
  181. package/{lib → dist/summary}/summarizerTypes.d.ts +29 -42
  182. package/dist/summary/summarizerTypes.d.ts.map +1 -0
  183. package/dist/{summarizerTypes.js → summary/summarizerTypes.js} +0 -5
  184. package/dist/summary/summarizerTypes.js.map +1 -0
  185. package/dist/summary/summaryCollection.d.ts.map +1 -0
  186. package/dist/{summaryCollection.js → summary/summaryCollection.js} +18 -8
  187. package/dist/summary/summaryCollection.js.map +1 -0
  188. package/{lib → dist/summary}/summaryFormat.d.ts +3 -21
  189. package/dist/summary/summaryFormat.d.ts.map +1 -0
  190. package/dist/{summaryFormat.js → summary/summaryFormat.js} +19 -21
  191. package/dist/summary/summaryFormat.js.map +1 -0
  192. package/dist/summary/summaryGenerator.d.ts.map +1 -0
  193. package/dist/{summaryGenerator.js → summary/summaryGenerator.js} +34 -16
  194. package/dist/summary/summaryGenerator.js.map +1 -0
  195. package/dist/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
  196. package/dist/summary/summaryManager.d.ts.map +1 -0
  197. package/dist/{summaryManager.js → summary/summaryManager.js} +21 -9
  198. package/dist/summary/summaryManager.js.map +1 -0
  199. package/dist/throttler.d.ts +2 -2
  200. package/dist/throttler.d.ts.map +1 -1
  201. package/dist/throttler.js +4 -4
  202. package/dist/throttler.js.map +1 -1
  203. package/lib/batchTracker.d.ts +1 -2
  204. package/lib/batchTracker.d.ts.map +1 -1
  205. package/lib/batchTracker.js +2 -1
  206. package/lib/batchTracker.js.map +1 -1
  207. package/lib/blobManager.d.ts +74 -42
  208. package/lib/blobManager.d.ts.map +1 -1
  209. package/lib/blobManager.js +322 -153
  210. package/lib/blobManager.js.map +1 -1
  211. package/lib/connectionTelemetry.d.ts.map +1 -1
  212. package/lib/connectionTelemetry.js +11 -9
  213. package/lib/connectionTelemetry.js.map +1 -1
  214. package/lib/containerHandleContext.d.ts.map +1 -1
  215. package/lib/containerHandleContext.js +3 -1
  216. package/lib/containerHandleContext.js.map +1 -1
  217. package/lib/containerRuntime.d.ts +148 -114
  218. package/lib/containerRuntime.d.ts.map +1 -1
  219. package/lib/containerRuntime.js +506 -314
  220. package/lib/containerRuntime.js.map +1 -1
  221. package/lib/dataStore.d.ts.map +1 -1
  222. package/lib/dataStore.js +11 -9
  223. package/lib/dataStore.js.map +1 -1
  224. package/lib/dataStoreContext.d.ts +40 -13
  225. package/lib/dataStoreContext.d.ts.map +1 -1
  226. package/lib/dataStoreContext.js +136 -56
  227. package/lib/dataStoreContext.js.map +1 -1
  228. package/lib/dataStoreContexts.d.ts.map +1 -1
  229. package/lib/dataStoreContexts.js +7 -3
  230. package/lib/dataStoreContexts.js.map +1 -1
  231. package/lib/dataStoreRegistry.d.ts.map +1 -1
  232. package/lib/dataStoreRegistry.js +3 -1
  233. package/lib/dataStoreRegistry.js.map +1 -1
  234. package/lib/dataStores.d.ts +39 -12
  235. package/lib/dataStores.d.ts.map +1 -1
  236. package/lib/dataStores.js +162 -74
  237. package/lib/dataStores.js.map +1 -1
  238. package/lib/deltaManagerSummarizerProxy.d.ts +19 -0
  239. package/lib/deltaManagerSummarizerProxy.d.ts.map +1 -0
  240. package/lib/deltaManagerSummarizerProxy.js +36 -0
  241. package/lib/deltaManagerSummarizerProxy.js.map +1 -0
  242. package/lib/deltaScheduler.d.ts.map +1 -1
  243. package/lib/deltaScheduler.js +9 -4
  244. package/lib/deltaScheduler.js.map +1 -1
  245. package/lib/gc/garbageCollection.d.ts +204 -0
  246. package/lib/gc/garbageCollection.d.ts.map +1 -0
  247. package/lib/gc/garbageCollection.js +922 -0
  248. package/lib/gc/garbageCollection.js.map +1 -0
  249. package/lib/gc/gcConfigs.d.ts +22 -0
  250. package/lib/gc/gcConfigs.d.ts.map +1 -0
  251. package/lib/gc/gcConfigs.js +139 -0
  252. package/lib/gc/gcConfigs.js.map +1 -0
  253. package/lib/gc/gcDefinitions.d.ts +320 -0
  254. package/lib/gc/gcDefinitions.d.ts.map +1 -0
  255. package/lib/gc/gcDefinitions.js +78 -0
  256. package/lib/gc/gcDefinitions.js.map +1 -0
  257. package/lib/gc/gcHelpers.d.ts +86 -0
  258. package/lib/gc/gcHelpers.d.ts.map +1 -0
  259. package/lib/gc/gcHelpers.js +254 -0
  260. package/lib/gc/gcHelpers.js.map +1 -0
  261. package/lib/gc/gcReferenceGraphAlgorithm.d.ts +16 -0
  262. package/lib/gc/gcReferenceGraphAlgorithm.d.ts.map +1 -0
  263. package/lib/gc/gcReferenceGraphAlgorithm.js +45 -0
  264. package/lib/gc/gcReferenceGraphAlgorithm.js.map +1 -0
  265. package/lib/gc/gcSummaryDefinitions.d.ts +52 -0
  266. package/lib/gc/gcSummaryDefinitions.d.ts.map +1 -0
  267. package/lib/gc/gcSummaryDefinitions.js +6 -0
  268. package/lib/gc/gcSummaryDefinitions.js.map +1 -0
  269. package/lib/gc/gcSummaryStateTracker.d.ts +93 -0
  270. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -0
  271. package/lib/gc/gcSummaryStateTracker.js +235 -0
  272. package/lib/gc/gcSummaryStateTracker.js.map +1 -0
  273. package/{dist → lib/gc}/gcSweepReadyUsageDetection.d.ts +5 -5
  274. package/lib/gc/gcSweepReadyUsageDetection.d.ts.map +1 -0
  275. package/lib/{gcSweepReadyUsageDetection.js → gc/gcSweepReadyUsageDetection.js} +15 -11
  276. package/lib/gc/gcSweepReadyUsageDetection.js.map +1 -0
  277. package/lib/gc/gcUnreferencedStateTracker.d.ts +34 -0
  278. package/lib/gc/gcUnreferencedStateTracker.d.ts.map +1 -0
  279. package/lib/gc/gcUnreferencedStateTracker.js +90 -0
  280. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -0
  281. package/lib/gc/index.d.ts +13 -0
  282. package/lib/gc/index.d.ts.map +1 -0
  283. package/lib/gc/index.js +12 -0
  284. package/lib/gc/index.js.map +1 -0
  285. package/lib/index.d.ts +3 -8
  286. package/lib/index.d.ts.map +1 -1
  287. package/lib/index.js +2 -6
  288. package/lib/index.js.map +1 -1
  289. package/lib/opLifecycle/batchManager.d.ts +10 -0
  290. package/lib/opLifecycle/batchManager.d.ts.map +1 -1
  291. package/lib/opLifecycle/batchManager.js +35 -7
  292. package/lib/opLifecycle/batchManager.js.map +1 -1
  293. package/lib/opLifecycle/definitions.d.ts +29 -1
  294. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  295. package/lib/opLifecycle/definitions.js.map +1 -1
  296. package/lib/opLifecycle/index.d.ts +3 -3
  297. package/lib/opLifecycle/index.d.ts.map +1 -1
  298. package/lib/opLifecycle/index.js +2 -2
  299. package/lib/opLifecycle/index.js.map +1 -1
  300. package/lib/opLifecycle/opCompressor.d.ts +1 -1
  301. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  302. package/lib/opLifecycle/opCompressor.js +47 -18
  303. package/lib/opLifecycle/opCompressor.js.map +1 -1
  304. package/lib/opLifecycle/opDecompressor.d.ts +6 -1
  305. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  306. package/lib/opLifecycle/opDecompressor.js +72 -18
  307. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  308. package/lib/opLifecycle/opSplitter.d.ts +46 -2
  309. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  310. package/lib/opLifecycle/opSplitter.js +141 -5
  311. package/lib/opLifecycle/opSplitter.js.map +1 -1
  312. package/lib/opLifecycle/outbox.d.ts +23 -2
  313. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  314. package/lib/opLifecycle/outbox.js +103 -53
  315. package/lib/opLifecycle/outbox.js.map +1 -1
  316. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  317. package/lib/opLifecycle/remoteMessageProcessor.js +17 -2
  318. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  319. package/lib/opProperties.d.ts.map +1 -1
  320. package/lib/opProperties.js +1 -3
  321. package/lib/opProperties.js.map +1 -1
  322. package/lib/packageVersion.d.ts +1 -1
  323. package/lib/packageVersion.js +1 -1
  324. package/lib/packageVersion.js.map +1 -1
  325. package/lib/pendingStateManager.d.ts +6 -15
  326. package/lib/pendingStateManager.d.ts.map +1 -1
  327. package/lib/pendingStateManager.js +137 -165
  328. package/lib/pendingStateManager.js.map +1 -1
  329. package/lib/scheduleManager.d.ts +0 -1
  330. package/lib/scheduleManager.d.ts.map +1 -1
  331. package/lib/scheduleManager.js +11 -21
  332. package/lib/scheduleManager.js.map +1 -1
  333. package/lib/storageServiceWithAttachBlobs.d.ts +17 -0
  334. package/lib/storageServiceWithAttachBlobs.d.ts.map +1 -0
  335. package/lib/storageServiceWithAttachBlobs.js +28 -0
  336. package/lib/storageServiceWithAttachBlobs.js.map +1 -0
  337. package/lib/summary/index.d.ts +17 -0
  338. package/lib/summary/index.d.ts.map +1 -0
  339. package/lib/summary/index.js +15 -0
  340. package/lib/summary/index.js.map +1 -0
  341. package/lib/summary/orderedClientElection.d.ts.map +1 -0
  342. package/lib/{orderedClientElection.js → summary/orderedClientElection.js} +10 -4
  343. package/lib/summary/orderedClientElection.js.map +1 -0
  344. package/{dist → lib/summary}/runWhileConnectedCoordinator.d.ts +3 -2
  345. package/lib/summary/runWhileConnectedCoordinator.d.ts.map +1 -0
  346. package/lib/{runWhileConnectedCoordinator.js → summary/runWhileConnectedCoordinator.js} +5 -4
  347. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -0
  348. package/{dist → lib/summary}/runningSummarizer.d.ts +19 -18
  349. package/lib/summary/runningSummarizer.d.ts.map +1 -0
  350. package/lib/{runningSummarizer.js → summary/runningSummarizer.js} +193 -79
  351. package/lib/summary/runningSummarizer.js.map +1 -0
  352. package/lib/{summarizer.d.ts → summary/summarizer.d.ts} +6 -12
  353. package/lib/summary/summarizer.d.ts.map +1 -0
  354. package/lib/{summarizer.js → summary/summarizer.js} +34 -78
  355. package/lib/summary/summarizer.js.map +1 -0
  356. package/lib/{summarizerClientElection.d.ts → summary/summarizerClientElection.d.ts} +1 -2
  357. package/lib/summary/summarizerClientElection.d.ts.map +1 -0
  358. package/lib/{summarizerClientElection.js → summary/summarizerClientElection.js} +3 -30
  359. package/lib/summary/summarizerClientElection.js.map +1 -0
  360. package/lib/{summarizerHeuristics.d.ts → summary/summarizerHeuristics.d.ts} +1 -1
  361. package/lib/summary/summarizerHeuristics.d.ts.map +1 -0
  362. package/lib/{summarizerHeuristics.js → summary/summarizerHeuristics.js} +9 -12
  363. package/lib/summary/summarizerHeuristics.js.map +1 -0
  364. package/lib/summary/summarizerNode/index.d.ts +8 -0
  365. package/lib/summary/summarizerNode/index.d.ts.map +1 -0
  366. package/lib/summary/summarizerNode/index.js +7 -0
  367. package/lib/summary/summarizerNode/index.js.map +1 -0
  368. package/lib/summary/summarizerNode/summarizerNode.d.ts +149 -0
  369. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -0
  370. package/lib/summary/summarizerNode/summarizerNode.js +526 -0
  371. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -0
  372. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +125 -0
  373. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -0
  374. package/lib/summary/summarizerNode/summarizerNodeUtils.js +125 -0
  375. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -0
  376. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +22 -0
  377. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -0
  378. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +419 -0
  379. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -0
  380. package/{dist → lib/summary}/summarizerTypes.d.ts +29 -42
  381. package/lib/summary/summarizerTypes.d.ts.map +1 -0
  382. package/lib/summary/summarizerTypes.js +6 -0
  383. package/lib/summary/summarizerTypes.js.map +1 -0
  384. package/lib/summary/summaryCollection.d.ts.map +1 -0
  385. package/lib/{summaryCollection.js → summary/summaryCollection.js} +18 -8
  386. package/lib/summary/summaryCollection.js.map +1 -0
  387. package/{dist → lib/summary}/summaryFormat.d.ts +3 -21
  388. package/lib/summary/summaryFormat.d.ts.map +1 -0
  389. package/lib/{summaryFormat.js → summary/summaryFormat.js} +20 -21
  390. package/lib/summary/summaryFormat.js.map +1 -0
  391. package/lib/summary/summaryGenerator.d.ts.map +1 -0
  392. package/lib/{summaryGenerator.js → summary/summaryGenerator.js} +34 -16
  393. package/lib/summary/summaryGenerator.js.map +1 -0
  394. package/lib/{summaryManager.d.ts → summary/summaryManager.d.ts} +1 -1
  395. package/lib/summary/summaryManager.d.ts.map +1 -0
  396. package/lib/{summaryManager.js → summary/summaryManager.js} +21 -9
  397. package/lib/summary/summaryManager.js.map +1 -0
  398. package/lib/throttler.d.ts +2 -2
  399. package/lib/throttler.d.ts.map +1 -1
  400. package/lib/throttler.js +4 -4
  401. package/lib/throttler.js.map +1 -1
  402. package/package.json +67 -61
  403. package/prettier.config.cjs +1 -1
  404. package/src/batchTracker.ts +55 -50
  405. package/src/blobManager.ts +863 -594
  406. package/src/connectionTelemetry.ts +280 -249
  407. package/src/containerHandleContext.ts +27 -29
  408. package/src/containerRuntime.ts +3174 -2805
  409. package/src/dataStore.ts +172 -159
  410. package/src/dataStoreContext.ts +1141 -993
  411. package/src/dataStoreContexts.ts +178 -161
  412. package/src/dataStoreRegistry.ts +25 -20
  413. package/src/dataStores.ts +887 -716
  414. package/src/deltaManagerSummarizerProxy.ts +46 -0
  415. package/src/deltaScheduler.ts +158 -150
  416. package/{garbageCollection.md → src/gc/garbageCollection.md} +16 -3
  417. package/src/gc/garbageCollection.ts +1250 -0
  418. package/src/gc/gcConfigs.ts +193 -0
  419. package/src/gc/gcDefinitions.ts +387 -0
  420. package/src/gc/gcHelpers.ts +332 -0
  421. package/src/gc/gcReferenceGraphAlgorithm.ts +52 -0
  422. package/src/gc/gcSummaryDefinitions.ts +54 -0
  423. package/src/gc/gcSummaryStateTracker.ts +329 -0
  424. package/src/gc/gcSweepReadyUsageDetection.ts +145 -0
  425. package/src/gc/gcUnreferencedStateTracker.ts +114 -0
  426. package/src/gc/index.ts +65 -0
  427. package/src/index.ts +61 -75
  428. package/src/opLifecycle/README.md +157 -0
  429. package/src/opLifecycle/batchManager.ts +119 -86
  430. package/src/opLifecycle/definitions.ts +49 -19
  431. package/src/opLifecycle/index.ts +7 -6
  432. package/src/opLifecycle/opCompressor.ts +78 -40
  433. package/src/opLifecycle/opDecompressor.ts +148 -64
  434. package/src/opLifecycle/opSplitter.ts +269 -66
  435. package/src/opLifecycle/outbox.ts +268 -184
  436. package/src/opLifecycle/remoteMessageProcessor.ts +63 -47
  437. package/src/opProperties.ts +11 -9
  438. package/src/packageVersion.ts +1 -1
  439. package/src/pendingStateManager.ts +386 -381
  440. package/src/scheduleManager.ts +299 -280
  441. package/src/storageServiceWithAttachBlobs.ts +38 -0
  442. package/src/summary/index.ts +105 -0
  443. package/src/summary/orderedClientElection.ts +564 -0
  444. package/src/summary/runWhileConnectedCoordinator.ts +113 -0
  445. package/src/summary/runningSummarizer.ts +788 -0
  446. package/src/summary/summarizer.ts +372 -0
  447. package/src/summary/summarizerClientElection.ts +139 -0
  448. package/src/summary/summarizerHeuristics.ts +224 -0
  449. package/src/summary/summarizerNode/index.ts +12 -0
  450. package/src/summary/summarizerNode/summarizerNode.ts +766 -0
  451. package/src/summary/summarizerNode/summarizerNodeUtils.ts +214 -0
  452. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +644 -0
  453. package/src/summary/summarizerTypes.ts +507 -0
  454. package/src/summary/summaryCollection.ts +450 -0
  455. package/src/summary/summaryFormat.ts +228 -0
  456. package/src/summary/summaryGenerator.ts +505 -0
  457. package/src/summary/summaryManager.ts +423 -0
  458. package/src/throttler.ts +131 -122
  459. package/tsconfig.esnext.json +6 -6
  460. package/tsconfig.json +9 -13
  461. package/dist/garbageCollection.d.ts +0 -387
  462. package/dist/garbageCollection.d.ts.map +0 -1
  463. package/dist/garbageCollection.js +0 -1138
  464. package/dist/garbageCollection.js.map +0 -1
  465. package/dist/garbageCollectionConstants.d.ts +0 -19
  466. package/dist/garbageCollectionConstants.d.ts.map +0 -1
  467. package/dist/garbageCollectionConstants.js +0 -34
  468. package/dist/garbageCollectionConstants.js.map +0 -1
  469. package/dist/gcSweepReadyUsageDetection.d.ts.map +0 -1
  470. package/dist/gcSweepReadyUsageDetection.js.map +0 -1
  471. package/dist/orderedClientElection.d.ts.map +0 -1
  472. package/dist/orderedClientElection.js.map +0 -1
  473. package/dist/runWhileConnectedCoordinator.d.ts.map +0 -1
  474. package/dist/runWhileConnectedCoordinator.js.map +0 -1
  475. package/dist/runningSummarizer.d.ts.map +0 -1
  476. package/dist/runningSummarizer.js.map +0 -1
  477. package/dist/serializedSnapshotStorage.d.ts +0 -58
  478. package/dist/serializedSnapshotStorage.d.ts.map +0 -1
  479. package/dist/serializedSnapshotStorage.js +0 -108
  480. package/dist/serializedSnapshotStorage.js.map +0 -1
  481. package/dist/summarizer.d.ts.map +0 -1
  482. package/dist/summarizer.js.map +0 -1
  483. package/dist/summarizerClientElection.d.ts.map +0 -1
  484. package/dist/summarizerClientElection.js.map +0 -1
  485. package/dist/summarizerHandle.d.ts +0 -12
  486. package/dist/summarizerHandle.d.ts.map +0 -1
  487. package/dist/summarizerHandle.js +0 -22
  488. package/dist/summarizerHandle.js.map +0 -1
  489. package/dist/summarizerHeuristics.d.ts.map +0 -1
  490. package/dist/summarizerHeuristics.js.map +0 -1
  491. package/dist/summarizerTypes.d.ts.map +0 -1
  492. package/dist/summarizerTypes.js.map +0 -1
  493. package/dist/summaryCollection.d.ts.map +0 -1
  494. package/dist/summaryCollection.js.map +0 -1
  495. package/dist/summaryFormat.d.ts.map +0 -1
  496. package/dist/summaryFormat.js.map +0 -1
  497. package/dist/summaryGenerator.d.ts.map +0 -1
  498. package/dist/summaryGenerator.js.map +0 -1
  499. package/dist/summaryManager.d.ts.map +0 -1
  500. package/dist/summaryManager.js.map +0 -1
  501. package/lib/garbageCollection.d.ts +0 -387
  502. package/lib/garbageCollection.d.ts.map +0 -1
  503. package/lib/garbageCollection.js +0 -1133
  504. package/lib/garbageCollection.js.map +0 -1
  505. package/lib/garbageCollectionConstants.d.ts +0 -19
  506. package/lib/garbageCollectionConstants.d.ts.map +0 -1
  507. package/lib/garbageCollectionConstants.js +0 -31
  508. package/lib/garbageCollectionConstants.js.map +0 -1
  509. package/lib/gcSweepReadyUsageDetection.d.ts.map +0 -1
  510. package/lib/gcSweepReadyUsageDetection.js.map +0 -1
  511. package/lib/orderedClientElection.d.ts.map +0 -1
  512. package/lib/orderedClientElection.js.map +0 -1
  513. package/lib/runWhileConnectedCoordinator.d.ts.map +0 -1
  514. package/lib/runWhileConnectedCoordinator.js.map +0 -1
  515. package/lib/runningSummarizer.d.ts.map +0 -1
  516. package/lib/runningSummarizer.js.map +0 -1
  517. package/lib/serializedSnapshotStorage.d.ts +0 -58
  518. package/lib/serializedSnapshotStorage.d.ts.map +0 -1
  519. package/lib/serializedSnapshotStorage.js +0 -104
  520. package/lib/serializedSnapshotStorage.js.map +0 -1
  521. package/lib/summarizer.d.ts.map +0 -1
  522. package/lib/summarizer.js.map +0 -1
  523. package/lib/summarizerClientElection.d.ts.map +0 -1
  524. package/lib/summarizerClientElection.js.map +0 -1
  525. package/lib/summarizerHandle.d.ts +0 -12
  526. package/lib/summarizerHandle.d.ts.map +0 -1
  527. package/lib/summarizerHandle.js +0 -18
  528. package/lib/summarizerHandle.js.map +0 -1
  529. package/lib/summarizerHeuristics.d.ts.map +0 -1
  530. package/lib/summarizerHeuristics.js.map +0 -1
  531. package/lib/summarizerTypes.d.ts.map +0 -1
  532. package/lib/summarizerTypes.js +0 -9
  533. package/lib/summarizerTypes.js.map +0 -1
  534. package/lib/summaryCollection.d.ts.map +0 -1
  535. package/lib/summaryCollection.js.map +0 -1
  536. package/lib/summaryFormat.d.ts.map +0 -1
  537. package/lib/summaryFormat.js.map +0 -1
  538. package/lib/summaryGenerator.d.ts.map +0 -1
  539. package/lib/summaryGenerator.js.map +0 -1
  540. package/lib/summaryManager.d.ts.map +0 -1
  541. package/lib/summaryManager.js.map +0 -1
  542. package/src/garbageCollection.ts +0 -1646
  543. package/src/garbageCollectionConstants.ts +0 -35
  544. package/src/gcSweepReadyUsageDetection.ts +0 -139
  545. package/src/orderedClientElection.ts +0 -532
  546. package/src/runWhileConnectedCoordinator.ts +0 -106
  547. package/src/runningSummarizer.ts +0 -611
  548. package/src/serializedSnapshotStorage.ts +0 -146
  549. package/src/summarizer.ts +0 -421
  550. package/src/summarizerClientElection.ts +0 -161
  551. package/src/summarizerHandle.ts +0 -21
  552. package/src/summarizerHeuristics.ts +0 -222
  553. package/src/summarizerTypes.ts +0 -510
  554. package/src/summaryCollection.ts +0 -421
  555. package/src/summaryFormat.ts +0 -235
  556. package/src/summaryGenerator.ts +0 -446
  557. package/src/summaryManager.ts +0 -394
  558. /package/dist/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
  559. /package/dist/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
  560. /package/dist/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +0 -0
  561. /package/lib/{orderedClientElection.d.ts → summary/orderedClientElection.d.ts} +0 -0
  562. /package/lib/{summaryCollection.d.ts → summary/summaryCollection.d.ts} +0 -0
  563. /package/lib/{summaryGenerator.d.ts → summary/summaryGenerator.d.ts} +0 -0
@@ -3,202 +3,286 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { ITelemetryLogger } from "@fluidframework/common-definitions";
6
7
  import { assert } from "@fluidframework/common-utils";
7
8
  import { IContainerContext } from "@fluidframework/container-definitions";
8
- import { GenericError } from "@fluidframework/container-utils";
9
+ import { GenericError, UsageError } from "@fluidframework/container-utils";
9
10
  import { MessageType } from "@fluidframework/protocol-definitions";
11
+ import {
12
+ ChildLogger,
13
+ loggerToMonitoringContext,
14
+ MonitoringContext,
15
+ } from "@fluidframework/telemetry-utils";
10
16
  import { ICompressionRuntimeOptions } from "../containerRuntime";
11
17
  import { PendingStateManager } from "../pendingStateManager";
12
- import { BatchManager } from "./batchManager";
18
+ import { BatchManager, estimateSocketSize } from "./batchManager";
13
19
  import { BatchMessage, IBatch } from "./definitions";
14
20
  import { OpCompressor } from "./opCompressor";
21
+ import { OpSplitter } from "./opSplitter";
15
22
 
16
23
  export interface IOutboxConfig {
17
- readonly compressionOptions: ICompressionRuntimeOptions;
18
- // The maximum size of a batch that we can send over the wire.
19
- readonly maxBatchSizeInBytes: number;
20
- };
24
+ readonly compressionOptions: ICompressionRuntimeOptions;
25
+ // The maximum size of a batch that we can send over the wire.
26
+ readonly maxBatchSizeInBytes: number;
27
+ readonly disablePartialFlush: boolean;
28
+ }
21
29
 
22
30
  export interface IOutboxParameters {
23
- readonly shouldSend: () => boolean,
24
- readonly pendingStateManager: PendingStateManager,
25
- readonly containerContext: IContainerContext,
26
- readonly config: IOutboxConfig,
27
- readonly compressor: OpCompressor;
31
+ readonly shouldSend: () => boolean;
32
+ readonly pendingStateManager: PendingStateManager;
33
+ readonly containerContext: IContainerContext;
34
+ readonly config: IOutboxConfig;
35
+ readonly compressor: OpCompressor;
36
+ readonly splitter: OpSplitter;
37
+ readonly logger: ITelemetryLogger;
28
38
  }
29
39
 
30
40
  export class Outbox {
31
- private readonly attachFlowBatch: BatchManager;
32
- private readonly mainBatch: BatchManager;
33
- private readonly defaultAttachFlowSoftLimitInBytes = 64 * 1024;
34
-
35
- constructor(private readonly params: IOutboxParameters) {
36
- const isCompressionEnabled = this.params.config.compressionOptions.minimumBatchSizeInBytes !== Number.POSITIVE_INFINITY;
37
- // We need to allow infinite size batches if we enable compression
38
- const hardLimit = isCompressionEnabled ? Infinity : this.params.config.maxBatchSizeInBytes;
39
- const softLimit = isCompressionEnabled ? Infinity : this.defaultAttachFlowSoftLimitInBytes;
40
-
41
- this.attachFlowBatch = new BatchManager({
42
- hardLimit,
43
- softLimit,
44
- });
45
- this.mainBatch = new BatchManager({
46
- hardLimit
47
- });
48
- }
49
-
50
- public get isEmpty(): boolean {
51
- return this.attachFlowBatch.length === 0 && this.mainBatch.length === 0;
52
- }
53
-
54
- public submit(message: BatchMessage) {
55
- if (!this.mainBatch.push(message)) {
56
- throw new GenericError(
57
- "BatchTooLarge",
58
- /* error */ undefined,
59
- {
60
- opSize: (message.contents?.length) ?? 0,
61
- count: this.mainBatch.length,
62
- limit: this.mainBatch.options.hardLimit,
63
- });
64
- }
65
- }
66
-
67
- public submitAttach(message: BatchMessage) {
68
- if (!this.attachFlowBatch.push(message)) {
69
- // BatchManager has two limits - soft limit & hard limit. Soft limit is only engaged
70
- // when queue is not empty.
71
- // Flush queue & retry. Failure on retry would mean - single message is bigger than hard limit
72
- this.flushInternal(this.attachFlowBatch.popBatch());
73
- if (!this.attachFlowBatch.push(message)) {
74
- throw new GenericError(
75
- "BatchTooLarge",
76
- /* error */ undefined,
77
- {
78
- opSize: (message.contents?.length) ?? 0,
79
- count: this.attachFlowBatch.length,
80
- limit: this.attachFlowBatch.options.hardLimit,
81
- });
82
- }
83
- }
84
-
85
- // If compression is enabled, we will always successfully receive
86
- // attach ops and compress then send them at the next JS turn, regardless
87
- // of the overall size of the accumulated ops in the batch.
88
- // However, it is more efficient to flush these ops faster, preferably
89
- // after they reach a size which would benefit from compression.
90
- if (this.attachFlowBatch.contentSizeInBytes >= this.params.config.compressionOptions.minimumBatchSizeInBytes) {
91
- this.flushInternal(this.attachFlowBatch.popBatch());
92
- }
93
- }
94
-
95
- public flush() {
96
- this.flushInternal(this.attachFlowBatch.popBatch());
97
- this.flushInternal(this.mainBatch.popBatch());
98
- }
99
-
100
- private flushInternal(rawBatch: IBatch) {
101
- const processedBatch = this.compressBatch(rawBatch);
102
- const clientSequenceNumber = this.sendBatch(processedBatch);
103
-
104
- this.persistBatch(clientSequenceNumber, rawBatch.content);
105
- }
106
-
107
- private compressBatch(batch: IBatch): IBatch {
108
- if (batch.content.length === 0
109
- || this.params.config.compressionOptions === undefined
110
- || this.params.config.compressionOptions.minimumBatchSizeInBytes > batch.contentSizeInBytes) {
111
- // Nothing to do if the batch is empty or if compression is disabled or if we don't need to compress
112
- return batch;
113
- }
114
-
115
- const compressedBatch = this.params.compressor.compressBatch(batch);
116
- if (compressedBatch.contentSizeInBytes > this.params.config.maxBatchSizeInBytes) {
117
- throw new GenericError(
118
- "BatchTooLarge",
119
- /* error */ undefined,
120
- {
121
- opSize: batch.contentSizeInBytes,
122
- count: batch.content.length,
123
- limit: this.params.config.maxBatchSizeInBytes,
124
- compressed: true,
125
- });
126
- }
127
-
128
- // If we don't reach the maximum supported size of a batch, it safe to be sent as is
129
- return compressedBatch;
130
- }
131
-
132
- /**
133
- * Sends the batch object to the container context to be sent over the wire.
134
- *
135
- * @param batch - batch to be sent
136
- * @returns the client sequence number of the last batched op which was sent and
137
- * -1 if there are no ops or the container cannot send ops.
138
- */
139
- private sendBatch(batch: IBatch): number {
140
- let clientSequenceNumber: number = -1;
141
- const length = batch.content.length;
142
-
143
- // Did we disconnect in the middle of turn-based batch?
144
- // If so, do nothing, as pending state manager will resubmit it correctly on reconnect.
145
- if (length === 0 || !this.params.shouldSend()) {
146
- return clientSequenceNumber;
147
- }
148
-
149
- if (this.params.containerContext.submitBatchFn === undefined) {
150
- // Legacy path - supporting old loader versions. Can be removed only when LTS moves above
151
- // version that has support for batches (submitBatchFn)
152
- for (const message of batch.content) {
153
- // Legacy path doesn't support compressed payloads and will submit uncompressed payload anyways
154
- if (message.metadata?.compressed) {
155
- delete message.metadata.compressed;
156
- }
157
-
158
- clientSequenceNumber = this.params.containerContext.submitFn(
159
- MessageType.Operation,
160
- message.deserializedContent,
161
- true, // batch
162
- message.metadata);
163
- }
164
-
165
- this.params.containerContext.deltaManager.flush();
166
- } else {
167
- // returns clientSequenceNumber of last message in a batch
168
- clientSequenceNumber = this.params.containerContext.submitBatchFn(
169
- batch.content.map((message) => ({ contents: message.contents, metadata: message.metadata })));
170
- }
171
-
172
- // Convert from clientSequenceNumber of last message in the batch to clientSequenceNumber of first message.
173
- clientSequenceNumber -= length - 1;
174
- assert(clientSequenceNumber >= 0, 0x3d0 /* clientSequenceNumber can't be negative */);
175
- return clientSequenceNumber;
176
- }
177
-
178
- private persistBatch(initialClientSequenceNumber: number, batch: BatchMessage[]) {
179
- let clientSequenceNumber = initialClientSequenceNumber;
180
- // Let the PendingStateManager know that a message was submitted.
181
- // In future, need to shift toward keeping batch as a whole!
182
- for (const message of batch) {
183
- this.params.pendingStateManager.onSubmitMessage(
184
- message.deserializedContent.type,
185
- clientSequenceNumber,
186
- message.referenceSequenceNumber,
187
- message.deserializedContent.contents,
188
- message.localOpMetadata,
189
- message.metadata,
190
- );
191
-
192
- clientSequenceNumber++;
193
- }
194
-
195
- this.params.pendingStateManager.onFlush();
196
- }
197
-
198
- public checkpoint() {
199
- return {
200
- mainBatch: this.mainBatch.checkpoint(),
201
- attachFlowBatch: this.attachFlowBatch.checkpoint(),
202
- };
203
- }
41
+ private readonly mc: MonitoringContext;
42
+ private readonly attachFlowBatch: BatchManager;
43
+ private readonly mainBatch: BatchManager;
44
+ private readonly defaultAttachFlowSoftLimitInBytes = 320 * 1024;
45
+
46
+ /**
47
+ * Track the number of ops which were detected to have a mismatched
48
+ * reference sequence number, in order to self-throttle the telemetry events.
49
+ *
50
+ * This should be removed as part of ADO:2322
51
+ */
52
+ private readonly maxMismatchedOpsToReport = 3;
53
+ private mismatchedOpsReported = 0;
54
+
55
+ constructor(private readonly params: IOutboxParameters) {
56
+ this.mc = loggerToMonitoringContext(ChildLogger.create(params.logger, "Outbox"));
57
+ const isCompressionEnabled =
58
+ this.params.config.compressionOptions.minimumBatchSizeInBytes !==
59
+ Number.POSITIVE_INFINITY;
60
+ // We need to allow infinite size batches if we enable compression
61
+ const hardLimit = isCompressionEnabled ? Infinity : this.params.config.maxBatchSizeInBytes;
62
+ const softLimit = isCompressionEnabled ? Infinity : this.defaultAttachFlowSoftLimitInBytes;
63
+
64
+ this.attachFlowBatch = new BatchManager({ hardLimit, softLimit });
65
+ this.mainBatch = new BatchManager({ hardLimit });
66
+ }
67
+
68
+ public get isEmpty(): boolean {
69
+ return this.attachFlowBatch.length === 0 && this.mainBatch.length === 0;
70
+ }
71
+
72
+ /**
73
+ * If we detect that the reference sequence number of the incoming message does not match
74
+ * what was already in the batch managers, this means that batching has been interrupted so
75
+ * we will flush the accumulated messages to account for that and create a new batch with the new
76
+ * message as the first message.
77
+ *
78
+ * @param message - the incoming message
79
+ */
80
+ private maybeFlushPartialBatch(message: BatchMessage) {
81
+ const mainBatchReference = this.mainBatch.referenceSequenceNumber;
82
+ const attachFlowBatchReference = this.attachFlowBatch.referenceSequenceNumber;
83
+ assert(
84
+ this.params.config.disablePartialFlush ||
85
+ mainBatchReference === undefined ||
86
+ attachFlowBatchReference === undefined ||
87
+ mainBatchReference === attachFlowBatchReference,
88
+ 0x58d /* Reference sequence numbers from both batches must be in sync */,
89
+ );
90
+
91
+ if (
92
+ (mainBatchReference === undefined ||
93
+ mainBatchReference === message.referenceSequenceNumber) &&
94
+ (attachFlowBatchReference === undefined ||
95
+ attachFlowBatchReference === message.referenceSequenceNumber)
96
+ ) {
97
+ // The reference sequence numbers are stable, there is nothing to do
98
+ return;
99
+ }
100
+
101
+ if (++this.mismatchedOpsReported <= this.maxMismatchedOpsToReport) {
102
+ this.mc.logger.sendErrorEvent(
103
+ {
104
+ eventName: "ReferenceSequenceNumberMismatch",
105
+ mainReferenceSequenceNumber: mainBatchReference,
106
+ attachReferenceSequenceNumber: attachFlowBatchReference,
107
+ messageReferenceSequenceNumber: message.referenceSequenceNumber,
108
+ },
109
+ new UsageError("Submission of an out of order message"),
110
+ );
111
+ }
112
+
113
+ if (!this.params.config.disablePartialFlush) {
114
+ this.flush();
115
+ }
116
+ }
117
+
118
+ public submit(message: BatchMessage) {
119
+ this.maybeFlushPartialBatch(message);
120
+
121
+ if (!this.mainBatch.push(message)) {
122
+ throw new GenericError("BatchTooLarge", /* error */ undefined, {
123
+ opSize: message.contents?.length ?? 0,
124
+ batchSize: this.mainBatch.contentSizeInBytes,
125
+ count: this.mainBatch.length,
126
+ limit: this.mainBatch.options.hardLimit,
127
+ });
128
+ }
129
+ }
130
+
131
+ public submitAttach(message: BatchMessage) {
132
+ this.maybeFlushPartialBatch(message);
133
+
134
+ if (!this.attachFlowBatch.push(message)) {
135
+ // BatchManager has two limits - soft limit & hard limit. Soft limit is only engaged
136
+ // when queue is not empty.
137
+ // Flush queue & retry. Failure on retry would mean - single message is bigger than hard limit
138
+ this.flushInternal(this.attachFlowBatch.popBatch());
139
+ if (!this.attachFlowBatch.push(message)) {
140
+ throw new GenericError("BatchTooLarge", /* error */ undefined, {
141
+ opSize: message.contents?.length ?? 0,
142
+ batchSize: this.attachFlowBatch.contentSizeInBytes,
143
+ count: this.attachFlowBatch.length,
144
+ limit: this.attachFlowBatch.options.hardLimit,
145
+ });
146
+ }
147
+ }
148
+
149
+ // If compression is enabled, we will always successfully receive
150
+ // attach ops and compress then send them at the next JS turn, regardless
151
+ // of the overall size of the accumulated ops in the batch.
152
+ // However, it is more efficient to flush these ops faster, preferably
153
+ // after they reach a size which would benefit from compression.
154
+ if (
155
+ this.attachFlowBatch.contentSizeInBytes >=
156
+ this.params.config.compressionOptions.minimumBatchSizeInBytes
157
+ ) {
158
+ this.flushInternal(this.attachFlowBatch.popBatch());
159
+ }
160
+ }
161
+
162
+ public flush() {
163
+ this.flushInternal(this.attachFlowBatch.popBatch());
164
+ this.flushInternal(this.mainBatch.popBatch());
165
+ }
166
+
167
+ private flushInternal(rawBatch: IBatch) {
168
+ const processedBatch = this.compressBatch(rawBatch);
169
+ this.sendBatch(processedBatch);
170
+
171
+ this.persistBatch(rawBatch.content);
172
+ }
173
+
174
+ private compressBatch(batch: IBatch): IBatch {
175
+ if (
176
+ batch.content.length === 0 ||
177
+ this.params.config.compressionOptions === undefined ||
178
+ this.params.config.compressionOptions.minimumBatchSizeInBytes >
179
+ batch.contentSizeInBytes ||
180
+ this.params.containerContext.submitBatchFn === undefined
181
+ ) {
182
+ // Nothing to do if the batch is empty or if compression is disabled or not supported, or if we don't need to compress
183
+ return batch;
184
+ }
185
+
186
+ const compressedBatch = this.params.compressor.compressBatch(batch);
187
+
188
+ if (this.params.splitter.isBatchChunkingEnabled) {
189
+ return compressedBatch.contentSizeInBytes <= this.params.splitter.chunkSizeInBytes
190
+ ? compressedBatch
191
+ : this.params.splitter.splitCompressedBatch(compressedBatch);
192
+ }
193
+
194
+ if (compressedBatch.contentSizeInBytes >= this.params.config.maxBatchSizeInBytes) {
195
+ throw new GenericError("BatchTooLarge", /* error */ undefined, {
196
+ batchSize: batch.contentSizeInBytes,
197
+ compressedBatchSize: compressedBatch.contentSizeInBytes,
198
+ count: compressedBatch.content.length,
199
+ limit: this.params.config.maxBatchSizeInBytes,
200
+ chunkingEnabled: this.params.splitter.isBatchChunkingEnabled,
201
+ compressionOptions: JSON.stringify(this.params.config.compressionOptions),
202
+ socketSize: estimateSocketSize(batch),
203
+ });
204
+ }
205
+
206
+ return compressedBatch;
207
+ }
208
+
209
+ /**
210
+ * Sends the batch object to the container context to be sent over the wire.
211
+ *
212
+ * @param batch - batch to be sent
213
+ */
214
+ private sendBatch(batch: IBatch) {
215
+ const length = batch.content.length;
216
+
217
+ // Did we disconnect in the middle of turn-based batch?
218
+ // If so, do nothing, as pending state manager will resubmit it correctly on reconnect.
219
+ if (length === 0 || !this.params.shouldSend()) {
220
+ return;
221
+ }
222
+
223
+ const socketSize = estimateSocketSize(batch);
224
+ if (socketSize >= this.params.config.maxBatchSizeInBytes) {
225
+ this.mc.logger.sendPerformanceEvent({
226
+ eventName: "LargeBatch",
227
+ length: batch.content.length,
228
+ sizeInBytes: batch.contentSizeInBytes,
229
+ socketSize,
230
+ });
231
+ }
232
+
233
+ if (this.params.containerContext.submitBatchFn === undefined) {
234
+ // Legacy path - supporting old loader versions. Can be removed only when LTS moves above
235
+ // version that has support for batches (submitBatchFn)
236
+ assert(
237
+ batch.content[0].compression === undefined,
238
+ 0x5a6 /* Compression should not have happened if the loader does not support it */,
239
+ );
240
+
241
+ for (const message of batch.content) {
242
+ this.params.containerContext.submitFn(
243
+ MessageType.Operation,
244
+ message.deserializedContent,
245
+ true, // batch
246
+ message.metadata,
247
+ );
248
+ }
249
+
250
+ this.params.containerContext.deltaManager.flush();
251
+ } else {
252
+ assert(
253
+ batch.referenceSequenceNumber !== undefined,
254
+ 0x58e /* Batch must not be empty */,
255
+ );
256
+ this.params.containerContext.submitBatchFn(
257
+ batch.content.map((message) => ({
258
+ contents: message.contents,
259
+ metadata: message.metadata,
260
+ compression: message.compression,
261
+ referenceSequenceNumber: message.referenceSequenceNumber,
262
+ })),
263
+ batch.referenceSequenceNumber,
264
+ );
265
+ }
266
+ }
267
+
268
+ private persistBatch(batch: BatchMessage[]) {
269
+ // Let the PendingStateManager know that a message was submitted.
270
+ // In future, need to shift toward keeping batch as a whole!
271
+ for (const message of batch) {
272
+ this.params.pendingStateManager.onSubmitMessage(
273
+ message.deserializedContent.type,
274
+ message.referenceSequenceNumber,
275
+ message.deserializedContent.contents,
276
+ message.localOpMetadata,
277
+ message.metadata,
278
+ );
279
+ }
280
+ }
281
+
282
+ public checkpoint() {
283
+ return {
284
+ mainBatch: this.mainBatch.checkpoint(),
285
+ attachFlowBatch: this.attachFlowBatch.checkpoint(),
286
+ };
287
+ }
204
288
  }
@@ -9,45 +9,61 @@ import { OpDecompressor } from "./opDecompressor";
9
9
  import { OpSplitter } from "./opSplitter";
10
10
 
11
11
  export class RemoteMessageProcessor {
12
- constructor(
13
- private readonly opSplitter: OpSplitter,
14
- private readonly opDecompressor: OpDecompressor,
15
- ) { }
12
+ constructor(
13
+ private readonly opSplitter: OpSplitter,
14
+ private readonly opDecompressor: OpDecompressor,
15
+ ) {}
16
16
 
17
- public get partialMessages(): ReadonlyMap<string, string[]> {
18
- return this.opSplitter.chunks;
19
- }
17
+ public get partialMessages(): ReadonlyMap<string, string[]> {
18
+ return this.opSplitter.chunks;
19
+ }
20
20
 
21
- public clearPartialMessagesFor(clientId: string) {
22
- this.opSplitter.clearPartialChunks(clientId);
23
- }
21
+ public clearPartialMessagesFor(clientId: string) {
22
+ this.opSplitter.clearPartialChunks(clientId);
23
+ }
24
24
 
25
- public process(remoteMessage: ISequencedDocumentMessage): ISequencedDocumentMessage {
26
- let message = copy(remoteMessage);
25
+ public process(remoteMessage: ISequencedDocumentMessage): ISequencedDocumentMessage {
26
+ let message = copy(remoteMessage);
27
+ message = this.opDecompressor.processMessage(message).message;
28
+ unpackRuntimeMessage(message);
27
29
 
28
- message = this.opDecompressor.processMessage(message);
29
- unpackRuntimeMessage(message);
30
- message = this.opSplitter.processRemoteMessage(message);
30
+ const chunkProcessingResult = this.opSplitter.processRemoteMessage(message);
31
+ message = chunkProcessingResult.message;
32
+ if (chunkProcessingResult.state !== "Processed") {
33
+ // If the message is not chunked or if the splitter is still rebuilding the original message,
34
+ // there is no need to continue processing
35
+ return message;
36
+ }
31
37
 
32
- return message;
33
- }
38
+ const decompressionAfterChunking = this.opDecompressor.processMessage(message);
39
+ message = decompressionAfterChunking.message;
40
+ if (decompressionAfterChunking.state === "Skipped") {
41
+ // After chunking, if the original message was not compressed,
42
+ // there is no need to continue processing
43
+ return message;
44
+ }
45
+
46
+ // The message needs to be unpacked after chunking + decompression
47
+ unpack(message);
48
+ return message;
49
+ }
34
50
  }
35
51
 
36
52
  const copy = (remoteMessage: ISequencedDocumentMessage): ISequencedDocumentMessage => {
37
- // Do shallow copy of message, as the processing flow will modify it.
38
- // There might be multiple container instances receiving same message
39
- // We do not need to make deep copy, as each layer will just replace message.content itself,
40
- // but would not modify contents details
41
- const message = { ...remoteMessage };
53
+ // Do shallow copy of message, as the processing flow will modify it.
54
+ // There might be multiple container instances receiving same message
55
+ // We do not need to make deep copy, as each layer will just replace message.content itself,
56
+ // but would not modify contents details
57
+ const message = { ...remoteMessage };
42
58
 
43
- // back-compat: ADO #1385: eventually should become unconditional, but only for runtime messages!
44
- // System message may have no contents, or in some cases (mostly for back-compat) they may have actual objects.
45
- // Old ops may contain empty string (I assume noops).
46
- if (typeof message.contents === "string" && message.contents !== "") {
47
- message.contents = JSON.parse(message.contents);
48
- }
59
+ // back-compat: ADO #1385: eventually should become unconditional, but only for runtime messages!
60
+ // System message may have no contents, or in some cases (mostly for back-compat) they may have actual objects.
61
+ // Old ops may contain empty string (I assume noops).
62
+ if (typeof message.contents === "string" && message.contents !== "") {
63
+ message.contents = JSON.parse(message.contents);
64
+ }
49
65
 
50
- return message;
66
+ return message;
51
67
  };
52
68
 
53
69
  /**
@@ -55,9 +71,9 @@ const copy = (remoteMessage: ISequencedDocumentMessage): ISequencedDocumentMessa
55
71
  *
56
72
  */
57
73
  const unpack = (message: ISequencedDocumentMessage) => {
58
- const innerContents = message.contents as ContainerRuntimeMessage;
59
- message.type = innerContents.type;
60
- message.contents = innerContents.contents;
74
+ const innerContents = message.contents as ContainerRuntimeMessage;
75
+ message.type = innerContents.type;
76
+ message.contents = innerContents.contents;
61
77
  };
62
78
 
63
79
  /**
@@ -70,21 +86,21 @@ const unpack = (message: ISequencedDocumentMessage) => {
70
86
  * @internal
71
87
  */
72
88
  export function unpackRuntimeMessage(message: ISequencedDocumentMessage): boolean {
73
- if (message.type !== MessageType.Operation) {
74
- // Legacy format, but it's already "unpacked",
75
- // i.e. message.type is actually ContainerMessageType.
76
- // Or it's non-runtime message.
77
- // Nothing to do in such case.
78
- return false;
79
- }
89
+ if (message.type !== MessageType.Operation) {
90
+ // Legacy format, but it's already "unpacked",
91
+ // i.e. message.type is actually ContainerMessageType.
92
+ // Or it's non-runtime message.
93
+ // Nothing to do in such case.
94
+ return false;
95
+ }
80
96
 
81
- // legacy op format?
82
- if (message.contents.address !== undefined && message.contents.type === undefined) {
83
- message.type = ContainerMessageType.FluidDataStoreOp;
84
- } else {
85
- // new format
86
- unpack(message);
87
- }
97
+ // legacy op format?
98
+ if (message.contents.address !== undefined && message.contents.type === undefined) {
99
+ message.type = ContainerMessageType.FluidDataStoreOp;
100
+ } else {
101
+ // new format
102
+ unpack(message);
103
+ }
88
104
 
89
- return true;
105
+ return true;
90
106
  }
@@ -3,17 +3,19 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ISequencedDocumentMessage, ISequencedDocumentSystemMessage } from "@fluidframework/protocol-definitions";
6
+ import {
7
+ ISequencedDocumentMessage,
8
+ ISequencedDocumentSystemMessage,
9
+ } from "@fluidframework/protocol-definitions";
7
10
 
8
11
  export const opSize = (op: ISequencedDocumentMessage): number => {
9
- // Some messages may already have string contents,
10
- // so stringifying them again will add inaccurate overhead.
11
- const content = typeof op.contents === "string" ?
12
- op.contents :
13
- JSON.stringify(op.contents) ?? "";
14
- const data = opHasData(op) ? op.data : "";
15
- return content.length + data.length;
12
+ // Some messages may already have string contents,
13
+ // so stringifying them again will add inaccurate overhead.
14
+ const content =
15
+ typeof op.contents === "string" ? op.contents : JSON.stringify(op.contents) ?? "";
16
+ const data = opHasData(op) ? op.data : "";
17
+ return content.length + data.length;
16
18
  };
17
19
 
18
20
  const opHasData = (op: ISequencedDocumentMessage): op is ISequencedDocumentSystemMessage =>
19
- (op as ISequencedDocumentSystemMessage).data !== undefined;
21
+ (op as ISequencedDocumentSystemMessage).data !== undefined;
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/container-runtime";
9
- export const pkgVersion = "2.0.0-dev.2.3.0.115467";
9
+ export const pkgVersion = "2.0.0-dev.4.1.0.148229";