Skip to content

perf(core): [SDK Overhead reduction for JVM 2] Short-circuit combined scope breadcrumbs#5540

Closed
adinauer wants to merge 1 commit into
perf/sdk-overhead-jvm-map-copies-v2from
perf/sdk-overhead-jvm-breadcrumbs-v2
Closed

perf(core): [SDK Overhead reduction for JVM 2] Short-circuit combined scope breadcrumbs#5540
adinauer wants to merge 1 commit into
perf/sdk-overhead-jvm-map-copies-v2from
perf/sdk-overhead-jvm-breadcrumbs-v2

Conversation

@adinauer

@adinauer adinauer commented Jun 12, 2026

Copy link
Copy Markdown
Member

PR Stack (SDK Overhead reduction for JVM)


📜 Description

Short-circuit CombinedScopeView.getBreadcrumbs() when only one component scope contains breadcrumbs.

The method now returns the single non-empty scope queue directly, keeps the existing merged/sorted bounded queue path when multiple scopes have breadcrumbs, and uses the configured default write scope when all queues are empty.

💡 Motivation and Context

This implements the breadcrumb portion of AR-08 from the SDK overhead reduction research. The previous code always allocated a temporary list, copied breadcrumbs from all three scopes, sorted them, allocated a bounded queue, and copied them again, even when only one scope had breadcrumbs.

Avoiding that merge path reduces per-event allocation overhead on the common single-scope breadcrumb path.

💚 How did you test it?

  • ./gradlew :sentry:test --tests io.sentry.CombinedScopeViewTest
  • ./gradlew spotlessApply apiDump :sentry:test --tests io.sentry.CombinedScopeViewTest

📝 Checklist

  • I added GH Issue ID & Linear ID
  • 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

#skip-changelog

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

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>
@sentry

sentry Bot commented Jun 12, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.43.2 (1) release

⚙️ sentry-android Build Distribution Settings

@adinauer adinauer changed the title perf(core): Short-circuit combined scope breadcrumbs perf(core): [SDK Overhead reduction for JVM 2] Short-circuit combined scope breadcrumbs Jun 12, 2026
@adinauer

Copy link
Copy Markdown
Member Author

Closing because this PR was based on #5536. Recreated against the collection branch as #5541.

@adinauer adinauer closed this Jun 12, 2026
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.

1 participant