Skip to content

Optimize when maxBreadcrumb is 0 #4504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 30, 2025

Conversation

stefanosiano
Copy link
Member

📜 Description

breadcumbs queue is now a simple DisabledQueue when maxBreadcrumb is 0
if breadcumbs is a DisabledQueue, no more processing is done (beforeBreadcrumb or scopeObservers)

💡 Motivation and Context

Fixes #4334
Previously we were calling beforeBreadcrumb and scopeObservers even when maxBreadcrumbs was 0, which was useless

💚 How did you test it?

📝 Checklist

  • 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

stefanosiano and others added 5 commits June 20, 2025 12:43
if breadcumbs is a DisabledQueue, no more processing is done (beforeBreadcrumb or scopeObservers)
added test
…ations' into fix/disabled-breadcrumbs-optimizations
@@ -862,7 +862,7 @@ public void clearAttachments() {
static @NotNull Queue<Breadcrumb> createBreadcrumbsList(final int maxBreadcrumb) {
return maxBreadcrumb > 0
? SynchronizedQueue.synchronizedQueue(new CircularFifoQueue<>(maxBreadcrumb))
: SynchronizedQueue.synchronizedQueue(new DisabledQueue<>());
: new DisabledQueue<>();
Copy link
Member Author

Choose a reason for hiding this comment

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

I tried calling queue.add from multiple threads concurrently, and it didn't crash, so i think we it's fine to remove SynchronizedQueue

@stefanosiano stefanosiano marked this pull request as ready for review June 20, 2025 10:57
Copy link
Contributor

github-actions bot commented Jun 20, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 440.85 ms 517.27 ms 76.42 ms
Size 1.58 MiB 2.09 MiB 518.90 KiB

Previous results on branch: fix/disabled-breadcrumbs-optimizations

Startup times

Revision Plain With Sentry Diff
22fe8fc 460.76 ms 492.36 ms 31.60 ms
8fbf5c2 444.50 ms 507.49 ms 62.99 ms

App size

Revision Plain With Sentry Diff
22fe8fc 1.58 MiB 2.09 MiB 518.69 KiB
8fbf5c2 1.58 MiB 2.09 MiB 519.15 KiB

# Conflicts:
#	CHANGELOG.md
#	sentry/src/test/java/io/sentry/ScopeTest.kt
@stefanosiano stefanosiano enabled auto-merge (squash) June 30, 2025 13:51
@stefanosiano stefanosiano merged commit 0f37c1d into main Jun 30, 2025
34 checks passed
@stefanosiano stefanosiano deleted the fix/disabled-breadcrumbs-optimizations branch June 30, 2025 14:03
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.

Setting maxBreadcrumbs 0 and beforeBreadcrumb callback crash
3 participants