perf(core): SDK Overhead Reduction#5499
Merged
Merged
Conversation
Android is never Java 9+, so the System.getProperty + Double.valueOf parse in the Platform static initializer is unnecessary overhead on the Android cold-start path. Short-circuit to isJavaNinePlus=false when isAndroid is true.
📲 Install BuildsAndroid
|
Replace OptionsContainer.create(SentryAndroidOptions.class) which uses getDeclaredConstructor().newInstance() with a direct SentryAndroidOptionsContainer subclass that returns new SentryAndroidOptions() without reflection. Make OptionsContainer non-final (@OPEN) with a protected no-arg constructor so Android can subclass it.
Avoid allocating and sorting a merged breadcrumb queue when only one component scope has breadcrumbs. This keeps the full merge path for multi-scope breadcrumbs and returns the default write scope queue when all scopes are empty. Co-Authored-By: Claude <noreply@anthropic.com>
Use an explicit 512-character BufferedWriter buffer for envelope item and envelope serialization. This avoids allocating the oversized default char buffer for each short-lived serialization writer while preserving the existing OutputStreamWriter-based encoding path. Co-Authored-By: Claude <noreply@anthropic.com>
Avoid creating temporary maps when applying scope and options tags or scope extras. The event setters already copy these maps, so this preserves snapshot semantics while reducing allocation overhead. Co-Authored-By: Claude <noreply@anthropic.com>
…ies-v2 perf(core): [SDK Overhead reduction for JVM 1] Remove redundant event map copies
…buffer-512 perf(core): [SDK Overhead reduction for JVM 3] Reduce writer buffer size
…erf/sdk-overhead-jvm-breadcrumbs-v3
Avoid allocating merged collection copies when only one combined scope contains values. This extends the breadcrumbs optimization to tags, attributes, extras, and attachments while preserving merge behavior when multiple scopes contribute data. Co-Authored-By: Claude <noreply@anthropic.com>
…umbs-v3 perf(core): [SDK Overhead reduction for JVM 2] Short-circuit combined scope breadcrumbs
…latform-android-skip perf(core): [SDK Overhead Reduction 1] Skip java.specification.version lookup on Android
…ptions-container perf(android): [SDK Overhead Reduction 2] Replace reflective OptionsContainer with direct subclass
Avoid constructing a Calendar only to read the default device timezone. The locale passed to Calendar does not affect the timezone value, so TimeZone.getDefault returns the same value with less work during device context collection. Co-Authored-By: Claude <noreply@anthropic.com>
Avoid constructing Calendar instances when DateUtils only needs the current epoch millis or a Date for an existing millis value. Date stores epoch millis without timezone state, so the returned values are unchanged while avoiding unnecessary Calendar allocation and field computation. Co-Authored-By: Claude <noreply@anthropic.com>
Shrink the vendored JsonWriter nesting stack from 32 entries to 8 entries. The stack still grows on demand for deeply nested payloads, while common SDK serialization avoids the larger initial array allocation. Co-Authored-By: Claude <noreply@anthropic.com>
Avoid allocating a ConcurrentHashMap for breadcrumbs that never set data. Initialize the data map on first write while preserving concurrent writes with double-checked locking. Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Jun 23, 2026
Merged
…imezone-default perf(android): [SDK Overhead Reduction 4] Use default timezone directly
…uction-date-utils
…ate-utils perf(core): [SDK Overhead Reduction 5] Replace Calendar with Date in DateUtils
…uction-json-writer-stack
…son-writer-stack perf(core): [SDK Overhead Reduction 6] Reduce JsonWriter stack allocation
…uction-breadcrumb-lazy-data
…readcrumb-lazy-data perf(core): [SDK Overhead Reduction 7] Lazily allocate Breadcrumb data
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b070303. Configure here.
…uction-contexts-key-array
…ontexts-key-array perf(core): [SDK Overhead Reduction 8] Reduce context serialization allocations
…uction-reflection-visiting
…eflection-visiting perf(core): [SDK Overhead Reduction 9] Lazily allocate reflection serializer state
…uction-reflection-serializer
…eflection-serializer perf(core): [SDK Overhead Reduction 10] Lazily create reflection JSON serializer
…o perf/sdk-overhead-reduction-fast-dates # Conflicts: # CHANGELOG.md # sentry/src/main/java/io/sentry/DateUtils.java
…o perf/sdk-overhead-jvm-v2 # Conflicts: # CHANGELOG.md
…ast-dates perf(core): [SDK Overhead Reduction 11] Replace ISO8601 timestamp handling
…so8601-compat fix(core): [SDK Overhead Reduction 13] Preserve ISO8601 utility compatibility
…uction-date-getters
…ate-getters perf(core): [SDK Overhead Reduction 12] Avoid cloning Date getters
perf(core): SDK Overhead reduction for JVM
runningcode
approved these changes
Jun 25, 2026
This was referenced Jun 25, 2026
runningcode
added a commit
that referenced
this pull request
Jun 30, 2026
SentryId and SpanId stored their string value behind a LazyEvaluator<String>, which allocates an AutoClosableReentrantLock (a ReentrantLock with its internal Sync) plus a capturing lambda on every instance. Since one SentryId is created per event/transaction and one SpanId per span, this per-instance lock machinery is far heavier than the single String it guards, and the eager string-arg constructors gained no laziness at all. Replace the LazyEvaluator with a plain volatile String guarded by a double-checked synchronized(this) block. Eager constructors now assign the value directly; the no-arg and UUID constructors still defer UUID-string generation. Synchronization is retained because UUID generation is non-idempotent and two racing threads must not produce different ids. Follow-up to the SDK Overhead Reduction work (#5499). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
runningcode
added a commit
that referenced
this pull request
Jun 30, 2026
SentryId and SpanId stored their string value behind a LazyEvaluator<String>, which allocates an AutoClosableReentrantLock (a ReentrantLock with its internal Sync) plus a capturing lambda on every instance. Since one SentryId is created per event/transaction and one SpanId per span, this per-instance lock machinery is far heavier than the single String it guards, and the eager string-arg constructors gained no laziness at all. Replace the LazyEvaluator with a plain volatile String guarded by a double-checked synchronized(this) block. Eager constructors now assign the value directly; the no-arg and UUID constructors still defer UUID-string generation. Synchronization is retained because UUID generation is non-idempotent and two racing threads must not produce different ids. Follow-up to the SDK Overhead Reduction work (#5499). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

#skip-changelog
PR Stack (SDK Overhead Reduction)
Collection PR for the SDK Overhead Reduction stack. Squash-merge this once all stack PRs are merged.