Skip to content

perf(core): [SDK Overhead reduction for JVM 3] Reduce writer buffer size#5544

Draft
adinauer wants to merge 1 commit into
perf/sdk-overhead-jvm-v2from
perf/sdk-overhead-jvm-writer-buffer-512
Draft

perf(core): [SDK Overhead reduction for JVM 3] Reduce writer buffer size#5544
adinauer wants to merge 1 commit into
perf/sdk-overhead-jvm-v2from
perf/sdk-overhead-jvm-writer-buffer-512

Conversation

@adinauer

@adinauer adinauer commented Jun 15, 2026

Copy link
Copy Markdown
Member

PR Stack (SDK Overhead reduction for JVM)


📜 Description

Set an explicit 512-character BufferedWriter buffer for envelope item and envelope serialization.

This keeps the existing OutputStreamWriter-based UTF-8 encoding path and does not introduce a custom writer implementation.

💡 Motivation and Context

This implements the safe AR-13 serialization buffer-size optimization from the SDK overhead reduction research. The JDK BufferedWriter default allocates an 8192-character buffer for each short-lived serialization writer, which is oversized for typical envelope item JSON payloads.

Using a smaller explicit buffer reduces temporary allocation overhead while preserving serialization behavior.

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • ./gradlew :sentry:test --tests io.sentry.SentryEnvelopeItemTest --tests io.sentry.JsonSerializerTest

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

Use an explicit 512-character BufferedWriter buffer for envelope item and envelope serialization. This avoids allocating the oversized default char buffer for each short-lived serialization writer while preserving the existing OutputStreamWriter-based encoding path.

Co-Authored-By: Claude <noreply@anthropic.com>
@sentry

sentry Bot commented Jun 15, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

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

⚙️ sentry-android Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 320.19 ms 374.33 ms 54.14 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