| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Sorry, something went wrong.
📲 Install BuildsAndroid
|
Sorry, something went wrong.
Performance metrics 🚀
Baseline results on branch: mainStartup times
App size
Previous results on branch: no/java-605-avoid-hint-allocationStartup times
App size
|
Sorry, something went wrong.
Only allocate a Hint when a beforeBreadcrumb callback is set. addBreadcrumb previously allocated a Hint (HashMap + ArrayList + lock) on every call even though the Hint is only ever passed to the callback, wasting allocations on the common no-callback path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| Back | FazBrowse Home | New Git URL |
Resolves JAVA-605.
Description
Scope.addBreadcrumb(Breadcrumb, Hint) allocated a Hint unconditionally when the caller passed null, even though the Hint is only ever used to pass to the beforeBreadcrumb callback. When no callback is configured (the common case) the Hint — a HashMap + ArrayList + AutoClosableReentrantLock — was created and immediately discarded on every breadcrumb.
This moves the allocation inside the callback != null branch, so no Hint is allocated on the common path.
Pure allocation elimination, no behavior change.
Source
Found via on-device Perfetto method-trace analysis of the Android SDK (Scope#addBreadcrumb breadcrumb path). Part of Reduce SDK init time [Android].
🤖 Generated with Claude Code
Benchmark
Measured on-device with androidx Microbenchmark 1.4.1 (benchmark-junit4) on a Samsung Galaxy A55 (SM-A556B), Android API 36 (release build, non-minified).
The benchmark exercises the caller-side cost of a scope mutation with scope persistence enabled (enableScopePersistence = true, cacheDirPath set, no beforeBreadcrumb). The async serialize + disk write is dispatched to a no-op executor so it never runs on the measured thread — mirroring production, where it runs off-thread. Each branch is compared against its base commit (aab952b82e); the per-branch delta isolates this change. allocationCount is deterministic; timeNs has ~±10 ns run-to-run noise on a non-rooted device (unlocked clocks), so it is reported as a median and reproduced across 2 runs.
How it was done
A local, uncommitted androidx microbenchmark module (sentry-android-integration-tests/sentry-uitest-android-microbenchmark) depending on :sentry, with a BenchmarkRule looping the scope mutation. Run with:
Result — scope.addBreadcrumb()
The 4 eliminated allocations are the Hint plus its HashMap, ArrayList, and AutoClosableReentrantLock. The setTag control path (unaffected by this change) was unchanged at ~127 ns / 3 allocs.