@fluidframework/container-runtime 2.0.0-dev-rc.5.0.0.265721 → 2.0.0-dev-rc.5.0.0.268409

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 (293) hide show
  1. package/api-report/{container-runtime.api.md → container-runtime.alpha.api.md} +13 -482
  2. package/api-report/container-runtime.beta.api.md +73 -0
  3. package/api-report/container-runtime.public.api.md +73 -0
  4. package/dist/batchTracker.js.map +1 -1
  5. package/dist/blobManager.d.ts +2 -2
  6. package/dist/blobManager.d.ts.map +1 -1
  7. package/dist/blobManager.js.map +1 -1
  8. package/dist/channelCollection.d.ts +3 -3
  9. package/dist/channelCollection.d.ts.map +1 -1
  10. package/dist/channelCollection.js.map +1 -1
  11. package/dist/connectionTelemetry.d.ts +2 -1
  12. package/dist/connectionTelemetry.d.ts.map +1 -1
  13. package/dist/connectionTelemetry.js +14 -14
  14. package/dist/connectionTelemetry.js.map +1 -1
  15. package/dist/containerRuntime.d.ts +2 -2
  16. package/dist/containerRuntime.d.ts.map +1 -1
  17. package/dist/containerRuntime.js +12 -16
  18. package/dist/containerRuntime.js.map +1 -1
  19. package/dist/dataStoreContext.d.ts +3 -4
  20. package/dist/dataStoreContext.d.ts.map +1 -1
  21. package/dist/dataStoreContext.js.map +1 -1
  22. package/dist/deltaManagerProxies.d.ts +4 -3
  23. package/dist/deltaManagerProxies.d.ts.map +1 -1
  24. package/dist/deltaManagerProxies.js.map +1 -1
  25. package/dist/deltaScheduler.d.ts +2 -1
  26. package/dist/deltaScheduler.d.ts.map +1 -1
  27. package/dist/deltaScheduler.js.map +1 -1
  28. package/dist/gc/garbageCollection.d.ts +0 -1
  29. package/dist/gc/garbageCollection.d.ts.map +1 -1
  30. package/dist/gc/garbageCollection.js +17 -20
  31. package/dist/gc/garbageCollection.js.map +1 -1
  32. package/dist/gc/gcConfigs.d.ts.map +1 -1
  33. package/dist/gc/gcConfigs.js +5 -19
  34. package/dist/gc/gcConfigs.js.map +1 -1
  35. package/dist/gc/gcDefinitions.d.ts +1 -10
  36. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  37. package/dist/gc/gcDefinitions.js +1 -3
  38. package/dist/gc/gcDefinitions.js.map +1 -1
  39. package/dist/gc/gcHelpers.d.ts +1 -1
  40. package/dist/gc/gcHelpers.d.ts.map +1 -1
  41. package/dist/gc/gcHelpers.js.map +1 -1
  42. package/dist/gc/gcSummaryStateTracker.d.ts +1 -34
  43. package/dist/gc/gcSummaryStateTracker.d.ts.map +1 -1
  44. package/dist/gc/gcSummaryStateTracker.js +9 -62
  45. package/dist/gc/gcSummaryStateTracker.js.map +1 -1
  46. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  47. package/dist/gc/gcTelemetry.js.map +1 -1
  48. package/dist/gc/index.d.ts +1 -1
  49. package/dist/gc/index.d.ts.map +1 -1
  50. package/dist/gc/index.js +1 -2
  51. package/dist/gc/index.js.map +1 -1
  52. package/dist/messageTypes.d.ts +1 -1
  53. package/dist/messageTypes.d.ts.map +1 -1
  54. package/dist/messageTypes.js.map +1 -1
  55. package/dist/opLifecycle/definitions.d.ts +2 -2
  56. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  57. package/dist/opLifecycle/definitions.js.map +1 -1
  58. package/dist/opLifecycle/opCompressor.d.ts +11 -1
  59. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  60. package/dist/opLifecycle/opCompressor.js +13 -2
  61. package/dist/opLifecycle/opCompressor.js.map +1 -1
  62. package/dist/opLifecycle/opDecompressor.d.ts +1 -1
  63. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  64. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  65. package/dist/opLifecycle/opGroupingManager.d.ts +10 -3
  66. package/dist/opLifecycle/opGroupingManager.d.ts.map +1 -1
  67. package/dist/opLifecycle/opGroupingManager.js +7 -0
  68. package/dist/opLifecycle/opGroupingManager.js.map +1 -1
  69. package/dist/opLifecycle/opSplitter.d.ts +4 -2
  70. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  71. package/dist/opLifecycle/opSplitter.js +12 -7
  72. package/dist/opLifecycle/opSplitter.js.map +1 -1
  73. package/dist/opLifecycle/outbox.d.ts +9 -0
  74. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  75. package/dist/opLifecycle/outbox.js +10 -1
  76. package/dist/opLifecycle/outbox.js.map +1 -1
  77. package/dist/opLifecycle/remoteMessageProcessor.d.ts +1 -1
  78. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  79. package/dist/opLifecycle/remoteMessageProcessor.js +2 -2
  80. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  81. package/dist/opProperties.d.ts +1 -1
  82. package/dist/opProperties.d.ts.map +1 -1
  83. package/dist/opProperties.js.map +1 -1
  84. package/dist/packageVersion.d.ts +1 -1
  85. package/dist/packageVersion.js +1 -1
  86. package/dist/packageVersion.js.map +1 -1
  87. package/dist/pendingStateManager.js.map +1 -1
  88. package/dist/scheduleManager.d.ts +2 -1
  89. package/dist/scheduleManager.d.ts.map +1 -1
  90. package/dist/scheduleManager.js.map +1 -1
  91. package/dist/summary/orderedClientElection.d.ts +1 -1
  92. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  93. package/dist/summary/orderedClientElection.js.map +1 -1
  94. package/dist/summary/runningSummarizer.d.ts +1 -1
  95. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  96. package/dist/summary/runningSummarizer.js +3 -4
  97. package/dist/summary/runningSummarizer.js.map +1 -1
  98. package/dist/summary/summarizerClientElection.d.ts +1 -1
  99. package/dist/summary/summarizerClientElection.d.ts.map +1 -1
  100. package/dist/summary/summarizerClientElection.js +2 -2
  101. package/dist/summary/summarizerClientElection.js.map +1 -1
  102. package/dist/summary/summarizerNode/summarizerNode.d.ts +2 -1
  103. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  104. package/dist/summary/summarizerNode/summarizerNode.js +16 -16
  105. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  106. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +2 -1
  107. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  108. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  109. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +1 -1
  110. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  111. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +1 -1
  112. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  113. package/dist/summary/summarizerTypes.d.ts +2 -3
  114. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  115. package/dist/summary/summarizerTypes.js.map +1 -1
  116. package/dist/summary/summaryCollection.d.ts +2 -1
  117. package/dist/summary/summaryCollection.d.ts.map +1 -1
  118. package/dist/summary/summaryCollection.js +9 -9
  119. package/dist/summary/summaryCollection.js.map +1 -1
  120. package/dist/summary/summaryFormat.d.ts +2 -2
  121. package/dist/summary/summaryFormat.d.ts.map +1 -1
  122. package/dist/summary/summaryFormat.js +2 -2
  123. package/dist/summary/summaryFormat.js.map +1 -1
  124. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  125. package/dist/summary/summaryGenerator.js +3 -4
  126. package/dist/summary/summaryGenerator.js.map +1 -1
  127. package/lib/batchTracker.js.map +1 -1
  128. package/lib/blobManager.d.ts +2 -2
  129. package/lib/blobManager.d.ts.map +1 -1
  130. package/lib/blobManager.js.map +1 -1
  131. package/lib/channelCollection.d.ts +3 -3
  132. package/lib/channelCollection.d.ts.map +1 -1
  133. package/lib/channelCollection.js.map +1 -1
  134. package/lib/connectionTelemetry.d.ts +2 -1
  135. package/lib/connectionTelemetry.d.ts.map +1 -1
  136. package/lib/connectionTelemetry.js +2 -2
  137. package/lib/connectionTelemetry.js.map +1 -1
  138. package/lib/containerRuntime.d.ts +2 -2
  139. package/lib/containerRuntime.d.ts.map +1 -1
  140. package/lib/containerRuntime.js +6 -10
  141. package/lib/containerRuntime.js.map +1 -1
  142. package/lib/dataStoreContext.d.ts +3 -4
  143. package/lib/dataStoreContext.d.ts.map +1 -1
  144. package/lib/dataStoreContext.js.map +1 -1
  145. package/lib/deltaManagerProxies.d.ts +4 -3
  146. package/lib/deltaManagerProxies.d.ts.map +1 -1
  147. package/lib/deltaManagerProxies.js.map +1 -1
  148. package/lib/deltaScheduler.d.ts +2 -1
  149. package/lib/deltaScheduler.d.ts.map +1 -1
  150. package/lib/deltaScheduler.js.map +1 -1
  151. package/lib/gc/garbageCollection.d.ts +0 -1
  152. package/lib/gc/garbageCollection.d.ts.map +1 -1
  153. package/lib/gc/garbageCollection.js +17 -20
  154. package/lib/gc/garbageCollection.js.map +1 -1
  155. package/lib/gc/gcConfigs.d.ts.map +1 -1
  156. package/lib/gc/gcConfigs.js +6 -20
  157. package/lib/gc/gcConfigs.js.map +1 -1
  158. package/lib/gc/gcDefinitions.d.ts +1 -10
  159. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  160. package/lib/gc/gcDefinitions.js +0 -2
  161. package/lib/gc/gcDefinitions.js.map +1 -1
  162. package/lib/gc/gcHelpers.d.ts +1 -1
  163. package/lib/gc/gcHelpers.d.ts.map +1 -1
  164. package/lib/gc/gcHelpers.js.map +1 -1
  165. package/lib/gc/gcSummaryStateTracker.d.ts +1 -34
  166. package/lib/gc/gcSummaryStateTracker.d.ts.map +1 -1
  167. package/lib/gc/gcSummaryStateTracker.js +4 -57
  168. package/lib/gc/gcSummaryStateTracker.js.map +1 -1
  169. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  170. package/lib/gc/gcTelemetry.js.map +1 -1
  171. package/lib/gc/index.d.ts +1 -1
  172. package/lib/gc/index.d.ts.map +1 -1
  173. package/lib/gc/index.js +1 -1
  174. package/lib/gc/index.js.map +1 -1
  175. package/lib/messageTypes.d.ts +1 -1
  176. package/lib/messageTypes.d.ts.map +1 -1
  177. package/lib/messageTypes.js.map +1 -1
  178. package/lib/opLifecycle/definitions.d.ts +2 -2
  179. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  180. package/lib/opLifecycle/definitions.js.map +1 -1
  181. package/lib/opLifecycle/opCompressor.d.ts +11 -1
  182. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  183. package/lib/opLifecycle/opCompressor.js +13 -2
  184. package/lib/opLifecycle/opCompressor.js.map +1 -1
  185. package/lib/opLifecycle/opDecompressor.d.ts +1 -1
  186. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  187. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  188. package/lib/opLifecycle/opGroupingManager.d.ts +10 -3
  189. package/lib/opLifecycle/opGroupingManager.d.ts.map +1 -1
  190. package/lib/opLifecycle/opGroupingManager.js +7 -0
  191. package/lib/opLifecycle/opGroupingManager.js.map +1 -1
  192. package/lib/opLifecycle/opSplitter.d.ts +4 -2
  193. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  194. package/lib/opLifecycle/opSplitter.js +12 -7
  195. package/lib/opLifecycle/opSplitter.js.map +1 -1
  196. package/lib/opLifecycle/outbox.d.ts +9 -0
  197. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  198. package/lib/opLifecycle/outbox.js +10 -1
  199. package/lib/opLifecycle/outbox.js.map +1 -1
  200. package/lib/opLifecycle/remoteMessageProcessor.d.ts +1 -1
  201. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  202. package/lib/opLifecycle/remoteMessageProcessor.js +1 -1
  203. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  204. package/lib/opProperties.d.ts +1 -1
  205. package/lib/opProperties.d.ts.map +1 -1
  206. package/lib/opProperties.js.map +1 -1
  207. package/lib/packageVersion.d.ts +1 -1
  208. package/lib/packageVersion.js +1 -1
  209. package/lib/packageVersion.js.map +1 -1
  210. package/lib/pendingStateManager.js.map +1 -1
  211. package/lib/scheduleManager.d.ts +2 -1
  212. package/lib/scheduleManager.d.ts.map +1 -1
  213. package/lib/scheduleManager.js.map +1 -1
  214. package/lib/summary/orderedClientElection.d.ts +1 -1
  215. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  216. package/lib/summary/orderedClientElection.js.map +1 -1
  217. package/lib/summary/runningSummarizer.d.ts +1 -1
  218. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  219. package/lib/summary/runningSummarizer.js +1 -2
  220. package/lib/summary/runningSummarizer.js.map +1 -1
  221. package/lib/summary/summarizerClientElection.d.ts +1 -1
  222. package/lib/summary/summarizerClientElection.d.ts.map +1 -1
  223. package/lib/summary/summarizerClientElection.js +1 -1
  224. package/lib/summary/summarizerClientElection.js.map +1 -1
  225. package/lib/summary/summarizerNode/summarizerNode.d.ts +2 -1
  226. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  227. package/lib/summary/summarizerNode/summarizerNode.js +14 -14
  228. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  229. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +2 -1
  230. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  231. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  232. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +1 -1
  233. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  234. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +1 -1
  235. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  236. package/lib/summary/summarizerTypes.d.ts +2 -3
  237. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  238. package/lib/summary/summarizerTypes.js.map +1 -1
  239. package/lib/summary/summaryCollection.d.ts +2 -1
  240. package/lib/summary/summaryCollection.d.ts.map +1 -1
  241. package/lib/summary/summaryCollection.js +1 -1
  242. package/lib/summary/summaryCollection.js.map +1 -1
  243. package/lib/summary/summaryFormat.d.ts +2 -2
  244. package/lib/summary/summaryFormat.d.ts.map +1 -1
  245. package/lib/summary/summaryFormat.js +1 -1
  246. package/lib/summary/summaryFormat.js.map +1 -1
  247. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  248. package/lib/summary/summaryGenerator.js +2 -3
  249. package/lib/summary/summaryGenerator.js.map +1 -1
  250. package/lib/tsdoc-metadata.json +1 -1
  251. package/package.json +33 -22
  252. package/src/batchTracker.ts +1 -1
  253. package/src/blobManager.ts +4 -4
  254. package/src/channelCollection.ts +4 -3
  255. package/src/connectionTelemetry.ts +14 -6
  256. package/src/containerRuntime.ts +17 -21
  257. package/src/dataStoreContext.ts +10 -10
  258. package/src/deltaManagerProxies.ts +7 -5
  259. package/src/deltaScheduler.ts +2 -1
  260. package/src/gc/garbageCollection.ts +18 -24
  261. package/src/gc/gcConfigs.ts +5 -24
  262. package/src/gc/gcDefinitions.ts +1 -10
  263. package/src/gc/gcHelpers.ts +1 -1
  264. package/src/gc/gcSummaryStateTracker.ts +6 -72
  265. package/src/gc/gcTelemetry.ts +1 -1
  266. package/src/gc/index.ts +0 -1
  267. package/src/messageTypes.ts +1 -1
  268. package/src/opLifecycle/README.md +120 -160
  269. package/src/opLifecycle/definitions.ts +2 -2
  270. package/src/opLifecycle/opCompressor.ts +13 -2
  271. package/src/opLifecycle/opDecompressor.ts +1 -1
  272. package/src/opLifecycle/opGroupingManager.ts +11 -4
  273. package/src/opLifecycle/opSplitter.ts +13 -8
  274. package/src/opLifecycle/outbox.ts +10 -1
  275. package/src/opLifecycle/remoteMessageProcessor.ts +2 -1
  276. package/src/opProperties.ts +2 -4
  277. package/src/packageVersion.ts +1 -1
  278. package/src/pendingStateManager.ts +1 -1
  279. package/src/scheduleManager.ts +2 -1
  280. package/src/summary/images/appTree.png +0 -0
  281. package/src/summary/images/protocolAndAppTree.png +0 -0
  282. package/src/summary/images/summaryTree.png +0 -0
  283. package/src/summary/orderedClientElection.ts +1 -1
  284. package/src/summary/runningSummarizer.ts +2 -2
  285. package/src/summary/summarizerClientElection.ts +2 -1
  286. package/src/summary/summarizerNode/summarizerNode.ts +19 -29
  287. package/src/summary/summarizerNode/summarizerNodeUtils.ts +2 -1
  288. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +3 -5
  289. package/src/summary/summarizerTypes.ts +2 -7
  290. package/src/summary/summaryCollection.ts +2 -2
  291. package/src/summary/summaryFormat.ts +5 -6
  292. package/src/summary/summaryFormats.md +160 -0
  293. package/src/summary/summaryGenerator.ts +2 -3
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { SummaryType } from "@fluidframework/protocol-definitions";
6
+ import { SummaryType } from "@fluidframework/driver-definitions";
7
7
  import {
8
8
  ISummaryTreeWithStats,
9
9
  ISummarizeResult,
@@ -16,7 +16,7 @@ import { SummaryTreeBuilder, mergeStats } from "@fluidframework/runtime-utils/in
16
16
 
17
17
  import { IRefreshSummaryResult } from "../summary/index.js";
18
18
 
19
- import { GCVersion, IGCStats, IGarbageCollectorConfigs } from "./gcDefinitions.js";
19
+ import { IGCStats, IGarbageCollectorConfigs } from "./gcDefinitions.js";
20
20
  import { generateSortedGCState } from "./gcHelpers.js";
21
21
  import { IGarbageCollectionSnapshotData, IGarbageCollectionState } from "./gcSummaryDefinitions.js";
22
22
 
@@ -38,17 +38,11 @@ export interface IGCSummaryTrackingData {
38
38
  * On summarize, it decides whether to write new state or re-use previous summary's state.
39
39
  */
40
40
  export class GCSummaryStateTracker {
41
- // This is the version of GC data in the latest summary being tracked.
42
- private latestSummaryGCVersion: GCVersion;
43
-
44
41
  // Keeps track of the GC data from the latest summary successfully acked by the server.
45
42
  private latestSummaryData: IGCSummaryTrackingData | undefined;
46
43
  // Keeps track of the GC data from the last summary submitted to the server but not yet acked.
47
44
  private pendingSummaryData: IGCSummaryTrackingData | undefined;
48
45
 
49
- // Tracks whether there was GC was run in latest summary being tracked.
50
- private wasGCRunInLatestSummary: boolean;
51
-
52
46
  // Tracks the count of data stores whose state updated since the last summary, i.e., they went from referenced
53
47
  // to unreferenced or vice-versa.
54
48
  public updatedDSCountSinceLastSummary: number = 0;
@@ -69,58 +63,9 @@ export class GCSummaryStateTracker {
69
63
  // Tells whether GC should run or not.
70
64
  private readonly configs: Pick<
71
65
  IGarbageCollectorConfigs,
72
- "shouldRunGC" | "tombstoneMode" | "gcVersionInBaseSnapshot" | "gcVersionInEffect"
66
+ "gcEnabled" | "tombstoneMode" | "gcVersionInBaseSnapshot" | "gcVersionInEffect"
73
67
  >,
74
- // Tells whether GC was run in the base snapshot this container loaded from.
75
- wasGCRunInBaseSnapshot: boolean,
76
- ) {
77
- this.wasGCRunInLatestSummary = wasGCRunInBaseSnapshot;
78
- // For existing document, the latest summary is the one that we loaded from. So, use its GC version as the
79
- // latest tracked GC version. For new documents, we will be writing the first summary with the current version.
80
- this.latestSummaryGCVersion =
81
- this.configs.gcVersionInBaseSnapshot ?? this.configs.gcVersionInEffect;
82
- }
83
-
84
- /**
85
- * Tells whether the GC state needs to be reset. This can happen under 3 conditions:
86
- *
87
- * 1. The base snapshot contains GC state but GC is disabled. This will happen the first time GC is disabled after
88
- * it was enabled before. GC state needs to be removed from summary and all nodes should be marked referenced.
89
- *
90
- * 2. The base snapshot does not have GC state but GC is enabled. This will happen the very first time GC runs on
91
- * a document and the first time GC is enabled after is was disabled before.
92
- *
93
- * 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.
94
- *
95
- * Note that the state will be reset only once for the first summary generated after this returns true. After that,
96
- * this will return false.
97
- */
98
- public get doesGCStateNeedReset(): boolean {
99
- return this.wasGCRunInLatestSummary !== this.configs.shouldRunGC;
100
- }
101
-
102
- /**
103
- * Tells whether the GC state needs to be reset in the next summary. We need to do this if:
104
- *
105
- * 1. GC was enabled and is now disabled. The GC state needs to be removed and everything becomes referenced.
106
- *
107
- * 2. GC was disabled and is now enabled. The GC state needs to be regenerated and added to summary.
108
- *
109
- * 3. GC is enabled and the latest summary state is refreshed from a snapshot that had GC disabled and vice-versa.
110
- *
111
- * 4. The GC version in the latest summary is different from the current GC version. This can happen if:
112
- *
113
- * 4.1. The summary this client loaded with has data from a different GC version.
114
- *
115
- * 4.2. This client's latest summary was updated from a snapshot that has a different GC version.
116
- */
117
- public get doesSummaryStateNeedReset(): boolean {
118
- return (
119
- this.doesGCStateNeedReset ||
120
- (this.configs.shouldRunGC &&
121
- this.latestSummaryGCVersion !== this.configs.gcVersionInEffect)
122
- );
123
- }
68
+ ) {}
124
69
 
125
70
  /**
126
71
  * Called during GC initialization. Initialize the latest summary data from the base snapshot data.
@@ -152,7 +97,7 @@ export class GCSummaryStateTracker {
152
97
  deletedNodes: Set<string>,
153
98
  tombstones: string[],
154
99
  ): ISummarizeResult | undefined {
155
- if (!this.configs.shouldRunGC) {
100
+ if (!this.configs.gcEnabled) {
156
101
  return;
157
102
  }
158
103
 
@@ -283,25 +228,14 @@ export class GCSummaryStateTracker {
283
228
  * Called to refresh the latest summary state. This happens when a pending summary is acked.
284
229
  */
285
230
  public async refreshLatestSummary(result: IRefreshSummaryResult): Promise<void> {
286
- if (!result.isSummaryTracked) {
287
- return;
288
- }
289
-
290
- // If the summary is tracked, this client is the one that generated it. So, update wasGCRunInLatestSummary.
291
- // Note that this has to be updated if GC did not run too. Otherwise, `gcStateNeedsReset` will always return
292
- // true in scenarios where GC is currently disabled but enabled in the snapshot we loaded from.
293
- this.wasGCRunInLatestSummary = this.configs.shouldRunGC;
294
-
295
- if (!this.configs.shouldRunGC) {
231
+ if (!this.configs.gcEnabled || !result.isSummaryTracked) {
296
232
  return;
297
233
  }
298
234
 
299
- this.latestSummaryGCVersion = this.configs.gcVersionInEffect;
300
235
  this.latestSummaryData = this.pendingSummaryData;
301
236
  this.pendingSummaryData = undefined;
302
237
  this.updatedDSCountSinceLastSummary = 0;
303
238
  this.fullGCModeForAutoRecovery = false;
304
- return;
305
239
  }
306
240
 
307
241
  /**
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import type { Tagged } from "@fluidframework/core-interfaces";
6
7
  import { IGarbageCollectionData } from "@fluidframework/runtime-definitions/internal";
7
8
  import {
8
9
  ITelemetryLoggerExt,
@@ -12,7 +13,6 @@ import {
12
13
  type ITelemetryGenericEventExt,
13
14
  } from "@fluidframework/telemetry-utils/internal";
14
15
 
15
- import type { Tagged } from "@fluidframework/core-interfaces";
16
16
  import { RuntimeHeaderData } from "../containerRuntime.js";
17
17
  import { ICreateContainerMetadata } from "../summary/index.js";
18
18
 
package/src/gc/index.ts CHANGED
@@ -30,7 +30,6 @@ export {
30
30
  ISweepPhaseStats,
31
31
  IGCStats,
32
32
  oneDayMs,
33
- runGCTestKey,
34
33
  runSessionExpiryKey,
35
34
  runSweepKey,
36
35
  stableGCVersion,
@@ -3,8 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions";
6
7
  import type { IdCreationRange } from "@fluidframework/id-compressor/internal";
7
- import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
8
  import {
9
9
  IAttachMessage,
10
10
  IEnvelope,
@@ -2,26 +2,28 @@
2
2
 
3
3
  ## Table of contents
4
4
 
5
- - [Introduction](#introduction)
6
- - [How batching works](#how-batching-works)
7
- - [Compression](#compression)
8
- - [Grouped batching](#grouped-batching)
9
- - [Risks](#risks)
10
- - [Chunking for compression](#chunking-for-compression)
11
- - [Disabling in case of emergency](#disabling-in-case-of-emergency)
12
- - [Example configs](#example-configs)
13
- - [Note about performance and latency](#note-about-performance-and-latency)
14
- - [How it works](#how-it-works)
15
- - [How grouped batching works](#how-grouped-batching-works)
16
- - [How the overall op flow works](#How-the-overall-op-flow-works)
17
- - [Outbound](#outbound)
18
- - [Inbound](#inbound)
5
+ - [Configs and feature gates for solving the 1MB limit.](#configs-and-feature-gates-for-solving-the-1mb-limit)
6
+ - [Table of contents](#table-of-contents)
7
+ - [Introduction](#introduction)
8
+ - [How batching works](#how-batching-works)
9
+ - [Compression](#compression)
10
+ - [Grouped batching](#grouped-batching)
11
+ - [Changes in op semantics](#changes-in-op-semantics)
12
+ - [Chunking for compression](#chunking-for-compression)
13
+ - [Disabling in case of emergency](#disabling-in-case-of-emergency)
14
+ - [Configuration](#configuration)
15
+ - [Note about performance and latency](#note-about-performance-and-latency)
16
+ - [How it works](#how-it-works)
17
+ - [How it works (Grouped Batching disabled)](#how-it-works-grouped-batching-disabled)
18
+ - [How the overall op flow works](#how-the-overall-op-flow-works)
19
+ - [Outbound](#outbound)
20
+ - [Inbound](#inbound)
19
21
 
20
22
  ## Introduction
21
23
 
22
24
  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.
23
25
 
24
- 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.
26
+ There are three features which can be used to work around this size limit: "grouped batching", "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.
25
27
 
26
28
  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.
27
29
 
@@ -29,7 +31,7 @@ By default, the runtime is configured with a max batch size of `716800` bytes, w
29
31
 
30
32
  Batching in the context of Fluid ops is a way in which the framework accumulates and applies ops. A batch is a group of ops accumulated within a single JS turn, which will be broadcasted in the same order to all the other connected clients and applied synchronously. Additional logic and validation ensure that batches are never interleaved, nested or interrupted and they are processed in isolation without interleaving of ops from other clients.
31
33
 
32
- The way batches are formed is governed by the `FlushMode` setting of the `ContainerRuntimeOptions` and it is immutable for the entire lifetime of the runtime and subsequently the container.
34
+ The way batches are formed is governed by the `FlushMode` setting of the `IContainerRuntimeOptions` and it is immutable for the entire lifetime of the runtime and subsequently the container.
33
35
 
34
36
  ```
35
37
  export enum FlushMode {
@@ -66,47 +68,30 @@ As `FlushMode.TurnBased` accumulates ops, it is the most vulnerable to run into
66
68
 
67
69
  Compression is relevant for both `FlushMode.TurnBased` and `FlushMode.Immediate` as it only targets the contents of the ops and not the number of ops in a batch. Compression is opaque to the server and implementations of the Fluid protocol do not need to alter their behavior to support this client feature.
68
70
 
69
- ## Grouped batching
70
-
71
- 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.
72
-
73
- 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.
74
-
75
- See [below](#how-grouped-batching-works) for an example.
76
-
77
- ### Risks
71
+ Compressing a batch yields a batch with the same number of messages. It compresses all the content, shifting the compressed payload into the first op,
72
+ leaving the rest of the batch's messages as empty placeholders to reserve sequence numbers for the compressed messages.
78
73
 
79
- This option should **ONLY** be enabled after observing that 99.9% of your application sessions contains these changes (runtime version "2.0.0-internal.7.0.0" or later). Containers created with this option may not open in future versions of the framework.
80
-
81
- This option will change a couple of expectations around message structure and runtime layer expectations. Only enable this option after testing
82
- and verifying that the following expectation changes won't have any effects:
74
+ ## Grouped batching
83
75
 
84
- - batch messages observed at the runtime layer will not match messages seen at the loader layer (i.e. grouped form at loader layer, ungrouped form at runtime layer)
85
- - messages within the same batch will have the same sequence number
86
- - client sequence numbers on batch messages can only be used to order messages with the same sequenceNumber
87
- - requires all ops to be processed by runtime layer (version "2.0.0-internal.1.2.0" or later https://github.com/microsoft/FluidFramework/pull/11832)
76
+ With Grouped Batching enabled (it's on by default), all batch messages are combined under a single "grouped" message _before compression_. Upon receiving this new "grouped" message, the batch messages will be extracted, and they each will be given the same sequence number - that of the parent "grouped" message.
88
77
 
89
- Grouped batching may become problematic for batches which contain reentrant ops. This is the case when changes are made to a DDS inside a DDS 'onChanged' event handler. This means that the reentrant op will have a different reference sequence number than the rest of the ops in the batch, resulting in a different view of the state of the data model.
78
+ The purpose for enabling grouped batching before compression is to eliminate the empty placeholder messages in the chunks. These empty messages are not free to transmit, can trigger service throttling, and in extreme cases can _still_ result in a batch too large (from empty op envelopes alone).
90
79
 
91
- Therefore, when grouped batching is enabled, all batches with reentrant ops are rebased to the current reference sequence number and resubmitted to the data stores so that all ops are in agreement about the state of the data model and ensure eventual consistency.
80
+ Grouped batching is only relevant for `FlushMode.TurnBased`, since `OpGroupingManagerConfig.opCountThreshold` defaults to 2. Grouped batching is opaque to the server and implementations of the Fluid protocol do not need to alter their behavior to support this client feature.
92
81
 
93
- ### How to enable
82
+ Grouped Batching can be disabled by setting `IContainerRuntimeOptions.enableGroupedBatching` to `false`.
94
83
 
95
- **This feature is disabled by default**
84
+ See [below](#how-grouped-batching-works) for an example.
96
85
 
97
- If all prerequisites in the previous section are met, enabling the feature can be done via the `IContainerRuntimeOptions` as following:
86
+ ### Changes in op semantics
98
87
 
99
- ```
100
- const runtimeOptions: IContainerRuntimeOptions = {
101
- (...)
102
- enableGroupedBatching: true,
103
- (...)
104
-   }
105
- ```
88
+ Grouped Batching changed a couple of expectations around message structure and runtime layer expectations. Specifically:
106
89
 
107
- In case of emergency grouped batching can be disabled at runtime, using feature gates. If `"Fluid.ContainerRuntime.DisableGroupedBatching"` is set to `true`, it will disable grouped batching if enabled from `IContainerRuntimeOptions` in the code.
108
-
109
- Grouped batching is only relevant for `FlushMode.TurnBased` as it only targets the number of ops in a batch. Grouped batching is opaque to the server and implementations of the Fluid protocol do not need to alter their behavior to support this client feature.
90
+ - Batch messages observed at the runtime layer no longer match messages seen at the loader layer (i.e. grouped form at loader layer, ungrouped form at runtime layer)
91
+ - Once the ContainerRuntime ungroups the batch, the client sequence numbers on the resulting messages can only be used to order messages with that batch (having the same sequenceNumber)
92
+ - Messages within the same batch now all share the same sequence number
93
+ - All ops in a batch must also have the same reference sequence number to ensure eventualy consistency of the model. The runtime will "rebase" ops in a batch with different ref sequence number to satisfy that requirement.
94
+ - What causes ops in a single JS turn (and thus in a batch) to have different reference sequence number? "Op reentrancy", where changes are made to a DDS inside a DDS 'onChanged' event handler.
110
95
 
111
96
  ## Chunking for compression
112
97
 
@@ -120,34 +105,15 @@ Chunking is relevant for both `FlushMode.TurnBased` and `FlushMode.Immediate` as
120
105
 
121
106
  ## Disabling in case of emergency
122
107
 
123
- If the features are enabled using the configs, they can be disabled at runtime via feature gates as following:
108
+ Compression and Chunking configuration can be overridden via feature gates to force-disable them:
124
109
 
125
110
  - `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).
126
- - `Fluid.ContainerRuntime.DisableGroupedBatching` - if set to true, will disable grouped batching.
127
111
  - `Fluid.ContainerRuntime.CompressionChunkingDisabled` - if set to true, will disable chunking for compression.
128
112
 
129
- ## Example configs
130
-
131
- By default, the runtime is configured with the following values related to compression and chunking:
132
-
133
- ```
134
- const runtimeOptions: IContainerRuntimeOptions = {
135
- compressionOptions: {
136
- minimumBatchSizeInBytes: 614400,
137
- compressionAlgorithm: CompressionAlgorithms.lz4,
138
- },
139
- chunkSizeInBytes: 204800,
140
- maxBatchSizeInBytes: 716800,
141
-     }
142
- ```
143
-
144
- To enable grouped batching, use the following property:
113
+ ## Configuration
145
114
 
146
- ```
147
- const runtimeOptions: IContainerRuntimeOptions = {
148
- enableGroupedBatching: true,
149
-     }
150
- ```
115
+ These features are configured via `IContainerRuntimeOptions`, passed to the `ContainerRuntime.loadRuntime` function.
116
+ Default values are specified in code in [containerRuntime.ts](../containerRuntime.ts).
151
117
 
152
118
  ## Note about performance and latency
153
119
 
@@ -157,86 +123,7 @@ In general, compression offers a trade-off between higher compute costs, lower b
157
123
 
158
124
  ## How it works
159
125
 
160
- Compression currently works as a runtime layer over the regular op sending/receiving pipeline.
161
-
162
- 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:
163
-
164
- ```
165
- +-----------+-----------+-----------+-----------+
166
- | Op 1 | Op 2 | Op 3 | Op 4 |
167
- | SeqNum: 1 | SeqNum: 2 | SeqNum: 3 | SeqNum: 4 |
168
- | Size: 100 | Size: 150 | Size: 200 | Size: 400 |
169
- +-----------+-----------+-----------+-----------+
170
- ```
171
-
172
- 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:
173
-
174
- ```
175
- +--------------------+-----------+-----------+-----------+
176
- | Op 1 | Op 2 | Op 3 | Op 4 |
177
- | SeqNum: 1 | SeqNum: 2 | SeqNum: 3 | SeqNum: 4 |
178
- | Size: 200 | Size: 0 | Size: 0 | Size: 0 |
179
- | Compression: 'lz4' | | | |
180
- +--------------------+-----------+-----------+-----------+
181
- ```
182
-
183
- 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.
184
-
185
- 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.
186
- So, compression virtualizes the batch.
187
-
188
- 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).
189
-
190
- 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.
191
-
192
- To illustrate, let’s take the large batch below:
193
-
194
- ```
195
- +--------------------+-----------+-----------+-----------+
196
- | Op 1 | Op 2 | Op 3 | Op 4 |
197
- | SeqNum: 1 | SeqNum: 2 | SeqNum: 3 | SeqNum: 4 |
198
- | Size: 900 | Size: 0 | Size: 0 | Size: 0 |
199
- | Compression: 'lz4' | | | |
200
- +--------------------+-----------+-----------+-----------+
201
- ```
202
-
203
- This will produce the following batches:
204
-
205
- ```
206
- +-----------+
207
- | Chunk 1/3 |
208
- | SeqNum: 1 |
209
- | Size: 300 |
210
- +-----------+
211
-
212
- ```
213
-
214
- ```
215
- +-----------+
216
- | Chunk 2/3 |
217
- | SeqNum: 2 |
218
- | Size: 300 |
219
- +-----------+
220
-
221
- ```
222
-
223
- ```
224
- +-----------+-----------+-----------+-----------+
225
- | Chunk 3/3 | Op 2 | Op 3 | Op 4 |
226
- | SeqNum: 3 | SeqNum: 4 | SeqNum: 5 | SeqNum: 6 |
227
- | Size: 300 | Size: 0 | Size: 0 | Size: 0 |
228
- +-----------+-----------+-----------+-----------+
229
- ```
230
-
231
- 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.
232
-
233
- 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.
234
-
235
- 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.
236
-
237
- 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.
238
-
239
- ## How grouped batching works
126
+ Virtualization works as an intermediate step in the Runtime layer, as the closest step to sending/receiving ops via the Loader layer.
240
127
 
241
128
  Given the following baseline batch:
242
129
 
@@ -262,9 +149,9 @@ Compressed batch:
262
149
 
263
150
  ```
264
151
  +-------------------------------------------------------------------------------------------------------------------------+
265
- | Op 1 Contents: +------------------------------------------------------------------------------------+ |
266
- | Compression: 'lz4' | Type: "groupedBatch" | |
267
- | | +----------------+---------------+---------------+---------------+---------------+ | |
152
+ | Op 1 Logical +------------------------------------------------------------------------------------+ |
153
+ | Compression: 'lz4' Contents: | Type: "groupedBatch" | |
154
+ | Compressed buffer: "wxyz" | +----------------+---------------+---------------+---------------+---------------+ | |
268
155
  | | | Op 1 | Op 2 | Op 3 | Op 4 | Op 5 | | |
269
156
  | | | Contents: "a" | Contents: "b" | Contents: "c" | Contents: "d" | Contents: "e" | | |
270
157
  | | +----------------+---------------+---------------+---------------+---------------+ | |
@@ -278,7 +165,7 @@ Can produce the following chunks:
278
165
  +------------------------------------------------+
279
166
  | Chunk 1/2 Contents: +---------------------+ |
280
167
  | | +-----------------+ | |
281
- | | | Contents: "abc" | | |
168
+ | | | Contents: "wx" | | |
282
169
  | | +-----------------+ | |
283
170
  | +---------------------+ |
284
171
  +------------------------------------------------+
@@ -288,16 +175,16 @@ Can produce the following chunks:
288
175
  +-----------------------------------------------+
289
176
  | Chunk 2/2 Contents: +--------------------+ |
290
177
  | | +----------------+ | |
291
- | | | Contents: "de" | | |
178
+ | | | Contents: "yz" | | |
292
179
  | | +----------------+ | |
293
180
  | +--------------------+ |
294
181
  +-----------------------------------------------+
295
182
  ```
296
183
 
297
- - Send to service
298
- - Service acks ops sent
299
- - Receive chunks from service
300
- - Recompile to the compression step
184
+ The chunks are sent to service to be sequenced, and broadcast to all clients.
185
+
186
+ - On the receiving end, the client will accumulate chunks 1 through n-1 and keep them in memory (in this example, it's just Chunk 1).
187
+ - When the final chunk 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.
301
188
 
302
189
  Decompressed batch:
303
190
 
@@ -321,6 +208,79 @@ Ungrouped batch:
321
208
  +-----------------+-----------------+-----------------+-----------------+-----------------+
322
209
  ```
323
210
 
211
+ ## How it works (Grouped Batching disabled)
212
+
213
+ 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:
214
+
215
+ ```
216
+ +-----------+-----------+-----------+-----------+
217
+ | Op 1 | Op 2 | Op 3 | Op 4 |
218
+ | SeqNum: 1 | SeqNum: 2 | SeqNum: 3 | SeqNum: 4 |
219
+ | Size: 100 | Size: 150 | Size: 200 | Size: 400 |
220
+ +-----------+-----------+-----------+-----------+
221
+ ```
222
+
223
+ 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:
224
+
225
+ ```
226
+ +--------------------+-----------+-----------+-----------+
227
+ | Op 1 | Op 2 | Op 3 | Op 4 |
228
+ | SeqNum: 1 | SeqNum: 2 | SeqNum: 3 | SeqNum: 4 |
229
+ | Size: 200 | Size: 0 | Size: 0 | Size: 0 |
230
+ | Compression: 'lz4' | | | |
231
+ +--------------------+-----------+-----------+-----------+
232
+ ```
233
+
234
+ 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.
235
+
236
+ 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.
237
+ So, compression virtualizes the batch.
238
+
239
+ 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).
240
+
241
+ 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.
242
+
243
+ To illustrate, let’s take the large batch below:
244
+
245
+ ```
246
+ +--------------------+-----------+-----------+-----------+
247
+ | Op 1 | Op 2 | Op 3 | Op 4 |
248
+ | SeqNum: 1 | SeqNum: 2 | SeqNum: 3 | SeqNum: 4 |
249
+ | Size: 900 | Size: 0 | Size: 0 | Size: 0 |
250
+ | Compression: 'lz4' | | | |
251
+ +--------------------+-----------+-----------+-----------+
252
+ ```
253
+
254
+ This will produce the following batches:
255
+
256
+ ```
257
+ +-----------+
258
+ | Chunk 1/3 |
259
+ | SeqNum: 1 |
260
+ | Size: 300 |
261
+ +-----------+
262
+
263
+ ```
264
+
265
+ ```
266
+ +-----------+
267
+ | Chunk 2/3 |
268
+ | SeqNum: 2 |
269
+ | Size: 300 |
270
+ +-----------+
271
+
272
+ ```
273
+
274
+ ```
275
+ +-----------+-----------+-----------+-----------+
276
+ | Chunk 3/3 | Op 2 | Op 3 | Op 4 |
277
+ | SeqNum: 3 | SeqNum: 4 | SeqNum: 5 | SeqNum: 6 |
278
+ | Size: 300 | Size: 0 | Size: 0 | Size: 0 |
279
+ +-----------+-----------+-----------+-----------+
280
+ ```
281
+
282
+ 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.
283
+
324
284
  ## How the overall op flow works
325
285
 
326
286
  ### Outbound
@@ -19,7 +19,7 @@ export type BatchMessage = IBatchMessage & {
19
19
  /**
20
20
  * Batch interface used internally by the runtime.
21
21
  */
22
- export interface IBatch {
22
+ export interface IBatch<TMessages extends BatchMessage[] = BatchMessage[]> {
23
23
  /**
24
24
  * Sum of the in-memory content sizes of all messages in the batch.
25
25
  * If the batch is compressed, this number reflects the post-compression size.
@@ -28,7 +28,7 @@ export interface IBatch {
28
28
  /**
29
29
  * All the messages in the batch
30
30
  */
31
- readonly content: BatchMessage[];
31
+ readonly content: TMessages;
32
32
  /**
33
33
  * The reference sequence number for the batch
34
34
  */
@@ -26,6 +26,13 @@ export class OpCompressor {
26
26
  this.logger = createChildLogger({ logger, namespace: "OpCompressor" });
27
27
  }
28
28
 
29
+ /**
30
+ * Combines the contents of the batch into a single JSON string and compresses it, putting
31
+ * the resulting string as the first message of the batch. The rest of the messages are
32
+ * empty placeholders to reserve sequence numbers.
33
+ * @param batch - The batch to compress
34
+ * @returns A batch of the same length as the input batch, containing a single compressed message followed by empty placeholders
35
+ */
29
36
  public compressBatch(batch: IBatch): IBatch {
30
37
  assert(
31
38
  batch.contentSizeInBytes > 0 && batch.content.length > 0,
@@ -33,7 +40,7 @@ export class OpCompressor {
33
40
  );
34
41
 
35
42
  const compressionStart = Date.now();
36
- const contentsAsBuffer = new TextEncoder().encode(this.serializeBatch(batch));
43
+ const contentsAsBuffer = new TextEncoder().encode(this.serializeBatchContents(batch));
37
44
  const compressedContents = compress(contentsAsBuffer);
38
45
  const compressedContent = IsoBuffer.from(compressedContents).toString("base64");
39
46
  const duration = Date.now() - compressionStart;
@@ -75,8 +82,12 @@ export class OpCompressor {
75
82
  return compressedBatch;
76
83
  }
77
84
 
78
- private serializeBatch(batch: IBatch): string {
85
+ /**
86
+ * Combine the batch's content strings into a single JSON string (a serialized array)
87
+ */
88
+ private serializeBatchContents(batch: IBatch): string {
79
89
  try {
90
+ // Yields a valid JSON array, since each message.contents is already serialized to JSON
80
91
  return `[${batch.content.map((message) => message.contents).join(",")}]`;
81
92
  } catch (e: any) {
82
93
  if (e.message === "Invalid string length") {
@@ -6,7 +6,7 @@
6
6
  import { IsoBuffer, Uint8ArrayToString } from "@fluid-internal/client-utils";
7
7
  import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
8
8
  import { assert } from "@fluidframework/core-utils/internal";
9
- import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
9
+ import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions";
10
10
  import { createChildLogger } from "@fluidframework/telemetry-utils/internal";
11
11
  import { decompress } from "lz4js";
12
12
 
@@ -5,10 +5,10 @@
5
5
 
6
6
  import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
7
7
  import { assert } from "@fluidframework/core-utils/internal";
8
- import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
+ import { ISequencedDocumentMessage } from "@fluidframework/driver-definitions";
9
9
  import { createChildLogger } from "@fluidframework/telemetry-utils/internal";
10
10
 
11
- import { IBatch } from "./definitions.js";
11
+ import { IBatch, type BatchMessage } from "./definitions.js";
12
12
 
13
13
  /**
14
14
  * Grouping makes assumptions about the shape of message contents. This interface codifies those assumptions, but does not validate them.
@@ -49,7 +49,14 @@ export class OpGroupingManager {
49
49
  this.logger = createChildLogger({ logger, namespace: "OpGroupingManager" });
50
50
  }
51
51
 
52
- public groupBatch(batch: IBatch): IBatch {
52
+ /**
53
+ * Converts the given batch into a "grouped batch" - a batch with a single message of type "groupedBatch",
54
+ * with contents being an array of the original batch's messages.
55
+ *
56
+ * @remarks - Remember that a BatchMessage has its content JSON serialized, so the incoming batch message contents
57
+ * must be parsed first, and then the type and contents mentioned above are hidden in that JSON serialization.
58
+ */
59
+ public groupBatch(batch: IBatch): IBatch<[BatchMessage]> {
53
60
  assert(this.shouldGroup(batch), 0x946 /* cannot group the provided batch */);
54
61
 
55
62
  if (batch.content.length >= 1000) {
@@ -82,7 +89,7 @@ export class OpGroupingManager {
82
89
  })),
83
90
  });
84
91
 
85
- const groupedBatch: IBatch = {
92
+ const groupedBatch: IBatch<[BatchMessage]> = {
86
93
  ...batch,
87
94
  content: [
88
95
  {