Skip to content

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

Open
adinauer wants to merge 5 commits into
perf/sdk-overhead-jvm-v2from
perf/sdk-overhead-jvm-breadcrumbs-v3
Open

perf(core): [SDK Overhead reduction for JVM 2] Short-circuit combined scope breadcrumbs#5541
adinauer wants to merge 5 commits 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.44.0 (1) release

⚙️ sentry-android Build Distribution Settings

Comment thread sentry/src/main/java/io/sentry/CombinedScopeView.java
@adinauer adinauer force-pushed the perf/sdk-overhead-jvm-v2 branch from 51c339c to 7c1a728 Compare June 18, 2026 12:58
@adinauer adinauer marked this pull request as ready for review June 18, 2026 13:16
Comment thread sentry/src/main/java/io/sentry/CombinedScopeView.java Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 22fe488. Configure here.

Comment thread sentry/src/main/java/io/sentry/CombinedScopeView.java
Comment thread sentry/src/main/java/io/sentry/CombinedScopeView.java
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 361.50 ms 436.82 ms 75.32 ms
Size 0 B 0 B 0 B

Baseline results on branch: perf/sdk-overhead-jvm-v2

Startup times

Revision Plain With Sentry Diff
d346c71 324.53 ms 363.54 ms 39.01 ms

App size

Revision Plain With Sentry Diff
d346c71 0 B 0 B 0 B

Previous results on branch: perf/sdk-overhead-jvm-breadcrumbs-v3

Startup times

Revision Plain With Sentry Diff
7974907 298.78 ms 357.50 ms 58.72 ms

App size

Revision Plain With Sentry Diff
7974907 0 B 0 B 0 B

adinauer and others added 3 commits June 18, 2026 15:46
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>
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