Skip to content

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

Open
adinauer wants to merge 2 commits into
perf/sdk-overhead-reductionfrom
perf/sdk-overhead-reduction-reflection-serializer
Open

perf(core): [SDK Overhead Reduction 10] Lazily create reflection JSON serializer#5601
adinauer wants to merge 2 commits 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

⚠️ 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

@adinauer

Copy link
Copy Markdown
Member Author

Cursor review

@adinauer

Copy link
Copy Markdown
Member Author

@sentry review

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit fd46dbe. Configure here.

@adinauer adinauer marked this pull request as ready for review June 24, 2026 08:10
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 369.23 ms 460.06 ms 90.83 ms
Size 0 B 0 B 0 B

Previous results on branch: perf/sdk-overhead-reduction-reflection-serializer

Startup times

Revision Plain With Sentry Diff
28e4d53 383.13 ms 473.56 ms 90.44 ms

App size

Revision Plain With Sentry Diff
28e4d53 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