◐ Shell
clean mode source ↗

perf(core): [SDK Overhead reduction for JVM 2] Short-circuit combined scope breadcrumbs by adinauer · Pull Request #5541 · getsentry/sentry-java

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.