Repository navigation
ref(core): Sample performance data on the timer executor (JAVA-837) - #6589
runningcode wants to merge 1 commit into
Conversation
📲 Install BuildsAndroid
|
DefaultCompositePerformanceCollector sampled CPU and memory every 100ms on a java.util.Timer, the last one in the SDK. Timer schedules on the wall clock, so a backward clock step stopped sampling, and the 30s collection budget check that runs in the same task, until the clock caught back up. The loop now runs on options.getTimerExecutorService(), which schedules on System.nanoTime(). The executor only has one-shot schedule(), so each run reschedules itself. A generation counter, bumped in close(), stops a run that is already in flight from rescheduling a cancelled chain. Based on #5816. Fixes JAVA-837 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8a0aeef to
dd1a717
Compare
PR risk: mediumFor commit Main concerns: reach, host performance, data sent to Sentry. This label is a hint for reviewers, not an approval. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit dd1a717. Configure here.
| .getTimerExecutorService() | ||
| .schedule( | ||
| () -> collectAndReschedule(currentGeneration), | ||
| TRANSACTION_COLLECTION_INTERVAL_MILLIS); |
There was a problem hiding this comment.
Setup and collect can collapse
Medium Severity
setup() and the first collect() are queued as two independent tasks (delay 0 and 100ms) on the shared single-thread timer executor. A long task already on that thread, such as an idle-timeout finish(), can make both due before either runs, so they execute back-to-back. AndroidCpuCollector then divides by a near-zero interval and can emit huge or non-finite CPU percentages.
Triggered by project rule: PR Review Guidelines for Cursor Bugbot
Reviewed by Cursor Bugbot for commit dd1a717. Configure here.


After a backward wall-clock step,
DefaultCompositePerformanceCollectorstopped sampling CPU and memory for running transactions and profiles until the clock caught up. It scheduled on ajava.util.Timer, which uses the wall clock. It now schedules onoptions.getTimerExecutorService(), which usesSystem.nanoTime()and is already used bySentryTracerfor its idle and deadline timeouts. This was the lastjava.util.Timerin the SDK.The executor only has a one-shot
schedule(), so each run schedules the next one. This keeps the old fixed-delay behavior, becauseTimer.schedule(task, delay, period)is fixed-delay, not fixed-rate.Worth reviewing: the
generationcounter.close()can't cancel a run that is already executing, and that run may itself callclose()by timing out the last transaction. A run only schedules the next one ifgenerationhasn't changed since it was scheduled.collector times out after 30 secondsfails without this check.Not changed:
options.getDateProvider(). On the JVM that's the wall clock, so a backward step still extends the timeout. ref(core): Measure the performance-collection budget on a monotonic ticker (JAVA-579) #6101 moves the timeout to a monotonic ticker on9.x.x. Expect a small conflict the next timemainis merged into it./proc/self/statread plusRuntimestats.Based on #5816, which made the same change and was closed without review.
#skip-changelog
🤖 Generated with Claude Code