Skip to content

perf(core): [SDK Overhead Reduction 10] Lazily create reflection JSON serializer#5601

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

perf(core): [SDK Overhead Reduction 10] Lazily create reflection JSON serializer#5601
adinauer wants to merge 1 commit into
perf/sdk-overhead-reductionfrom
perf/sdk-overhead-reduction-reflection-serializer

Conversation

@adinauer

@adinauer adinauer commented Jun 23, 2026

Copy link
Copy Markdown
Member

PR Stack (SDK Overhead Reduction)


📜 Description

Lazily creates JsonReflectionObjectSerializer only when unknown-object reflection serialization is used.

Known JSON serialization paths continue to serialize directly without creating the reflection serializer. Unknown-object fallback keeps using the same reflection serializer behavior once needed.

💡 Motivation and Context

Most SDK payloads serialize through explicit JsonSerializable implementations or other directly supported types. Those paths do not need reflection fallback, so eagerly allocating JsonReflectionObjectSerializer for every writer adds unnecessary overhead.

💚 How did you test it?

  • ./gradlew :sentry:test --tests io.sentry.JsonObjectSerializerTest
  • ./gradlew spotlessApply apiDump
  • Re-ran ./gradlew :sentry:test --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 JsonReflectionObjectSerializer until unknown-object reflection serialization is needed. Normal SDK payloads use explicit serializers, so this avoids allocating unused reflection serializer state 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

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