Skip to content

Conversation

@romtsn
Copy link
Member

@romtsn romtsn commented Apr 11, 2025

📜 Description

The PR attempts to make SystemEventsBreadcrumbsIntegration faster by:

  • Using a fixed-size array for storing default actions we're subscribing for
    • This will avoid growing (previously unbounded) array list
    • But also will avoid allocating a new iterator in the for-loop
  • Improve getStringAfterDot by using a pre-allocated buffer and iterating from the end of the string until the first dot to create a String after that. This yielded ~2x faster results on Android (10k iterations x 3 times):

Google Chrome 2025-04-10 23 50 17

💡 Motivation and Context

💚 How did you test it?

📝 Checklist

  • 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.
  • I updated the wizard 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

// in theory this should be ThreadLocal, but we won't have more than 1 thread accessing it,
// so we save some memory here and CPU cycles. 64 is because all intent actions we subscribe for
// are less than 64 chars. We also don't care about encoding as those are always UTF.
// TODO: _MULTI_THREADED_EXECUTOR_
Copy link
Member Author

Choose a reason for hiding this comment

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

decided to mark things that depend on the single-threaded executor from now on so we won't shoot ourselves in the foot if we ever gonna switch to a multi-threaded one 😅

@github-actions
Copy link
Contributor

github-actions bot commented Apr 11, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 412.89 ms 448.76 ms 35.87 ms
Size 1.58 MiB 2.08 MiB 505.87 KiB

Previous results on branch: rz/fix/system-events-receiver-faster

Startup times

Revision Plain With Sentry Diff
e4e5296 437.63 ms 467.88 ms 30.25 ms
2532ed2 392.60 ms 448.13 ms 55.52 ms

App size

Revision Plain With Sentry Diff
e4e5296 1.58 MiB 2.08 MiB 505.67 KiB
2532ed2 1.58 MiB 2.08 MiB 505.71 KiB

Copy link
Contributor

@stefanosiano stefanosiano left a comment

Choose a reason for hiding this comment

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

nice!

@romtsn romtsn enabled auto-merge (squash) April 14, 2025 12:37
@romtsn romtsn merged commit 175c4af into main Apr 14, 2025
34 of 35 checks passed
@romtsn romtsn deleted the rz/fix/system-events-receiver-faster branch April 14, 2025 12:58
romtsn added a commit that referenced this pull request Jul 8, 2025
)

* Make SystemEventsBreadcrumbsIntegration faster

* Changelog

* Fix leak
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.

3 participants