microsoft / FluidFramework

Library for building distributed, real-time collaborative web applications
https://fluidframework.com
MIT License
4.73k stars 532 forks source link

Offline: Only enable DuplicateBatchDetector if Offline Load is enabled #22497

Closed markfields closed 1 month ago

markfields commented 1 month ago

Description

Related to AB#8885

DuplicateBatchDetection maintains a datastructure of all batchIds/sequenceNumbers within the collab window (seqNum > latest MSN), and checks all incoming batchIds against that set. However, until Offline Load is enabled, there will be no duplicate batchIds. So until then, don't bother with this tracking.

Notes about performance

For whenever it is enabled

A simple benchmark shows that the time spent doing DuplicateBatchDetection is not much - around 30ms for data structure size of 1000, which is 99.99%ile collab window in the production data I looked at.

To me this seems acceptable - and more importantly, predictable (in terms of perf characteristics, based on the data structures/algorithms used) - so I don't see benefit in instrumenting the code (which would only slow it down). I tried using SampledTelemetryHelper in this branch (3bf60452ec0bc5a7645bc4f483c6b9b234a3918d) but decided it wasn't worth it (per this analysis)

msfluid-bot commented 1 month ago
@fluid-example/bundle-size-tests: +345 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 459.93 KB 459.99 KB +60 Bytes
azureClient.js 557.86 KB 557.93 KB +74 Bytes
connectionState.js 680 Bytes 680 Bytes No change
containerRuntime.js 260.69 KB 260.73 KB +39 Bytes
fluidFramework.js 401.54 KB 401.55 KB +14 Bytes
loader.js 134.19 KB 134.2 KB +14 Bytes
map.js 42.43 KB 42.44 KB +7 Bytes
matrix.js 146.58 KB 146.58 KB +7 Bytes
odspClient.js 525.21 KB 525.28 KB +74 Bytes
odspDriver.js 97.8 KB 97.82 KB +21 Bytes
odspPrefetchSnapshot.js 42.76 KB 42.78 KB +14 Bytes
sharedString.js 163.3 KB 163.31 KB +7 Bytes
sharedTree.js 392 KB 392.01 KB +7 Bytes
Total Size 3.3 MB 3.3 MB +345 Bytes

Baseline commit: 819cafad04cfc737d6267743dd590715045aa326

Generated by :no_entry_sign: dangerJS against ea554f8796cdf395f7e4d63f38ac47deddec9cd0