Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡️ [RUM-6929] delay resource collection #3102

Merged
merged 6 commits into from
Nov 14, 2024

Conversation

BenoitZugmeyer
Copy link
Member

@BenoitZugmeyer BenoitZugmeyer commented Oct 29, 2024

Motivation

We observed that on some condition, processing resources can block the main thread for a significant amount of time.

Screenshot 2024-10-29 at 18 37 44

Changes

This PR mitigate the issue by processing each resource in a "task queue". Tasks are scheduled to be run in "idle tasks" via requestIdleCallback. This will break down those big blocking tasks into smaller tasks with lower priority.

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@BenoitZugmeyer BenoitZugmeyer requested a review from a team as a code owner October 29, 2024 17:40
@codecov-commenter
Copy link

codecov-commenter commented Oct 29, 2024

Codecov Report

Attention: Patch coverage is 98.61111% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.70%. Comparing base (c951eec) to head (cf5ca40).

Files with missing lines Patch % Lines
...kages/core/test/emulate/mockRequestIdleCallback.ts 96.87% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3102      +/-   ##
==========================================
+ Coverage   93.65%   93.70%   +0.04%     
==========================================
  Files         276      279       +3     
  Lines        7615     7672      +57     
  Branches     1708     1713       +5     
==========================================
+ Hits         7132     7189      +57     
  Misses        483      483              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Update shim implementation based on Chrome devs suggestion. It should be
more accurate than the previous shim, and also offer `remainingTime`
capabilities.
Copy link

cit-pr-commenter bot commented Oct 30, 2024

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 161.01 KiB 161.46 KiB 462 B +0.28%
Logs 55.75 KiB 55.75 KiB 0 B 0.00%
Rum Slim 109.59 KiB 110.30 KiB 731 B +0.65%
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.001 -0.001
addaction 0.050 0.031 -0.019
addtiming 0.001 0.001 -0.000
adderror 0.059 0.032 -0.027
startstopsessionreplayrecording 1.604 0.978 -0.626
startview 1.571 0.976 -0.595
logmessage 0.034 0.020 -0.015
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 8.24 KiB 8.76 KiB 535 B
addaction 38.18 KiB 40.23 KiB 2.05 KiB
addtiming 7.27 KiB 8.35 KiB 1.08 KiB
adderror 42.95 KiB 45.71 KiB 2.76 KiB
startstopsessionreplayrecording 6.68 KiB 6.38 KiB -303 B
startview 424.42 KiB 433.33 KiB 8.91 KiB
logmessage 39.70 KiB 43.40 KiB 3.70 KiB

🔗 RealWorld

@BenoitZugmeyer
Copy link
Member Author

/to-staging

@dd-devflow
Copy link

dd-devflow bot commented Oct 30, 2024

🚂 Branch Integration: starting soon, median merge time is 0s

Commit 4bbad82b2d will soon be integrated into staging-44.

Use /to-staging -c to cancel this operation!

dd-mergequeue bot added a commit that referenced this pull request Oct 30, 2024
Integrated commit sha: 4bbad82

Co-authored-by: Benoît Zugmeyer <benoit.zugmeyer@datadoghq.com>
@dd-devflow
Copy link

dd-devflow bot commented Oct 30, 2024

🚂 Branch Integration: This commit was successfully integrated

Commit 4bbad82b2d has been merged into staging-44 in merge commit 8ce8f387df.

Check out the triggered pipeline on Gitlab 🦊

packages/core/src/tools/taskQueue.ts Outdated Show resolved Hide resolved
packages/core/src/tools/taskQueue.ts Outdated Show resolved Hide resolved
packages/core/src/tools/taskQueue.ts Outdated Show resolved Hide resolved
packages/core/src/tools/taskQueue.ts Outdated Show resolved Hide resolved
packages/core/src/tools/taskQueue.spec.ts Outdated Show resolved Hide resolved
@BenoitZugmeyer BenoitZugmeyer merged commit c136ac9 into main Nov 14, 2024
19 checks passed
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/delay-resource-collection branch November 14, 2024 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants