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

Move integrations registration to background during init #3043

Merged
merged 5 commits into from
Nov 27, 2023

Conversation

stefanosiano
Copy link
Member

📜 Description

moved several integrations to the background to reduce main thread usage on SDK init:
-AnrIntegration
-PhoneStateBreadcrumbsIntegration
-SystemEventsBreadcrumbsIntegration
-TempSensorBreadcrumbsIntegration

💡 Motivation and Context

Relates to #2222
It continues the work done on #3036
Fixes #3040

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

…age on SDK init:

-AnrIntegration
-PhoneStateBreadcrumbsIntegration
-SystemEventsBreadcrumbsIntegration
-TempSensorBreadcrumbsIntegration
@stefanosiano stefanosiano changed the base branch from main to fix/reduce-io-init November 9, 2023 11:40
@stefanosiano stefanosiano marked this pull request as ready for review November 9, 2023 11:41
Copy link
Contributor

github-actions bot commented Nov 9, 2023

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 368.22 ms 475.32 ms 107.10 ms
Size 1.72 MiB 2.29 MiB 579.28 KiB

Baseline results on branch: fix/reduce-io-init

Startup times

Revision Plain With Sentry Diff
077a103 410.41 ms 464.64 ms 54.24 ms
5295259 376.14 ms 448.89 ms 72.75 ms
644ca6a 448.52 ms 547.22 ms 98.70 ms
2462226 400.98 ms 477.18 ms 76.20 ms

App size

Revision Plain With Sentry Diff
077a103 1.72 MiB 2.29 MiB 578.27 KiB
5295259 1.72 MiB 2.29 MiB 577.94 KiB
644ca6a 1.72 MiB 2.29 MiB 578.27 KiB
2462226 1.72 MiB 2.29 MiB 578.43 KiB

Previous results on branch: fix/integrations-background-init

Startup times

Revision Plain With Sentry Diff
7f37052 427.09 ms 507.41 ms 80.32 ms

App size

Revision Plain With Sentry Diff
7f37052 1.72 MiB 2.29 MiB 578.73 KiB

Copy link
Member

@markushi markushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, this will be a great step forward!
Similar to https://github.com/getsentry/sentry-java/pull/3036/files#r1393877541 I think we need to ensure thread safety within the Integrations, as different threads may modify the state at the same time.

Copy link
Member

@markushi markushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! In case we want to move more integrations to the background thread, we could think about having some base class integration, which takes care of thread safe start() and close().
Nice job adapting the tests! 💯

@stefanosiano stefanosiano merged commit 7ba0ff1 into fix/reduce-io-init Nov 27, 2023
1 of 2 checks passed
@stefanosiano stefanosiano deleted the fix/integrations-background-init branch November 27, 2023 10:56
lbloder pushed a commit that referenced this pull request Nov 28, 2023
* delete old profiles in the background on SDK init
* moved some Integration.register() to the background using executorService
* Move integrations registration to background during init (#3043)
* removed integrations registration falling back to calling thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ANR when initialising Sentry SDK
2 participants