Skip to content

perf(core): [SDK Overhead Reduction 5] Replace Calendar with Date in DateUtils#5589

Draft
adinauer wants to merge 1 commit into
perf/sdk-overhead-reductionfrom
perf/sdk-overhead-reduction-date-utils
Draft

perf(core): [SDK Overhead Reduction 5] Replace Calendar with Date in DateUtils#5589
adinauer wants to merge 1 commit into
perf/sdk-overhead-reductionfrom
perf/sdk-overhead-reduction-date-utils

Conversation

@adinauer

@adinauer adinauer commented Jun 22, 2026

Copy link
Copy Markdown
Member

PR Stack (SDK Overhead Reduction)


📜 Description

Replace Calendar.getInstance(TIMEZONE_UTC).getTime() with new Date() in DateUtils.getCurrentDateTime(), and replace the Calendar conversion in DateUtils.getDateTime(long) with new Date(millis).

Date stores epoch milliseconds and has no timezone state, so the returned values are unchanged. The UTC Calendar was only doing unnecessary allocation and calendar field computation before returning the same epoch millis as a Date.

Also update a stale Breadcrumb memoization comment that referenced Calendar allocation.

💡 Motivation and Context

Part of the SDK Overhead Reduction stack. DateUtils is used in hot event, breadcrumb, and session timestamp paths. Constructing Calendar for these helpers is unnecessary because no calendar fields are used. The change keeps Android/JDK compatibility and avoids introducing java.time or desugaring requirements.

💚 How did you test it?

  • ./gradlew :sentry:test --tests io.sentry.DateUtilsTest — all tests pass
  • ./gradlew spotlessApply apiDump — no API surface changes

📝 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

More SDK overhead reduction PRs in this stack.

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

#skip-changelog

Avoid constructing Calendar instances when DateUtils only needs the current epoch millis or a Date for an existing millis value. Date stores epoch millis without timezone state, so the returned values are unchanged while avoiding unnecessary Calendar allocation and field computation.

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

sentry Bot commented Jun 22, 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 312.66 ms 364.94 ms 52.28 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