Skip to content

perf(core): [SDK Overhead Reduction 9] Lazily allocate reflection serializer state#5600

Draft
adinauer wants to merge 1 commit into
perf/sdk-overhead-reductionfrom
perf/sdk-overhead-reduction-reflection-visiting
Draft

perf(core): [SDK Overhead Reduction 9] Lazily allocate reflection serializer state#5600
adinauer wants to merge 1 commit into
perf/sdk-overhead-reductionfrom
perf/sdk-overhead-reduction-reflection-visiting

Conversation

@adinauer

@adinauer adinauer commented Jun 23, 2026

Copy link
Copy Markdown
Member

PR Stack (SDK Overhead Reduction)


📜 Description

Lazily creates the JsonReflectionObjectSerializer visiting set only when reflection serialization is used.

The set still tracks objects during reflection serialization for cyclic reference and max-depth handling, but normal JSON serialization paths no longer allocate it eagerly.

💡 Motivation and Context

Most SDK payloads serialize through explicit JsonSerializable implementations or other supported direct types. Those paths do not need reflection cycle tracking, so allocating an empty HashSet for every reflection serializer adds unnecessary overhead.

💚 How did you test it?

  • ./gradlew :sentry:test --tests io.sentry.JsonReflectionObjectSerializerTest --tests io.sentry.JsonObjectSerializerTest
  • ./gradlew spotlessApply apiDump
  • Re-ran ./gradlew :sentry:test --tests io.sentry.JsonReflectionObjectSerializerTest --tests io.sentry.JsonObjectSerializerTest

📝 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.

Defer creation of the reflection serializer visiting set until reflection serialization is actually needed. Normal SDK payload serialization uses explicit serializers, so this avoids an unused HashSet allocation for each writer.
@sentry

sentry Bot commented Jun 23, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 340.48 ms 427.56 ms 87.08 ms
Size 0 B 0 B 0 B

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