Skip to content

perf(core): [SDK Overhead reduction for JVM 1] Remove redundant event map copies#5536

Draft
adinauer wants to merge 1 commit into
perf/sdk-overhead-jvm-v2from
perf/sdk-overhead-jvm-map-copies-v2
Draft

perf(core): [SDK Overhead reduction for JVM 1] Remove redundant event map copies#5536
adinauer wants to merge 1 commit into
perf/sdk-overhead-jvm-v2from
perf/sdk-overhead-jvm-map-copies-v2

Conversation

@adinauer

@adinauer adinauer commented Jun 12, 2026

Copy link
Copy Markdown
Member

PR Stack (SDK Overhead reduction for JVM)


📜 Description

Remove redundant intermediate HashMap copies when applying scope and options tags, and scope extras, to events.

The event setters still copy the provided maps, so this keeps event map containers isolated from the source scope/options maps while avoiding one temporary allocation per application path.

💡 Motivation and Context

This implements AR-04b from the SDK overhead reduction research. The previous code copied tags/extras before calling setters that already copy their input. Removing the extra copy reduces allocation overhead without exposing live scope or options maps to events.

💚 How did you test it?

  • ./gradlew :sentry:test --tests io.sentry.SentryClientTest --tests io.sentry.MainEventProcessorTest --tests io.sentry.protocol.SentryBaseEventSerializationTest
  • ./gradlew spotlessApply apiDump

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

Avoid creating temporary maps when applying scope and options tags or scope extras. The event setters already copy these maps, so this preserves snapshot semantics while reducing allocation overhead.

Co-Authored-By: Claude <noreply@anthropic.com>
@adinauer adinauer changed the title perf(core): Remove redundant event map copies perf(core): [SDK Overhead reduction for JVM 1] Remove redundant event map copies Jun 12, 2026
@sentry

sentry Bot commented Jun 12, 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 312.13 ms 365.27 ms 53.14 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ee747ae 357.79 ms 421.84 ms 64.05 ms
d15471f 315.20 ms 370.22 ms 55.02 ms
3998a95 415.94 ms 478.54 ms 62.60 ms
c8125f3 383.82 ms 441.66 ms 57.84 ms
cf708bd 408.35 ms 458.98 ms 50.63 ms
ff8eea4 313.42 ms 337.08 ms 23.66 ms
ce0a49e 532.00 ms 609.96 ms 77.96 ms
d15471f 303.49 ms 439.08 ms 135.59 ms
6edfca2 305.52 ms 432.78 ms 127.26 ms
4fc476b 280.63 ms 363.04 ms 82.42 ms

App size

Revision Plain With Sentry Diff
ee747ae 1.58 MiB 2.10 MiB 530.95 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
3998a95 1.58 MiB 2.10 MiB 532.96 KiB
c8125f3 1.58 MiB 2.10 MiB 532.32 KiB
cf708bd 1.58 MiB 2.11 MiB 539.71 KiB
ff8eea4 1.58 MiB 2.28 MiB 718.64 KiB
ce0a49e 1.58 MiB 2.10 MiB 532.94 KiB
d15471f 1.58 MiB 2.13 MiB 559.54 KiB
6edfca2 1.58 MiB 2.13 MiB 559.07 KiB
4fc476b 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.

2 participants