perf(android): mini optimization: Guard manifest metadata debug logs behind isEnabled#5790
Open
runningcode wants to merge 2 commits into
Open
perf(android): mini optimization: Guard manifest metadata debug logs behind isEnabled#5790runningcode wants to merge 2 commits into
runningcode wants to merge 2 commits into
Conversation
…AVA-614) The read helpers in ManifestMetadataReader built the debug message (key + " read: " + value) unconditionally at the call site, and DiagnosticLogger only filtered on options.isDebug() afterward. With debug=false (the default) that discarded ~100 StringBuilder/String allocations per init. Guard the six read helpers with logger.isEnabled(DEBUG) so the message is only constructed when debug logging is actually on. Behavior is unchanged; this is a pure allocation/GC-pressure reduction on the init path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
📲 Install BuildsAndroid
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 5b1a06b | 310.56 ms | 362.79 ms | 52.22 ms |
| ad8da22 | 339.92 ms | 407.37 ms | 67.45 ms |
| d15471f | 307.28 ms | 381.85 ms | 74.57 ms |
| 2195398 | 345.88 ms | 411.71 ms | 65.82 ms |
| ee747ae | 396.82 ms | 441.67 ms | 44.86 ms |
| abfcc92 | 304.04 ms | 370.33 ms | 66.29 ms |
| 22f4345 | 312.78 ms | 347.40 ms | 34.62 ms |
| d15471f | 304.55 ms | 408.43 ms | 103.87 ms |
| ad8da22 | 362.98 ms | 453.94 ms | 90.96 ms |
| bbc35bb | 298.53 ms | 372.17 ms | 73.64 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 5b1a06b | 0 B | 0 B | 0 B |
| ad8da22 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 2195398 | 0 B | 0 B | 0 B |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| abfcc92 | 1.58 MiB | 2.13 MiB | 557.31 KiB |
| 22f4345 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| ad8da22 | 1.58 MiB | 2.29 MiB | 719.83 KiB |
| bbc35bb | 1.58 MiB | 2.12 MiB | 553.01 KiB |
runningcode
commented
Jul 20, 2026
| final boolean defaultValue) { | ||
| final boolean value = metadata.getBoolean(key, defaultValue); | ||
| logger.log(SentryLevel.DEBUG, key + " read: " + value); | ||
| if (logger.isEnabled(SentryLevel.DEBUG)) { |
Contributor
Author
There was a problem hiding this comment.
We could provide a new api to build the strings inside a lambda like Timber does. I wonder if customers have asked for this.
runningcode
marked this pull request as ready for review
July 20, 2026 14:44
runningcode
requested review from
0xadam-brown,
adinauer,
markushi and
romtsn
as code owners
July 20, 2026 14:44
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.
📜 Description
This is a mini optimization, this just reduces GC churn in the manifest reading which is a very expensive part of the startup.
This wraps each of the six helpers in a
logger.isEnabled(SentryLevel.DEBUG)guard so the message is only built when debug logging is actually enabled. The guard is exactly the conditionDiagnosticLogger.logalready applies internally, so behavior is unchanged.Closes #5700
💚 How did you test it?
Existing
ManifestMetadataReaderTestcoverage exercises these helpers. The change is behavior-preserving (only defers message construction), andsentry-android-corecompiles withapiDumpproducing no.apichanges.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
None.