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

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 (340) 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 +53 -34
  9. package/dist/blobManager.d.ts.map +1 -1
  10. package/dist/blobManager.js +236 -124
  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 +95 -46
  19. package/dist/containerRuntime.d.ts.map +1 -1
  20. package/dist/containerRuntime.js +288 -135
  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 +2 -1
  26. package/dist/dataStoreContext.d.ts.map +1 -1
  27. package/dist/dataStoreContext.js +38 -21
  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 +12 -9
  36. package/dist/dataStores.d.ts.map +1 -1
  37. package/dist/dataStores.js +68 -46
  38. package/dist/dataStores.js.map +1 -1
  39. package/dist/deltaScheduler.d.ts.map +1 -1
  40. package/dist/deltaScheduler.js +8 -3
  41. package/dist/deltaScheduler.js.map +1 -1
  42. package/dist/garbageCollection.d.ts +50 -26
  43. package/dist/garbageCollection.d.ts.map +1 -1
  44. package/dist/garbageCollection.js +348 -196
  45. package/dist/garbageCollection.js.map +1 -1
  46. package/dist/garbageCollectionConstants.d.ts +7 -3
  47. package/dist/garbageCollectionConstants.d.ts.map +1 -1
  48. package/dist/garbageCollectionConstants.js +10 -8
  49. package/dist/garbageCollectionConstants.js.map +1 -1
  50. package/dist/garbageCollectionHelpers.d.ts +15 -0
  51. package/dist/garbageCollectionHelpers.d.ts.map +1 -0
  52. package/dist/garbageCollectionHelpers.js +27 -0
  53. package/dist/garbageCollectionHelpers.js.map +1 -0
  54. package/dist/gcSweepReadyUsageDetection.d.ts +5 -5
  55. package/dist/gcSweepReadyUsageDetection.d.ts.map +1 -1
  56. package/dist/gcSweepReadyUsageDetection.js +14 -10
  57. package/dist/gcSweepReadyUsageDetection.js.map +1 -1
  58. package/dist/index.d.ts +3 -4
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +3 -5
  61. package/dist/index.js.map +1 -1
  62. package/dist/opLifecycle/batchManager.d.ts +13 -1
  63. package/dist/opLifecycle/batchManager.d.ts.map +1 -1
  64. package/dist/opLifecycle/batchManager.js +48 -7
  65. package/dist/opLifecycle/batchManager.js.map +1 -1
  66. package/dist/opLifecycle/definitions.d.ts +25 -1
  67. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  68. package/dist/opLifecycle/definitions.js.map +1 -1
  69. package/dist/opLifecycle/index.d.ts +2 -2
  70. package/dist/opLifecycle/index.d.ts.map +1 -1
  71. package/dist/opLifecycle/index.js +2 -1
  72. package/dist/opLifecycle/index.js.map +1 -1
  73. package/dist/opLifecycle/opCompressor.d.ts +1 -1
  74. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  75. package/dist/opLifecycle/opCompressor.js +24 -10
  76. package/dist/opLifecycle/opCompressor.js.map +1 -1
  77. package/dist/opLifecycle/opDecompressor.d.ts +2 -1
  78. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  79. package/dist/opLifecycle/opDecompressor.js +33 -17
  80. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  81. package/dist/opLifecycle/opSplitter.d.ts +34 -2
  82. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  83. package/dist/opLifecycle/opSplitter.js +117 -5
  84. package/dist/opLifecycle/opSplitter.js.map +1 -1
  85. package/dist/opLifecycle/outbox.d.ts +5 -0
  86. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  87. package/dist/opLifecycle/outbox.js +38 -27
  88. package/dist/opLifecycle/outbox.js.map +1 -1
  89. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  90. package/dist/opLifecycle/remoteMessageProcessor.js +17 -2
  91. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  92. package/dist/opProperties.d.ts.map +1 -1
  93. package/dist/opProperties.js +1 -3
  94. package/dist/opProperties.js.map +1 -1
  95. package/dist/orderedClientElection.d.ts.map +1 -1
  96. package/dist/orderedClientElection.js +10 -4
  97. package/dist/orderedClientElection.js.map +1 -1
  98. package/dist/packageVersion.d.ts +1 -1
  99. package/dist/packageVersion.js +1 -1
  100. package/dist/packageVersion.js.map +1 -1
  101. package/dist/pendingStateManager.d.ts +4 -13
  102. package/dist/pendingStateManager.d.ts.map +1 -1
  103. package/dist/pendingStateManager.js +134 -161
  104. package/dist/pendingStateManager.js.map +1 -1
  105. package/dist/runWhileConnectedCoordinator.d.ts.map +1 -1
  106. package/dist/runWhileConnectedCoordinator.js.map +1 -1
  107. package/dist/runningSummarizer.d.ts.map +1 -1
  108. package/dist/runningSummarizer.js +34 -22
  109. package/dist/runningSummarizer.js.map +1 -1
  110. package/dist/scheduleManager.d.ts +0 -1
  111. package/dist/scheduleManager.d.ts.map +1 -1
  112. package/dist/scheduleManager.js +11 -21
  113. package/dist/scheduleManager.js.map +1 -1
  114. package/dist/serializedSnapshotStorage.d.ts.map +1 -1
  115. package/dist/serializedSnapshotStorage.js +3 -1
  116. package/dist/serializedSnapshotStorage.js.map +1 -1
  117. package/dist/summarizer.d.ts +2 -3
  118. package/dist/summarizer.d.ts.map +1 -1
  119. package/dist/summarizer.js +39 -18
  120. package/dist/summarizer.js.map +1 -1
  121. package/dist/summarizerClientElection.d.ts +1 -2
  122. package/dist/summarizerClientElection.d.ts.map +1 -1
  123. package/dist/summarizerClientElection.js +3 -30
  124. package/dist/summarizerClientElection.js.map +1 -1
  125. package/dist/summarizerHandle.d.ts.map +1 -1
  126. package/dist/summarizerHandle.js.map +1 -1
  127. package/dist/summarizerHeuristics.d.ts.map +1 -1
  128. package/dist/summarizerHeuristics.js +6 -9
  129. package/dist/summarizerHeuristics.js.map +1 -1
  130. package/dist/summarizerTypes.d.ts +22 -25
  131. package/dist/summarizerTypes.d.ts.map +1 -1
  132. package/dist/summarizerTypes.js.map +1 -1
  133. package/dist/summaryCollection.d.ts.map +1 -1
  134. package/dist/summaryCollection.js +18 -8
  135. package/dist/summaryCollection.js.map +1 -1
  136. package/dist/summaryFormat.d.ts.map +1 -1
  137. package/dist/summaryFormat.js +18 -11
  138. package/dist/summaryFormat.js.map +1 -1
  139. package/dist/summaryGenerator.d.ts.map +1 -1
  140. package/dist/summaryGenerator.js +32 -14
  141. package/dist/summaryGenerator.js.map +1 -1
  142. package/dist/summaryManager.d.ts.map +1 -1
  143. package/dist/summaryManager.js +21 -9
  144. package/dist/summaryManager.js.map +1 -1
  145. package/dist/throttler.d.ts +2 -2
  146. package/dist/throttler.d.ts.map +1 -1
  147. package/dist/throttler.js +4 -4
  148. package/dist/throttler.js.map +1 -1
  149. package/garbageCollection.md +15 -2
  150. package/lib/batchTracker.d.ts +1 -2
  151. package/lib/batchTracker.d.ts.map +1 -1
  152. package/lib/batchTracker.js +2 -1
  153. package/lib/batchTracker.js.map +1 -1
  154. package/lib/blobManager.d.ts +53 -34
  155. package/lib/blobManager.d.ts.map +1 -1
  156. package/lib/blobManager.js +239 -127
  157. package/lib/blobManager.js.map +1 -1
  158. package/lib/connectionTelemetry.d.ts.map +1 -1
  159. package/lib/connectionTelemetry.js +11 -9
  160. package/lib/connectionTelemetry.js.map +1 -1
  161. package/lib/containerHandleContext.d.ts.map +1 -1
  162. package/lib/containerHandleContext.js +3 -1
  163. package/lib/containerHandleContext.js.map +1 -1
  164. package/lib/containerRuntime.d.ts +95 -46
  165. package/lib/containerRuntime.d.ts.map +1 -1
  166. package/lib/containerRuntime.js +291 -138
  167. package/lib/containerRuntime.js.map +1 -1
  168. package/lib/dataStore.d.ts.map +1 -1
  169. package/lib/dataStore.js +11 -9
  170. package/lib/dataStore.js.map +1 -1
  171. package/lib/dataStoreContext.d.ts +2 -1
  172. package/lib/dataStoreContext.d.ts.map +1 -1
  173. package/lib/dataStoreContext.js +40 -23
  174. package/lib/dataStoreContext.js.map +1 -1
  175. package/lib/dataStoreContexts.d.ts.map +1 -1
  176. package/lib/dataStoreContexts.js +7 -3
  177. package/lib/dataStoreContexts.js.map +1 -1
  178. package/lib/dataStoreRegistry.d.ts.map +1 -1
  179. package/lib/dataStoreRegistry.js +3 -1
  180. package/lib/dataStoreRegistry.js.map +1 -1
  181. package/lib/dataStores.d.ts +12 -9
  182. package/lib/dataStores.d.ts.map +1 -1
  183. package/lib/dataStores.js +74 -52
  184. package/lib/dataStores.js.map +1 -1
  185. package/lib/deltaScheduler.d.ts.map +1 -1
  186. package/lib/deltaScheduler.js +9 -4
  187. package/lib/deltaScheduler.js.map +1 -1
  188. package/lib/garbageCollection.d.ts +50 -26
  189. package/lib/garbageCollection.d.ts.map +1 -1
  190. package/lib/garbageCollection.js +347 -195
  191. package/lib/garbageCollection.js.map +1 -1
  192. package/lib/garbageCollectionConstants.d.ts +7 -3
  193. package/lib/garbageCollectionConstants.d.ts.map +1 -1
  194. package/lib/garbageCollectionConstants.js +9 -7
  195. package/lib/garbageCollectionConstants.js.map +1 -1
  196. package/lib/garbageCollectionHelpers.d.ts +15 -0
  197. package/lib/garbageCollectionHelpers.d.ts.map +1 -0
  198. package/lib/garbageCollectionHelpers.js +23 -0
  199. package/lib/garbageCollectionHelpers.js.map +1 -0
  200. package/lib/gcSweepReadyUsageDetection.d.ts +5 -5
  201. package/lib/gcSweepReadyUsageDetection.d.ts.map +1 -1
  202. package/lib/gcSweepReadyUsageDetection.js +14 -10
  203. package/lib/gcSweepReadyUsageDetection.js.map +1 -1
  204. package/lib/index.d.ts +3 -4
  205. package/lib/index.d.ts.map +1 -1
  206. package/lib/index.js +2 -3
  207. package/lib/index.js.map +1 -1
  208. package/lib/opLifecycle/batchManager.d.ts +13 -1
  209. package/lib/opLifecycle/batchManager.d.ts.map +1 -1
  210. package/lib/opLifecycle/batchManager.js +48 -7
  211. package/lib/opLifecycle/batchManager.js.map +1 -1
  212. package/lib/opLifecycle/definitions.d.ts +25 -1
  213. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  214. package/lib/opLifecycle/definitions.js.map +1 -1
  215. package/lib/opLifecycle/index.d.ts +2 -2
  216. package/lib/opLifecycle/index.d.ts.map +1 -1
  217. package/lib/opLifecycle/index.js +1 -1
  218. package/lib/opLifecycle/index.js.map +1 -1
  219. package/lib/opLifecycle/opCompressor.d.ts +1 -1
  220. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  221. package/lib/opLifecycle/opCompressor.js +24 -10
  222. package/lib/opLifecycle/opCompressor.js.map +1 -1
  223. package/lib/opLifecycle/opDecompressor.d.ts +2 -1
  224. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  225. package/lib/opLifecycle/opDecompressor.js +33 -17
  226. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  227. package/lib/opLifecycle/opSplitter.d.ts +34 -2
  228. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  229. package/lib/opLifecycle/opSplitter.js +116 -5
  230. package/lib/opLifecycle/opSplitter.js.map +1 -1
  231. package/lib/opLifecycle/outbox.d.ts +5 -0
  232. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  233. package/lib/opLifecycle/outbox.js +38 -27
  234. package/lib/opLifecycle/outbox.js.map +1 -1
  235. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  236. package/lib/opLifecycle/remoteMessageProcessor.js +17 -2
  237. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  238. package/lib/opProperties.d.ts.map +1 -1
  239. package/lib/opProperties.js +1 -3
  240. package/lib/opProperties.js.map +1 -1
  241. package/lib/orderedClientElection.d.ts.map +1 -1
  242. package/lib/orderedClientElection.js +10 -4
  243. package/lib/orderedClientElection.js.map +1 -1
  244. package/lib/packageVersion.d.ts +1 -1
  245. package/lib/packageVersion.js +1 -1
  246. package/lib/packageVersion.js.map +1 -1
  247. package/lib/pendingStateManager.d.ts +4 -13
  248. package/lib/pendingStateManager.d.ts.map +1 -1
  249. package/lib/pendingStateManager.js +134 -161
  250. package/lib/pendingStateManager.js.map +1 -1
  251. package/lib/runWhileConnectedCoordinator.d.ts.map +1 -1
  252. package/lib/runWhileConnectedCoordinator.js.map +1 -1
  253. package/lib/runningSummarizer.d.ts.map +1 -1
  254. package/lib/runningSummarizer.js +35 -23
  255. package/lib/runningSummarizer.js.map +1 -1
  256. package/lib/scheduleManager.d.ts +0 -1
  257. package/lib/scheduleManager.d.ts.map +1 -1
  258. package/lib/scheduleManager.js +11 -21
  259. package/lib/scheduleManager.js.map +1 -1
  260. package/lib/serializedSnapshotStorage.d.ts.map +1 -1
  261. package/lib/serializedSnapshotStorage.js +3 -1
  262. package/lib/serializedSnapshotStorage.js.map +1 -1
  263. package/lib/summarizer.d.ts +2 -3
  264. package/lib/summarizer.d.ts.map +1 -1
  265. package/lib/summarizer.js +39 -18
  266. package/lib/summarizer.js.map +1 -1
  267. package/lib/summarizerClientElection.d.ts +1 -2
  268. package/lib/summarizerClientElection.d.ts.map +1 -1
  269. package/lib/summarizerClientElection.js +3 -30
  270. package/lib/summarizerClientElection.js.map +1 -1
  271. package/lib/summarizerHandle.d.ts.map +1 -1
  272. package/lib/summarizerHandle.js.map +1 -1
  273. package/lib/summarizerHeuristics.d.ts.map +1 -1
  274. package/lib/summarizerHeuristics.js +6 -9
  275. package/lib/summarizerHeuristics.js.map +1 -1
  276. package/lib/summarizerTypes.d.ts +22 -25
  277. package/lib/summarizerTypes.d.ts.map +1 -1
  278. package/lib/summarizerTypes.js.map +1 -1
  279. package/lib/summaryCollection.d.ts.map +1 -1
  280. package/lib/summaryCollection.js +18 -8
  281. package/lib/summaryCollection.js.map +1 -1
  282. package/lib/summaryFormat.d.ts.map +1 -1
  283. package/lib/summaryFormat.js +20 -13
  284. package/lib/summaryFormat.js.map +1 -1
  285. package/lib/summaryGenerator.d.ts.map +1 -1
  286. package/lib/summaryGenerator.js +32 -14
  287. package/lib/summaryGenerator.js.map +1 -1
  288. package/lib/summaryManager.d.ts.map +1 -1
  289. package/lib/summaryManager.js +21 -9
  290. package/lib/summaryManager.js.map +1 -1
  291. package/lib/throttler.d.ts +2 -2
  292. package/lib/throttler.d.ts.map +1 -1
  293. package/lib/throttler.js +4 -4
  294. package/lib/throttler.js.map +1 -1
  295. package/package.json +27 -24
  296. package/prettier.config.cjs +1 -1
  297. package/src/batchTracker.ts +55 -50
  298. package/src/blobManager.ts +799 -593
  299. package/src/connectionTelemetry.ts +280 -249
  300. package/src/containerHandleContext.ts +27 -29
  301. package/src/containerRuntime.ts +3123 -2793
  302. package/src/dataStore.ts +172 -159
  303. package/src/dataStoreContext.ts +1048 -991
  304. package/src/dataStoreContexts.ts +178 -161
  305. package/src/dataStoreRegistry.ts +25 -20
  306. package/src/dataStores.ts +784 -711
  307. package/src/deltaScheduler.ts +158 -150
  308. package/src/garbageCollection.ts +1795 -1546
  309. package/src/garbageCollectionConstants.ts +10 -7
  310. package/src/garbageCollectionHelpers.ts +37 -0
  311. package/src/gcSweepReadyUsageDetection.ts +89 -83
  312. package/src/index.ts +67 -69
  313. package/src/opLifecycle/batchManager.ts +148 -86
  314. package/src/opLifecycle/definitions.ts +45 -19
  315. package/src/opLifecycle/index.ts +6 -5
  316. package/src/opLifecycle/opCompressor.ts +57 -39
  317. package/src/opLifecycle/opDecompressor.ts +104 -64
  318. package/src/opLifecycle/opSplitter.ts +226 -66
  319. package/src/opLifecycle/outbox.ts +206 -182
  320. package/src/opLifecycle/remoteMessageProcessor.ts +63 -47
  321. package/src/opProperties.ts +11 -9
  322. package/src/orderedClientElection.ts +489 -457
  323. package/src/packageVersion.ts +1 -1
  324. package/src/pendingStateManager.ts +379 -381
  325. package/src/runWhileConnectedCoordinator.ts +78 -71
  326. package/src/runningSummarizer.ts +619 -582
  327. package/src/scheduleManager.ts +299 -280
  328. package/src/serializedSnapshotStorage.ts +116 -111
  329. package/src/summarizer.ts +417 -381
  330. package/src/summarizerClientElection.ts +107 -129
  331. package/src/summarizerHandle.ts +11 -9
  332. package/src/summarizerHeuristics.ts +183 -186
  333. package/src/summarizerTypes.ts +344 -333
  334. package/src/summaryCollection.ts +378 -349
  335. package/src/summaryFormat.ts +146 -127
  336. package/src/summaryGenerator.ts +464 -406
  337. package/src/summaryManager.ts +377 -348
  338. package/src/throttler.ts +131 -122
  339. package/tsconfig.esnext.json +6 -6
  340. package/tsconfig.json +9 -13
