-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
fix(session-replay): improve multi-threading of session replay processing #5018
base: main
Are you sure you want to change the base?
Conversation
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
- improve multi-threading of session replay processing ([#5018](https://github.com/getsentry/sentry-cocoa/pull/5018)) If none of the above apply, you can opt out of this check by adding |
__block NSArray<SentryVideoInfo *> *videos; | ||
__block NSError *_Nullable error; | ||
|
||
dispatch_group_t group = dispatch_group_create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would appreciate feedback if you asee any issues with this approach for synchronizing the async call
replayMaker.bitRate = replayOptions.replayBitRate; | ||
replayMaker.videoScale = replayOptions.sizeScale; | ||
replayMaker.cacheMaxSize | ||
= (NSInteger)(shouldReplayFullSession ? replayOptions.sessionSegmentDuration + 1 | ||
: replayOptions.errorReplayDuration + 1); | ||
|
||
dispatch_queue_attr_t attributes = dispatch_queue_attr_make_with_qos_class( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this setup to the SentryDispatchQueueWrapper to make it replaceable
Performance metrics 🚀
|
Revision | Plain | With Sentry | Diff |
---|---|---|---|
4597906 | 1228.37 ms | 1242.29 ms | 13.92 ms |
9d61bea | 1243.88 ms | 1254.36 ms | 10.48 ms |
6001822 | 1234.49 ms | 1265.20 ms | 30.71 ms |
706c41f | 1231.00 ms | 1248.52 ms | 17.52 ms |
9ef729b | 1228.79 ms | 1245.36 ms | 16.57 ms |
7bc3c0d | 1212.35 ms | 1228.94 ms | 16.59 ms |
80da9d1 | 1193.76 ms | 1211.83 ms | 18.08 ms |
b9b0f0a | 1251.45 ms | 1257.86 ms | 6.41 ms |
75f7fc8 | 1239.31 ms | 1266.12 ms | 26.82 ms |
0589699 | 1233.49 ms | 1249.09 ms | 15.60 ms |
App size
Revision | Plain | With Sentry | Diff |
---|---|---|---|
4597906 | 21.58 KiB | 678.19 KiB | 656.61 KiB |
9d61bea | 20.76 KiB | 436.29 KiB | 415.53 KiB |
6001822 | 22.85 KiB | 410.98 KiB | 388.13 KiB |
706c41f | 21.58 KiB | 699.25 KiB | 677.67 KiB |
9ef729b | 20.76 KiB | 432.88 KiB | 412.12 KiB |
7bc3c0d | 20.76 KiB | 427.35 KiB | 406.59 KiB |
80da9d1 | 21.58 KiB | 418.45 KiB | 396.86 KiB |
b9b0f0a | 20.76 KiB | 434.94 KiB | 414.18 KiB |
75f7fc8 | 21.58 KiB | 704.23 KiB | 682.65 KiB |
0589699 | 21.58 KiB | 656.60 KiB | 635.02 KiB |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5018 +/- ##
=============================================
- Coverage 92.705% 8.861% -83.844%
=============================================
Files 672 358 -314
Lines 82202 25570 -56632
Branches 29841 94 -29747
=============================================
- Hits 76206 2266 -73940
- Misses 5899 23304 +17405
+ Partials 97 0 -97
... and 659 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
📜 Description
💡 Motivation and Context
Some of the methods of the session replay video processing are dispatched to a low priority background queue, which then dispatches additional AV work on another dispatch queue.
The current implementation does not respect queue priorities and can cause thread starvation, because the processing queue and the work queue are either on the same priority, or the work queue is on a lower priority.
In the worst case, the processing queue is blocked and waits for the work queue, but the work queue has a lower priority than the processing queue and is awaiting execution on the main thread.
This is what the thread inversion warning is showing.
Closes #4730
💚 How did you test it?
Manual testing.
📝 Checklist
You have to check all boxes before merging:
sendDefaultPII
is enabled.