DataDog / browser-sdk

Datadog Browser SDK
Apache License 2.0
294 stars 131 forks source link

⚡️[RUM-3570] Batch the records for 16ms minimum before processing them #2807

Closed amortemousque closed 3 months ago

amortemousque commented 3 months ago

Motivation

When recording for Session Replay, MutationRecord objects are batched together (see mutationBatch), then deduplicated on processing (ex: here).

When the same mutation happens continuously on the same element, for example with JS-driven animations, a lot of MutationRecords can be notified by the browser in a very short amount of time, which can significantly inflate the data sent to Datadog, and have a performance impact both on the recorder side and on the player side (see below). Those mutations could be deduplicated if they were batched together.

Changes

Batch the records for 16ms minimum before processing them

Testing


I have gone over the contributing documentation.

codecov-commenter commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 93.65%. Comparing base (b839f8c) to head (28d38d9).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #2807 +/- ## ======================================= Coverage 93.65% 93.65% ======================================= Files 243 243 Lines 7140 7143 +3 Branches 1599 1599 ======================================= + Hits 6687 6690 +3 Misses 453 453 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

cit-pr-commenter[bot] commented 3 months ago

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 159.49 KiB 159.55 KiB 62 B +0.04%
Logs 58.02 KiB 58.02 KiB 0 B 0.00%
Rum Slim 108.07 KiB 108.07 KiB 0 B 0.00%
Worker 25.21 KiB 25.21 KiB 0 B 0.00%

🚀 CPU Performance | Action Name | Base Average Cpu Time (ms) | Local Average Cpu Time (ms) | 𝚫 | | --- | --- | --- | --- | | addglobalcontext | 0.002 | 0.002 | -0.000 | | addaction | 0.050 | 0.042 | -0.007 | | adderror | 0.052 | 0.034 | -0.017 | | addtiming | 0.001 | 0.001 | -0.001 | | startview | 1.427 | 0.999 | -0.428 | | startstopsessionreplayrecording | 1.077 | 0.825 | -0.252 | | logmessage | 0.007 | 0.019 | 0.012 |
🧠 Memory Performance | Action Name | Base Consumption Memory (bytes) | Local Consumption Memory (bytes) | 𝚫 (bytes) | | --- | --- | --- | --- | | addglobalcontext | 19.58 KiB | 18.83 KiB | -766 B | | addaction | 68.97 KiB | 68.36 KiB | -632 B | | adderror | 83.18 KiB | 85.19 KiB | 2.00 KiB | | addtiming | 17.24 KiB | 17.05 KiB | -193 B | | startview | 313.58 KiB | 317.81 KiB | 4.22 KiB | | startstopsessionreplayrecording | 11.51 KiB | 12.38 KiB | 890 B | | logmessage | 64.11 KiB | 67.06 KiB | 2.95 KiB |