package/dist/throttler.js CHANGED
@@ -55,7 +55,7 @@ class Throttler {
55
55
  }
56
56
  }
57
57
  // Remove all attempts that have already fallen out of the window.
58
- this.startTimes = this.startTimes.filter((t) => (now - t) < this.delayWindowMs);
58
+ this.startTimes = this.startTimes.filter((t) => now - t < this.delayWindowMs);
59
59
  // Compute delay, but do not exceed the specified max delay.
60
60
  const delayMs = Math.min(this.delayFn(this.startTimes.length), this.maxDelayMs);
61
61
  // Record this attempt start time.
@@ -84,7 +84,7 @@ exports.Throttler = Throttler;
84
84
  */
85
85
  const formExponentialFn = ({ multiplier = 2, coefficient = 1, offset = 0, initialDelay = undefined, } = {}) => (numAttempts) => Math.max(0, numAttempts <= 0 && initialDelay !== undefined
86
86
  ? initialDelay
87
- : coefficient * (Math.pow(multiplier, numAttempts)) + offset);
87
+ : coefficient * Math.pow(multiplier, numAttempts) + offset);
88
88
  exports.formExponentialFn = formExponentialFn;
89
89
  /** f(n) = C x (B^(n+A)) + F = (C x B^A) x B^n + F */
