Skip to content

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

Draft
adinauer wants to merge 1 commit into
perf/sdk-overhead-jvm-v2from
perf/sdk-overhead-jvm-breadcrumbs-v3
Draft

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

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

final boolean hasIsolationBreadcrumbs = !isolationBreadcrumbs.isEmpty();
final boolean hasCurrentBreadcrumbs = !currentBreadcrumbs.isEmpty();

if (!hasGlobalBreadcrumbs && !hasIsolationBreadcrumbs && !hasCurrentBreadcrumbs) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, but previously we'd been always returning a copy, whereas now it's not a copy anymore, so it could've been modified?

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.

2 participants