perf: Reduce reflection cost during SDK init (Init Reflection stack)#5634
Merged
Conversation
Contributor
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Performance
- Reduce reflection cost during SDK init (Init Reflection stack) ([#5634](https://github.com/getsentry/sentry-java/pull/5634))If none of the above apply, you can opt out of this check by adding |
📲 Install BuildsAndroid
|
This was referenced Jun 25, 2026
4b31414 to
a11693e
Compare
…ializing (#5635) * perf(core): Probe class availability without initializing the class LoadClass.loadClass used Class.forName(name) which initializes the class. Used purely for availability probing during init, this eagerly runs unrelated static initializers (e.g. Compose's Owner, the fragment integration). Use Class.forName(name, false, classLoader) so the class is only initialized lazily on first real use. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * changelog * changelog: move init reflection entries to Performance * perf(core): Limit no-init class probing to isClassAvailable The previous change made loadClass itself skip class initialization, which affected callers that load a class to actually use it (NDK integration, OTEL span factory and scopes storage). Restore loadClass to its initializing behavior and confine the non-initializing probe to isClassAvailable, which is only ever used for classpath availability checks. This keeps SDK init cheap while leaving real-use callers unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
adinauer
approved these changes
Jun 30, 2026
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 1edbdfa | 364.77 ms | 450.29 ms | 85.52 ms |
| a416a65 | 333.78 ms | 410.37 ms | 76.59 ms |
| d15471f | 302.62 ms | 353.84 ms | 51.22 ms |
| 22f4345 | 314.79 ms | 375.02 ms | 60.23 ms |
| 6b019b7 | 343.31 ms | 417.23 ms | 73.91 ms |
| 22f4345 | 312.78 ms | 347.40 ms | 34.62 ms |
| d217708 | 411.22 ms | 430.86 ms | 19.63 ms |
| 319f256 | 315.96 ms | 372.96 ms | 57.00 ms |
| e2dce0b | 308.96 ms | 360.10 ms | 51.14 ms |
| 8558cac | 306.16 ms | 355.24 ms | 49.09 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 1edbdfa | 1.58 MiB | 2.20 MiB | 635.34 KiB |
| a416a65 | 1.58 MiB | 2.12 MiB | 555.26 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 22f4345 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| 6b019b7 | 0 B | 0 B | 0 B |
| 22f4345 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| d217708 | 1.58 MiB | 2.10 MiB | 532.97 KiB |
| 319f256 | 1.58 MiB | 2.19 MiB | 619.79 KiB |
| e2dce0b | 0 B | 0 B | 0 B |
| 8558cac | 0 B | 0 B | 0 B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Stack (Init Reflection)
Part of JAVA-587
Collection PR for the Init Reflection stack — reducing the reflection cost on the
SentryAndroid.initpath (found via the customer-provided Perfetto trace in the Reduce SDK init time [Android] project).Squash-merge this once all stack PRs below are merged into it.