Repository navigation
Conversation
Every SDK log call allocated a varargs array at the call site, also when debug is off. ILogger now has fixed-arity default overloads for zero, one and two arguments, which DiagnosticLogger and NoOpLogger override. Recompiled call sites use them and do not allocate when logging is disabled. Hot-path log calls in DefaultCompositePerformanceCollector and SentryGestureListener also built their messages eagerly with string concatenation or toString(). They now pass format arguments, so the message is built only when logging is enabled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
romtsn
marked this pull request as ready for review
November 12, 2026 17:22
romtsn
requested review from
0xadam-brown and
markushi
and removed request for
a team
November 12, 2026 17:22
📲 Install BuildsAndroid
|
This branch has not been deployed
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
When
debug = false, an SDK log call still allocates at the call site. The disabled logger then discards the result. This PR removes two sources of these allocations.1. A varargs array on each call. javac makes a new
Object[]for each varargs call, also for a call without arguments. ART does not remove it.ILoggernow hasdefaultoverloads for 0, 1 and 2 format arguments.DiagnosticLoggerandNoOpLoggeroverride them, and they checkisEnabledbefore an array exists. The SDK call sites need no change: when they compile again, they use the new overloads. About 95% of the ~1,300 SDK log calls have 2 arguments or fewer.2. Messages built before the call. 7 log calls on normal code paths built their message with string concatenation or
toString(): 2 inDefaultCompositePerformanceCollector, called on each transaction stop, and 5 inSentryGestureListener, for example on each scroll. They now send%sarguments, so the SDK builds the message only when logging is enabled. Calls incatchblocks and at init are not changed.The new
ILoggermethods are additions withdefaultbodies, so existingILoggerimplementations continue to work.💡 Motivation and Context
Apps in production pay for SDK debug logs that they never see.
💚 How did you test it?
I used an
androidx.benchmarkmicrobenchmark on a Pixel 2 XL (API 30,debug = false, median). It was a temporary module and is not part of this PR. The logger is the realDiagnosticLoggerthat wrapsAndroidLogger.mainlog(level, msg)log(level, msg, a)log(level, msg, a, b)log(level, msg, long)log(level, "msg " + s)captureMessagelog(level, msg, long): theLongbox stays, because the overloads takeObject.All unit tests pass (9,074 tests in 46 modules). Some tests verified the varargs overload with
anyVararg(). Because the SDK calls now use the new overloads, those tests failed, or, in 4never()checks, passed always. They now verify the overload that the SDK calls.📝 Checklist
sendDefaultPIIis enabled.🤖 Generated with Claude Code