90
90
  const formExponentialFnWithAttemptOffset = (attemptOffset, { multiplier = 2, coefficient = 1, offset = 0, initialDelay = undefined, } = {}) => (0, exports.formExponentialFn)({
@@ -101,10 +101,10 @@ exports.formExponentialFnWithAttemptOffset = formExponentialFnWithAttemptOffset;
101
101
  * If not provided, coefficient will default to 1, and offset to 0, yielding:
102
102
  * 0 ms, 1 ms, 2 ms, 3 ms, ..., n ms delays; a linear back-off.
103
103
  */
104
- const formLinearFn = ({ coefficient = 1, offset = 0, } = {}) => (numAttempts) => Math.max(0, coefficient * numAttempts + offset);
104
+ const formLinearFn = ({ coefficient = 1, offset = 0 } = {}) => (numAttempts) => Math.max(0, coefficient * numAttempts + offset);
105
105
  exports.formLinearFn = formLinearFn;
106
106
  /** f(n) = C x (n+A) + F = C x n + (C x A + F) */
107
- const formLinearFnWithAttemptOffset = (attemptOffset, { coefficient = 1, offset = 0, } = {}) => (0, exports.formLinearFn)({
107
+ const formLinearFnWithAttemptOffset = (attemptOffset, { coefficient = 1, offset = 0 } = {}) => (0, exports.formLinearFn)({
108
108
  coefficient,
109
109
  offset: coefficient * attemptOffset + offset,
110
110
  });
@@ -1 +1 @@
1
- {"version":3,"file":"throttler.js","sourceRoot":"","sources":["../src/throttler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA2BH;;;GAGG;AACH,MAAa,SAAS;IAuBlB;IACI,qDAAqD;IACrC,aAAqB;IACrC,6CAA6C;IAC7B,UAAkB;IAClC;;;;OAIG;IACa,OAAwC;QARxC,kBAAa,GAAb,aAAa,CAAQ;QAErB,eAAU,GAAV,UAAU,CAAQ;QAMlB,YAAO,GAAP,OAAO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G,CAAC,EACzB,WAAW,GAAG,CAAC,EACf,MAAM,GAAG,CAAC,GACb,GAAG,EAAE,EAAyB,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EACzD,WAAW,GAAG,WAAW,GAAG,MAAM,CAAC,CAAC;AAJ3B,QAAA,YAAY,gBAIe;AAExC,iDAAiD;AAC1C,MAAM,6BAA6B,GAAG,CAAC,aAAqB,EAAE,EACjE,WAAW,GAAG,CAAC,EACf,MAAM,GAAG,CAAC,GACb,GAAG,EAAE,EAAE,EAAE,CAAC,IAAA,oBAAY,EAAC;IACpB,WAAW;IACX,MAAM,EAAE,WAAW,GAAG,aAAa,GAAG,MAAM;CAC/C,CAAC,CAAC;AANU,QAAA,6BAA6B,iCAMvC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport interface IThrottler {\n /**\n * Computes what the throttle delay should be, and records an attempt\n * which will be used for calculating future attempt delays.\n */\n getDelay(): number;\n\n /**\n * Number of attempts that occurred within the sliding window as of\n * the most recent delay computation.\n */\n readonly numAttempts: number;\n\n /** Width of sliding delay window in milliseconds. */\n readonly delayWindowMs: number;\n /** Maximum delay allowed in milliseconds. */\n readonly maxDelayMs: number;\n /**\n * Delay function used to calculate what the delay should be.\n * The input is the number of attempts that occurred within the sliding window.\n * The result is the calculated delay in milliseconds.\n */\n readonly delayFn: (numAttempts: number) => number;\n}\n\n/**\n * Used to give increasing delay times for throttling a single functionality.\n * Delay is based on previous attempts within specified time window, subtracting delay time.\n */\nexport class Throttler implements IThrottler {\n private startTimes: number[] = [];\n\n public get numAttempts() {\n return this.startTimes.length;\n }\n\n /**\n * Gets all attempt start times after compensating for the delay times\n * by adding the delay times to the actual times.\n */\n public getAttempts(): readonly number[] {\n return [...this.startTimes];\n }\n\n /**\n * Latest attempt time after compensating for the delay time itself\n * by adding the delay time to the actual time.\n */\n public get latestAttemptTime() {\n return this.startTimes.length > 0 ? this.startTimes[this.startTimes.length - 1] : undefined;\n }\n\n constructor(\n /** Width of sliding delay window in milliseconds. */\n public readonly delayWindowMs: number,\n /** Maximum delay allowed in milliseconds. */\n public readonly maxDelayMs: number,\n /**\n * Delay function used to calculate what the delay should be.\n * The input is the number of attempts that occurred within the sliding window.\n * The result is the calculated delay in milliseconds.\n */\n public readonly delayFn: (numAttempts: number) => number,\n ) { }\n\n public getDelay() {\n const now = Date.now();\n\n const latestAttemptTime = this.latestAttemptTime;\n if (latestAttemptTime !== undefined) {\n // If getDelay was called sooner than the most recent delay,\n // subtract the remaining time, since we previously added it.\n const earlyMs = latestAttemptTime - now;\n if (earlyMs > 0) {\n this.startTimes = this.startTimes.map((t) => t - earlyMs);\n }\n }\n\n // Remove all attempts that have already fallen out of the window.\n this.startTimes = this.startTimes.filter((t) => (now - t) < this.delayWindowMs);\n\n // Compute delay, but do not exceed the specified max delay.\n const delayMs = Math.min(this.delayFn(this.startTimes.length), this.maxDelayMs);\n\n // Record this attempt start time.\n this.startTimes.push(now);\n\n // Account for the delay time, by effectively removing it from the delay window.\n this.startTimes = this.startTimes.map((t) => t + delayMs);\n\n if (delayMs === this.maxDelayMs) {\n // We hit max delay, so adding more won't affect anything.\n // Shift off oldest time to stop this array from growing forever.\n this.startTimes.shift();\n }\n\n return delayMs;\n }\n}\n\n/**\n * Helper function to generate simple exponential throttle functions.\n * f(n) = [coefficient] x ([multiplier]^n) + [flatOffset]\n * where n = number of attempts, and f(n) = delay time in milliseconds.\n * If not provided, coefficient will default to 1, multiplier to 2,\n * minimum delay to 0, and the offset to 0, yielding:\n * 0 ms, 2 ms, 4 ms, 8 ms, ..., 2^n ms\n * where M = multiplier; an exponential back-off.\n * Use initialDelay to decide what should happen when numAttempts is 0,\n * leave it undefined to not special case.\n */\n export const formExponentialFn = ({\n multiplier = 2,\n coefficient = 1,\n offset = 0,\n initialDelay = undefined as number | undefined,\n} = {}): IThrottler[\"delayFn\"] => (numAttempts) => Math.max(0,\n numAttempts <= 0 && initialDelay !== undefined\n ? initialDelay\n : coefficient * (Math.pow(multiplier, numAttempts)) + offset);\n\n/** f(n) = C x (B^(n+A)) + F = (C x B^A) x B^n + F */\nexport const formExponentialFnWithAttemptOffset = (attemptOffset: number, {\n multiplier = 2,\n coefficient = 1,\n offset = 0,\n initialDelay = undefined as number | undefined,\n} = {}) => formExponentialFn({\n multiplier,\n coefficient: coefficient * Math.pow(multiplier, attemptOffset),\n offset,\n initialDelay,\n});\n\n/**\n * Helper function to generate simple linear throttle functions.\n * f(n) = [coefficient] x n + [flatOffset]\n * where n = number of attempts, and f(n) = delay time in milliseconds.\n * If not provided, coefficient will default to 1, and offset to 0, yielding:\n * 0 ms, 1 ms, 2 ms, 3 ms, ..., n ms delays; a linear back-off.\n */\nexport const formLinearFn = ({\n coefficient = 1,\n offset = 0,\n} = {}): IThrottler[\"delayFn\"] => (numAttempts) => Math.max(0,\n coefficient * numAttempts + offset);\n\n/** f(n) = C x (n+A) + F = C x n + (C x A + F) */\nexport const formLinearFnWithAttemptOffset = (attemptOffset: number, {\n coefficient = 1,\n offset = 0,\n} = {}) => formLinearFn({\n coefficient,\n offset: coefficient * attemptOffset + offset,\n});\n"]}
1
+ {"version":3,"file":"throttler.js","sourceRoot":"","sources":["../src/throttler.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA2BH;;;GAGG;AACH,MAAa,SAAS;IAuBrB;IACC,qDAAqD;IACrC,aAAqB;IACrC,6CAA6C;IAC7B,UAAkB;IAClC;;;;OAIG;IACa,OAAwC;QARxC,kBAAa,GAAb,aAAa,CAAQ;QAErB,eAAU,GAAV,UAAU,CAAQ;QAMlB,YAAO,GAAP,OAAO,CAAiC;QAhCjD,eAAU,GAAa,EAAE,CAAC;IAiC/B,CAAC;IA/BJ,IAAW,WAAW;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACI,WAAW;QACjB,OAAO,CAAC,G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rC,QAAA,YAAY,gBAGyB;AAElD,iDAAiD;AAC1C,MAAM,6BAA6B,GAAG,CAC5C,aAAqB,EACrB,EAAE,WAAW,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,EAAE,GAAG,EAAE,EACnC,EAAE,CACH,IAAA,oBAAY,EAAC;IACZ,WAAW;IACX,MAAM,EAAE,WAAW,GAAG,aAAa,GAAG,MAAM;CAC5C,CAAC,CAAC;AAPS,QAAA,6BAA6B,iCAOtC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport interface IThrottler {\n\t/**\n\t * Computes what the throttle delay should be, and records an attempt\n\t * which will be used for calculating future attempt delays.\n\t */\n\tgetDelay(): number;\n\n\t/**\n\t * Number of attempts that occurred within the sliding window as of\n\t * the most recent delay computation.\n\t */\n\treadonly numAttempts: number;\n\n\t/** Width of sliding delay window in milliseconds. */\n\treadonly delayWindowMs: number;\n\t/** Maximum delay allowed in milliseconds. */\n\treadonly maxDelayMs: number;\n\t/**\n\t * Delay function used to calculate what the delay should be.\n\t * The input is the number of attempts that occurred within the sliding window.\n\t * The result is the calculated delay in milliseconds.\n\t */\n\treadonly delayFn: (numAttempts: number) => number;\n}\n\n/**\n * Used to give increasing delay times for throttling a single functionality.\n * Delay is based on previous attempts within specified time window, subtracting delay time.\n */\nexport class Throttler implements IThrottler {\n\tprivate startTimes: number[] = [];\n\n\tpublic get numAttempts() {\n\t\treturn this.startTimes.length;\n\t}\n\n\t/**\n\t * Gets all attempt start times after compensating for the delay times\n\t * by adding the delay times to the actual times.\n\t */\n\tpublic getAttempts(): readonly number[] {\n\t\treturn [...this.startTimes];\n\t}\n\n\t/**\n\t * Latest attempt time after compensating for the delay time itself\n\t * by adding the delay time to the actual time.\n\t */\n\tpublic get latestAttemptTime() {\n\t\treturn this.startTimes.length > 0 ? this.startTimes[this.startTimes.length - 1] : undefined;\n\t}\n\n\tconstructor(\n\t\t/** Width of sliding delay window in milliseconds. */\n\t\tpublic readonly delayWindowMs: number,\n\t\t/** Maximum delay allowed in milliseconds. */\n\t\tpublic readonly maxDelayMs: number,\n\t\t/**\n\t\t * Delay function used to calculate what the delay should be.\n\t\t * The input is the number of attempts that occurred within the sliding window.\n\t\t * The result is the calculated delay in milliseconds.\n\t\t */\n\t\tpublic readonly delayFn: (numAttempts: number) => number,\n\t) {}\n\n\tpublic getDelay() {\n\t\tconst now = Date.now();\n\n\t\tconst latestAttemptTime = this.latestAttemptTime;\n\t\tif (latestAttemptTime !== undefined) {\n\t\t\t// If getDelay was called sooner than the most recent delay,\n\t\t\t// subtract the remaining time, since we previously added it.\n\t\t\tconst earlyMs = latestAttemptTime - now;\n\t\t\tif (earlyMs > 0) {\n\t\t\t\tthis.startTimes = this.startTimes.map((t) => t - earlyMs);\n\t\t\t}\n\t\t}\n\n\t\t// Remove all attempts that have already fallen out of the window.\n\t\tthis.startTimes = this.startTimes.filter((t) => now - t < this.delayWindowMs);\n\n\t\t// Compute delay, but do not exceed the specified max delay.\n\t\tconst delayMs = Math.min(this.delayFn(this.startTimes.length), this.maxDelayMs);\n\n\t\t// Record this attempt start time.\n\t\tthis.startTimes.push(now);\n\n\t\t// Account for the delay time, by effectively removing it from the delay window.\n\t\tthis.startTimes = this.startTimes.map((t) => t + delayMs);\n\n\t\tif (delayMs === this.maxDelayMs) {\n\t\t\t// We hit max delay, so adding more won't affect anything.\n\t\t\t// Shift off oldest time to stop this array from growing forever.\n\t\t\tthis.startTimes.shift();\n\t\t}\n\n\t\treturn delayMs;\n\t}\n}\n\n/**\n * Helper function to generate simple exponential throttle functions.\n * f(n) = [coefficient] x ([multiplier]^n) + [flatOffset]\n * where n = number of attempts, and f(n) = delay time in milliseconds.\n * If not provided, coefficient will default to 1, multiplier to 2,\n * minimum delay to 0, and the offset to 0, yielding:\n * 0 ms, 2 ms, 4 ms, 8 ms, ..., 2^n ms\n * where M = multiplier; an exponential back-off.\n * Use initialDelay to decide what should happen when numAttempts is 0,\n * leave it undefined to not special case.\n */\nexport const formExponentialFn =\n\t({\n\t\tmultiplier = 2,\n\t\tcoefficient = 1,\n\t\toffset = 0,\n\t\tinitialDelay = undefined as number | undefined,\n\t} = {}): IThrottler[\"delayFn\"] =>\n\t(numAttempts) =>\n\t\tMath.max(\n\t\t\t0,\n\t\t\tnumAttempts <= 0 && initialDelay !== undefined\n\t\t\t\t? initialDelay\n\t\t\t\t: coefficient * Math.pow(multiplier, numAttempts) + offset,\n\t\t);\n\n/** f(n) = C x (B^(n+A)) + F = (C x B^A) x B^n + F */\nexport const formExponentialFnWithAttemptOffset = (\n\tattemptOffset: number,\n\t{\n\t\tmultiplier = 2,\n\t\tcoefficient = 1,\n\t\toffset = 0,\n\t\tinitialDelay = undefined as number | undefined,\n\t} = {},\n) =>\n\tformExponentialFn({\n\t\tmultiplier,\n\t\tcoefficient: coefficient * Math.pow(multiplier, attemptOffset),\n\t\toffset,\n\t\tinitialDelay,\n\t});\n\n/**\n * Helper function to generate simple linear throttle functions.\n * f(n) = [coefficient] x n + [flatOffset]\n * where n = number of attempts, and f(n) = delay time in milliseconds.\n * If not provided, coefficient will default to 1, and offset to 0, yielding:\n * 0 ms, 1 ms, 2 ms, 3 ms, ..., n ms delays; a linear back-off.\n */\nexport const formLinearFn =\n\t({ coefficient = 1, offset = 0 } = {}): IThrottler[\"delayFn\"] =>\n\t(numAttempts) =>\n\t\tMath.max(0, coefficient * numAttempts + offset);\n\n/** f(n) = C x (n+A) + F = C x n + (C x A + F) */\nexport const formLinearFnWithAttemptOffset = (\n\tattemptOffset: number,\n\t{ coefficient = 1, offset = 0 } = {},\n) =>\n\tformLinearFn({\n\t\tcoefficient,\n\t\toffset: coefficient * attemptOffset + offset,\n\t});\n"]}
@@ -1,35 +1,47 @@
1
1
  # Garbage Collection
2
+
2
3
  Garbage collection (GC) is the process by which Fluid Framework safely delete objects that are not used. The only responsibility of the users of Fluid Framework is to add and remove references to Fluid objects correctly.
3
4
 
4
5
  ## Why have Garbage Collection?
6
+
5
7
  GC reduces the size of the Fluid file at rest, the in-memory content and the summary that is uploaded to / downloaded from the server. It saves COGS on the server and it makes containers load faster as there is less data to download and process.
6
8
 
7
9
  ## What do I need to do?
10
+
8
11
  All Fluid objects that are in use must be properly referenced so that they are not deleted by GC. Similarly, references to all unused Fluid objects should be removed so that they can be deleted by GC. It is the responsibility of the users of Fluid Framework to correctly add and remove references to Fluid objects.
9
12
 
10
13
  ## How do I reference / unreference Fluid objects?
14
+
11
15
  Currently, the only Fluid objects that are eligible for GC are data stores and attachment blobs. The following sections describe how you can mark them as referenced or unreferenced. These sections speak of a "referenced DDS" which refers to a DDS that is created by a referenced data store.
16
+
12
17
  ### Data stores
18
+
13
19
  There are 2 ways to reference a data store:
14
- - Store the data stores's handle (see [IFluidHandle](../../../common/lib/core-interfaces/src/handles.ts)) in a referenced DDS that supports handle in its data. For example, a data store's handle can be stored in a referenced `SharedMap` DDS.
20
+
21
+ - Store the data stores's handle (see [IFluidHandle](../../../common/lib/core-interfaces/src/handles.ts)) in a referenced DDS that supports handle in its data. For example, a data store's handle can be stored in a referenced `SharedMap` DDS.
15
22
 
16
23
  Note that storing a handle of any of a data store's DDS will also mark the data store as referenced.
17
- - Alias the data store. Aliased data stores are rooted in the container, i.e., they are always referenced and cannot be unreferenced later. Aliased data stores can never be deleted so only do so if you want them to live forever.
24
+
25
+ - Alias the data store. Aliased data stores are rooted in the container, i.e., they are always referenced and cannot be unreferenced later. Aliased data stores can never be deleted so only do so if you want them to live forever.
18
26
 
19
27
  Once there are no more referenced DDSes in the container containing a handle to a particular data store, that data store is unreferenced and is eligible for GC.
20
28
 
21
29
  > Note: There should be at least one aliased data store with at least one DDS in a container. This is the starting point for GC to look for other referenced objects in the container.
22
30
 
23
31
  ### Attachment blobs
32
+
24
33
  The only way to reference an attachment blob is to store its IFluidHandle in a referenced DDS similar to data stores.
25
34
 
26
35
  Once there are no more referenced DDSes in the container containing a handle to a particular attachment blob, that attachment blob is unreferenced and is eligible for GC.
27
36
 
28
37
  ## GC algorithm
38
+
29
39
  The GC algorithm runs in two phases:
30
40
 
31
41
  ### Mark phase
42
+
32
43
  In this phase, the GC algorithm identifies all Fluid objects that are unreferenced and marks them as such:
44
+
33
45
  1. It starts at the root (aliased) data stores and marks them and all their DDSes as referenced.
34
46
  2. It recursively finds the handles stored in referenced DDSes and marks the objects corresponding to the handles as referenced until is has scanned all objects.
35
47
  3. All the objects in the system that are not marked as referenced are marked as unreferenced. The unreferenced state of the object and timestamp of when it is unreferenced is added to the summary. The timestamp is used to determine how long the object has been unreferenced for and is used for the sweep phase.
@@ -41,6 +53,7 @@ If you wish to disable this, set the `gcAllowed` option to `false` in `IGCRuntim
41
53
  See `IGCRuntimeOptions` in [containerRuntime.ts](./src/containerRuntime.ts) for more options to control GC behavior.
42
54
 
43
55
  ### Sweep phase
56
+
44
57
  In this phase, the GC algorithm identifies all Fluid objects that have been unreferenced for a specific amount of time (typically 30-40 days) and deletes them. Objects are only swept once the GC system is sure that they could never be referenced again by any active clients, i.e., clients that have the object in memory and could reference it.
45
58
 
46
59
  GC sweep phase has not been enabled yet. More details will be added here when sweep is enabled.
@@ -2,8 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- /// <reference types="node" />
6
- import EventEmitter from "events";
5
+ import { EventEmitter } from "events";
7
6
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
8
7
  export declare class BatchTracker {
9
8
  private readonly batchEventEmitter;
@@ -1 +1 @@
1
- {"version":3,"file":"batchTracker.d.ts","sourceRoot":"","sources":["../src/batchTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAKtE,qBAAa,YAAY;IAOjB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IANtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,wBAAwB,CAAqB;IACrD,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,6BAA6B,CAAqB;gBAGrC,iBAAiB,EAAE,YAAY,EAChD,MAAM,EAAE,gBAAgB,EACxB,oBAAoB,EAAE,MAAM,EAC5B,sBAAsB,EAAE,MAAM,EAC9B,gBAAgB,GAAE,MAAM,MAAgC;CAyC/D;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,sBACN,YAAY,UACvB,gBAAgB,yBACF,MAAM,2BACJ,MAAM,iBAC4D,CAAC"}
1
+ {"version":3,"file":"batchTracker.d.ts","sourceRoot":"","sources":["../src/batchTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAKtE,qBAAa,YAAY;IAOvB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IANnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,wBAAwB,CAAqB;IACrD,OAAO,CAAC,iBAAiB,CAAa;IACtC,OAAO,CAAC,6BAA6B,CAAqB;gBAGxC,iBAAiB,EAAE,YAAY,EAChD,MAAM,EAAE,gBAAgB,EACxB,oBAAoB,EAAE,MAAM,EAC5B,sBAAsB,EAAE,MAAM,EAC9B,gBAAgB,GAAE,MAAM,MAAgC;CA8CzD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,sBACT,YAAY,UACvB,gBAAgB,yBACF,MAAM,2BACJ,MAAM,iBAC+D,CAAC"}
@@ -15,7 +15,8 @@ export class BatchTracker {
15
15
  this.trackedBatchCount++;
16
16
  });
17
17
  this.batchEventEmitter.on("batchEnd", (error, message) => {
18
- assert(this.startBatchSequenceNumber !== undefined && this.batchProcessingStartTimeStamp !== undefined, 0x2ba /* "batchBegin must fire before batchEnd" */);
18
+ assert(this.startBatchSequenceNumber !== undefined &&
19
+ this.batchProcessingStartTimeStamp !== undefined, 0x2ba /* "batchBegin must fire before batchEnd" */);
19
20
  const length = message.sequenceNumber - this.startBatchSequenceNumber + 1;
20
21
  if (length >= batchLengthThreshold) {
21
22
  this.logger.sendPerformanceEvent({
@@ -1 +1 @@
1
- {"version":3,"file":"batchTracker.js","sourceRoot":"","sources":["../src/batchTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,MAAM,OAAO,YAAY;IAMrB,YACqB,iBAA+B,EAChD,MAAwB,EACxB,oBAA4B,EAC5B,sBAA8B,EAC9B,mBAAiC,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE;QAJvC,sBAAiB,GAAjB,iBAAiB,CAAc;QAJ5C,sBAAiB,GAAW,CAAC,CAAC;QAUlC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAErD,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,OAAkC,EAAE,EAAE;YAC3E,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC;YACvD,IAAI,CAAC,6BAA6B,GAAG,gBAAgB,EAAE,CAAC;YACxD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,KAAsB,EAAE,OAAkC,EAAE,EAAE;YACjG,MAAM,CACF,IAAI,CAAC,wBAAwB,KAAK,SAAS,IAAI,IAAI,CAAC,6BAA6B,KAAK,SAAS,EAC/F,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAExD,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAAC;YAC1E,IAAI,MAAM,IAAI,oBAAoB,EAAE;gBAChC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAC7B,SAAS,EAAE,cAAc;oBACzB,MAAM;oBACN,SAAS,EAAE,oBAAoB;oBAC/B,sBAAsB,EAAE,OAAO,CAAC,cAAc;oBAC9C,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,6BAA6B;oBACjE,UAAU,EAAE,KAAK,KAAK,SAAS;iBAClC,CAAC,CAAC;aACN;YAED,IAAI,IAAI,CAAC,iBAAiB,GAAG,sBAAsB,KAAK,CAAC,EAAE;gBACvD,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAC7B,SAAS,EAAE,QAAQ;oBACnB,MAAM;oBACN,YAAY,EAAE,sBAAsB;oBACpC,sBAAsB,EAAE,OAAO,CAAC,cAAc;oBAC9C,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,6BAA6B;iBACpE,CAAC,CAAC;aACN;YAED,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;YAC1C,IAAI,CAAC,6BAA6B,GAAG,SAAS,CAAC;QACnD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC5B,iBAA+B,EAC/B,MAAwB,EACxB,uBAA+B,IAAI,EACnC,yBAAiC,IAAI,EACvC,EAAE,CAAC,IAAI,YAAY,CAAC,iBAAiB,EAAE,MAAM,EAAE,oBAAoB,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport EventEmitter from \"events\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\n\nexport class BatchTracker {\n private readonly logger: ITelemetryLogger;\n private startBatchSequenceNumber: number | undefined;\n private trackedBatchCount: number = 0;\n private batchProcessingStartTimeStamp: number | undefined;\n\n constructor(\n private readonly batchEventEmitter: EventEmitter,\n logger: ITelemetryLogger,\n batchLengthThreshold: number,\n batchCountSamplingRate: number,\n dateTimeProvider: () => number = () => performance.now(),\n ) {\n this.logger = ChildLogger.create(logger, \"Batching\");\n\n this.batchEventEmitter.on(\"batchBegin\", (message: ISequencedDocumentMessage) => {\n this.startBatchSequenceNumber = message.sequenceNumber;\n this.batchProcessingStartTimeStamp = dateTimeProvider();\n this.trackedBatchCount++;\n });\n\n this.batchEventEmitter.on(\"batchEnd\", (error: any | undefined, message: ISequencedDocumentMessage) => {\n assert(\n this.startBatchSequenceNumber !== undefined && this.batchProcessingStartTimeStamp !== undefined,\n 0x2ba /* \"batchBegin must fire before batchEnd\" */);\n\n const length = message.sequenceNumber - this.startBatchSequenceNumber + 1;\n if (length >= batchLengthThreshold) {\n this.logger.sendPerformanceEvent({\n eventName: \"LengthTooBig\",\n length,\n threshold: batchLengthThreshold,\n batchEndSequenceNumber: message.sequenceNumber,\n duration: dateTimeProvider() - this.batchProcessingStartTimeStamp,\n batchError: error !== undefined,\n });\n }\n\n if (this.trackedBatchCount % batchCountSamplingRate === 0) {\n this.logger.sendPerformanceEvent({\n eventName: \"Length\",\n length,\n samplingRate: batchCountSamplingRate,\n batchEndSequenceNumber: message.sequenceNumber,\n duration: dateTimeProvider() - this.batchProcessingStartTimeStamp,\n });\n }\n\n this.startBatchSequenceNumber = undefined;\n this.batchProcessingStartTimeStamp = undefined;\n });\n }\n}\n\n/**\n * Track batch sizes in terms of op counts and processing times\n *\n * @param batchEventEmitter - event emitter which tracks the lifecycle of batch operations\n * @param logger - See {@link @fluidframework/common-definitions#ITelemetryLogger}\n * @param batchLengthThreshold - threshold for the length of a batch when to send an error event\n * @param batchCountSamplingRate - rate for batches for which to send an event with its characteristics\n */\nexport const BindBatchTracker = (\n batchEventEmitter: EventEmitter,\n logger: ITelemetryLogger,\n batchLengthThreshold: number = 1000,\n batchCountSamplingRate: number = 1000,\n) => new BatchTracker(batchEventEmitter, logger, batchLengthThreshold, batchCountSamplingRate);\n"]}
1
+ {"version":3,"file":"batchTracker.js","sourceRoot":"","sources":["../src/batchTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,MAAM,OAAO,YAAY;IAMxB,YACkB,iBAA+B,EAChD,MAAwB,EACxB,oBAA4B,EAC5B,sBAA8B,EAC9B,mBAAiC,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE;QAJvC,sBAAiB,GAAjB,iBAAiB,CAAc;QAJzC,sBAAiB,GAAW,CAAC,CAAC;QAUrC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAErD,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,OAAkC,EAAE,EAAE;YAC9E,IAAI,CAAC,wBAAwB,GAAG,OAAO,CAAC,cAAc,CAAC;YACvD,IAAI,CAAC,6BAA6B,GAAG,gBAAgB,EAAE,CAAC;YACxD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC1B,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,iBAAiB,CAAC,EAAE,CACxB,UAAU,EACV,CAAC,KAAsB,EAAE,OAAkC,EAAE,EAAE;YAC9D,MAAM,CACL,IAAI,CAAC,wBAAwB,KAAK,SAAS;gBAC1C,IAAI,CAAC,6BAA6B,KAAK,SAAS,EACjD,KAAK,CAAC,4CAA4C,CAClD,CAAC;YAEF,MAAM,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAAC;YAC1E,IAAI,MAAM,IAAI,oBAAoB,EAAE;gBACnC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAChC,SAAS,EAAE,cAAc;oBACzB,MAAM;oBACN,SAAS,EAAE,oBAAoB;oBAC/B,sBAAsB,EAAE,OAAO,CAAC,cAAc;oBAC9C,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,6BAA6B;oBACjE,UAAU,EAAE,KAAK,KAAK,SAAS;iBAC/B,CAAC,CAAC;aACH;YAED,IAAI,IAAI,CAAC,iBAAiB,GAAG,sBAAsB,KAAK,CAAC,EAAE;gBAC1D,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC;oBAChC,SAAS,EAAE,QAAQ;oBACnB,MAAM;oBACN,YAAY,EAAE,sBAAsB;oBACpC,sBAAsB,EAAE,OAAO,CAAC,cAAc;oBAC9C,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC,6BAA6B;iBACjE,CAAC,CAAC;aACH;YAED,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;YAC1C,IAAI,CAAC,6BAA6B,GAAG,SAAS,CAAC;QAChD,CAAC,CACD,CAAC;IACH,CAAC;CACD;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC/B,iBAA+B,EAC/B,MAAwB,EACxB,uBAA+B,IAAI,EACnC,yBAAiC,IAAI,EACpC,EAAE,CAAC,IAAI,YAAY,CAAC,iBAAiB,EAAE,MAAM,EAAE,oBAAoB,EAAE,sBAAsB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"events\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, performance } from \"@fluidframework/common-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\n\nexport class BatchTracker {\n\tprivate readonly logger: ITelemetryLogger;\n\tprivate startBatchSequenceNumber: number | undefined;\n\tprivate trackedBatchCount: number = 0;\n\tprivate batchProcessingStartTimeStamp: number | undefined;\n\n\tconstructor(\n\t\tprivate readonly batchEventEmitter: EventEmitter,\n\t\tlogger: ITelemetryLogger,\n\t\tbatchLengthThreshold: number,\n\t\tbatchCountSamplingRate: number,\n\t\tdateTimeProvider: () => number = () => performance.now(),\n\t) {\n\t\tthis.logger = ChildLogger.create(logger, \"Batching\");\n\n\t\tthis.batchEventEmitter.on(\"batchBegin\", (message: ISequencedDocumentMessage) => {\n\t\t\tthis.startBatchSequenceNumber = message.sequenceNumber;\n\t\t\tthis.batchProcessingStartTimeStamp = dateTimeProvider();\n\t\t\tthis.trackedBatchCount++;\n\t\t});\n\n\t\tthis.batchEventEmitter.on(\n\t\t\t\"batchEnd\",\n\t\t\t(error: any | undefined, message: ISequencedDocumentMessage) => {\n\t\t\t\tassert(\n\t\t\t\t\tthis.startBatchSequenceNumber !== undefined &&\n\t\t\t\t\t\tthis.batchProcessingStartTimeStamp !== undefined,\n\t\t\t\t\t0x2ba /* \"batchBegin must fire before batchEnd\" */,\n\t\t\t\t);\n\n\t\t\t\tconst length = message.sequenceNumber - this.startBatchSequenceNumber + 1;\n\t\t\t\tif (length >= batchLengthThreshold) {\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\teventName: \"LengthTooBig\",\n\t\t\t\t\t\tlength,\n\t\t\t\t\t\tthreshold: batchLengthThreshold,\n\t\t\t\t\t\tbatchEndSequenceNumber: message.sequenceNumber,\n\t\t\t\t\t\tduration: dateTimeProvider() - this.batchProcessingStartTimeStamp,\n\t\t\t\t\t\tbatchError: error !== undefined,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tif (this.trackedBatchCount % batchCountSamplingRate === 0) {\n\t\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\t\teventName: \"Length\",\n\t\t\t\t\t\tlength,\n\t\t\t\t\t\tsamplingRate: batchCountSamplingRate,\n\t\t\t\t\t\tbatchEndSequenceNumber: message.sequenceNumber,\n\t\t\t\t\t\tduration: dateTimeProvider() - this.batchProcessingStartTimeStamp,\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tthis.startBatchSequenceNumber = undefined;\n\t\t\t\tthis.batchProcessingStartTimeStamp = undefined;\n\t\t\t},\n\t\t);\n\t}\n}\n\n/**\n * Track batch sizes in terms of op counts and processing times\n *\n * @param batchEventEmitter - event emitter which tracks the lifecycle of batch operations\n * @param logger - See {@link @fluidframework/common-definitions#ITelemetryLogger}\n * @param batchLengthThreshold - threshold for the length of a batch when to send an error event\n * @param batchCountSamplingRate - rate for batches for which to send an event with its characteristics\n */\nexport const BindBatchTracker = (\n\tbatchEventEmitter: EventEmitter,\n\tlogger: ITelemetryLogger,\n\tbatchLengthThreshold: number = 1000,\n\tbatchCountSamplingRate: number = 1000,\n) => new BatchTracker(batchEventEmitter, logger, batchLengthThreshold, batchCountSamplingRate);\n"]}
@@ -40,30 +40,37 @@ export interface IPendingBlobs {
40
40
  blob: string;
41
41
  };
42
42
  }
43
- export declare class BlobManager {
43
+ export interface IBlobManagerEvents {
44
+ (event: "noPendingBlobs", listener: () => void): any;
45
+ }
46
+ export declare class BlobManager extends TypedEventEmitter<IBlobManagerEvents> {
44
47
  private readonly routeContext;
45
48
  private readonly getStorage;
46
49
  /**
47
- * Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which
48
- * the blob is deleted. The BlobAttach op notifies the server that blob is in use. The server
49
- * will then not delete the blob as long as it is listed as referenced in future summaries.
50
- * The summarizing client will know to include the storage ID in the summary when it sees the op.
50
+ * Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which the blob is
51
+ * deleted. The BlobAttach op notifies the server that blob is in use. The server will then not delete the
52
+ * the blob as long as it is listed as referenced in future summaries. The summarizing client will know to
53
+ * include the storage ID in the summary when it sees the op.
51
54
  *
52
- * The op may also include a local ID to inform all clients of the relation to the storage
53
- * ID, without knowledge of which they cannot request the blob from storage. This is also
54
- * included in the redirect table in the summary.
55
+ * The op will also include a local ID to inform all clients of the relation to the storage ID, without
56
+ * knowledge of which they cannot request the blob from storage. It's important that this op is sequenced
57
+ * before any ops that reference the local ID, otherwise, an invalid handle could be added to the document.
55
58
  */
56
59
  private readonly sendBlobAttachOp;
57
- private readonly gcNodeUpdated;
60
+ private readonly blobRequested;
61
+ private readonly addedBlobReference;
62
+ private readonly isBlobDeleted;
58
63
  private readonly runtime;
64
+ private readonly getCurrentReferenceTimestampMs;
59
65
  static readonly basePath = "_blobs";
60
66
  private static readonly redirectTableBlobName;
61
67
  private readonly mc;
62
68
  /**
63
- * Map of local (offline/detached) IDs to storage IDs. Contains identity entries
64
- * (id id) for storage IDs, so all requested IDs should be a key in this map.
65
- * Blobs created while the container is detached are stored in IDetachedBlobStorage
66
- * which gives local IDs; the storage IDs are filled in at attach time.
69
+ * Map of local IDs to storage IDs. Contains identity entries (id → id) for storage IDs. All requested IDs should
70
+ * be a key in this map. Blobs created while the container is detached are stored in IDetachedBlobStorage which
71
+ * gives local IDs; the storage IDs are filled in at attach time.
72
+ * Note: It contains mappings from all clients, i.e., from remote clients as well. local ID comes from the client
73
+ * that uploaded the blob but its mapping to storage ID is needed in all clients in order to retrieve the blob.
67
74
  */
68
75
  private readonly redirectTable;
69
76
  /**
@@ -73,32 +80,34 @@ export declare class BlobManager {
73
80
  */
74
81
  private readonly pendingBlobs;
75
82
  /**
76
- * Track ops in flight for online flow. Used to avoid searching pendingBlobs since BlobAttach ops
77
- * don't include local ID in online flow.
83
+ * Track ops in flight for online flow. This is used for optimizations where if we receive an ack for a storage ID,
84
+ * we can resolve all pending blobs with the same storage ID even though they may have different local IDs. That's
85
+ * because we know that the server will not delete the blob corresponding to that storage ID.
78
86
  */
79
87
  private readonly opsInFlight;
80
88
  private readonly retryThrottler;
81
89
  /** If true, throw an error when a tombstone attachment blob is retrieved. */
82
- private readonly throwOnTombstoneUsage;
90
+ private readonly throwOnTombstoneLoad;
83
91
  /**
84
- * This stores ides of tombstoned blobs.
92
+ * This stores IDs of tombstoned blobs.
85
93
  * Tombstone is a temporary feature that imitates a blob getting swept by garbage collection.
86
94
  */
87
95
  private readonly tombstonedBlobs;
88
96
  constructor(routeContext: IFluidHandleContext, snapshot: IBlobManagerLoadInfo, getStorage: () => IDocumentStorageService,
89
97
  /**
90
- * Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which
91
- * the blob is deleted. The BlobAttach op notifies the server that blob is in use. The server
92
- * will then not delete the blob as long as it is listed as referenced in future summaries.
93
- * The summarizing client will know to include the storage ID in the summary when it sees the op.
98
+ * Submit a BlobAttach op. When a blob is uploaded, there is a short grace period before which the blob is
99
+ * deleted. The BlobAttach op notifies the server that blob is in use. The server will then not delete the
100
+ * the blob as long as it is listed as referenced in future summaries. The summarizing client will know to
101
+ * include the storage ID in the summary when it sees the op.
94
102
  *
95
- * The op may also include a local ID to inform all clients of the relation to the storage
96
- * ID, without knowledge of which they cannot request the blob from storage. This is also
97
- * included in the redirect table in the summary.
103
+ * The op will also include a local ID to inform all clients of the relation to the storage ID, without
104
+ * knowledge of which they cannot request the blob from storage. It's important that this op is sequenced
105
+ * before any ops that reference the local ID, otherwise, an invalid handle could be added to the document.
98
106
  */
99
- sendBlobAttachOp: (storageId?: string, localId?: string) => void, gcNodeUpdated: (blobPath: string) => void, runtime: IBlobManagerRuntime, stashedBlobs?: IPendingBlobs);
107
+ sendBlobAttachOp: (localId: string, storageId?: string) => void, blobRequested: (blobPath: string) => void, addedBlobReference: (fromNodePath: string, toNodePath: string) => void, isBlobDeleted: (blobPath: string) => boolean, runtime: IBlobManagerRuntime, stashedBlobs: IPendingBlobs | undefined, getCurrentReferenceTimestampMs: () => number | undefined);
100
108
  private get pendingOfflineUploads();
101
109
  get hasPendingOfflineUploads(): boolean;
110
+ get hasPendingBlobs(): boolean;
102
111
  /**
103
112
  * Upload blobs added while offline. This must be completed before connecting and resubmitting ops.
104
113
  */
@@ -124,6 +133,12 @@ export declare class BlobManager {
124
133
  private createBlobDetached;
125
134
  createBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>>;
126
135
  private uploadBlob;
136
+ /**
137
+ * Set up a mapping in the redirect table from fromId to toId. Also, notify the runtime that a reference is added
138
+ * which is required for GC.
139
+ */
140
+ private setRedirection;
141
+ private deleteAndEmitsIfEmpty;
127
142
  private onUploadResolve;
128
143
  private onUploadReject;
129
144
  private transitionToOffline;
@@ -133,6 +148,7 @@ export declare class BlobManager {
133
148
  * @param metadata - op metadata containing storage and/or local IDs
134
149
  */
135
150
  reSubmit(metadata: Record<string, unknown> | undefined): void;
151
+ private logTimeInfo;
136
152
  processBlobAttachOp(message: ISequencedDocumentMessage, local: boolean): void;
137
153
  /**
138
154
  * Reads blobs needed to load BlobManager from storage.
@@ -153,18 +169,21 @@ export declare class BlobManager {
153
169
  */
154
170
  getGCData(fullGC?: boolean): IGarbageCollectionData;
155
171
  /**
156
- * This is called to update blobs whose routes are used. The used blobs are removed from the tombstone list.
157
- * @param usedRoutes - The routes of the blob nodes that are used.
172
+ * This is called to update blobs whose routes are unused. The unused blobs are deleted.
173
+ * @param unusedRoutes - The routes of the blob nodes that are unused.
158
174
  */
159
- updateUsedRoutes(usedRoutes: string[]): void;
175
+ updateUnusedRoutes(unusedRoutes: string[]): void;
160
176
  /**
161
- * This is called to update blobs whose routes are unused. The unused blobs are either deleted or marked as
162
- * tombstones.
163
- * @param unusedRoutes - The routes of the blob nodes that are unused.
164
- * @param tombstone - if true, the objects corresponding to unused routes are marked tombstones. Otherwise, they
165
- * are deleted.
177
+ * This is called to update blobs whose routes are tombstones. Tombstoned blobs enable testing scenarios with
178
+ * accessing deleted content without actually deleting content from summaries.
179
+ * @param tombstonedRoutes - The routes of blob nodes that are tombstones.
180
+ */
181
+ updateTombstonedRoutes(tombstonedRoutes: string[]): void;
182
+ /**
183
+ * Verifies that the blob with given id is valid, i.e., it has not been garbage collected. If the blob is GC'd,
184
+ * log an error and throw if necessary.
166
185
  */
167
- updateUnusedRoutes(unusedRoutes: string[], tombstone: boolean): void;
186
+ private verifyBlobValidity;
168
187
  summarize(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
169
188
  setRedirectTable(table: Map<string, string>): void;
170
189
  getPendingBlobs(): IPendingBlobs;
@@ -1 +1 @@
1
- {"version":3,"file":"blobManager.d.ts","sourceRoot":"","sources":["../src/blobManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAuB,yBAAyB,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAOrH,OAAO,EAAoD,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACnH,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAC;AAG3G,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACpB,MAAM,qCAAqC,CAAC;AAK7C;;;;;;GAMG;AACH,qBAAa,UAAW,YAAW,YAAY,CAAC,eAAe,CAAC;aAYxC,IAAI,EAAE,MAAM;aACZ,YAAY,EAAE,mBAAmB;IAC1C,GAAG,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;IAblC,OAAO,CAAC,QAAQ,CAAkB;IAElC,IAAW,YAAY,IAAI,YAAY,CAAiB;IAExD,IAAW,UAAU,IAAI,OAAO,CAE/B;IAED,SAAgB,YAAY,EAAE,MAAM,CAAC;gBAGjB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,mBAAmB,EAC1C,GAAG,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC;IAK3B,WAAW;IAIX,IAAI,CAAC,MAAM,EAAE,YAAY;CAGnC;AAmBD;;GAEG;AACH,MAAM,WAAW,oB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