Repository navigation
ref(core): Sample performance data on the timer executor (JAVA-837) - #6589
Conversation
📲 Install BuildsAndroid
|
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.
romtsn
left a comment
There was a problem hiding this comment.
one comment re. tests but LGTM otherwise!
There's one more behaviour change which is the executor.scheduleWithFixedDelay schedules the next read after the task has finished, whereas previously, the Timer would compute the next run before the task and schedule it exactly 100ms after scheduling the first task. However, I think the new approach is the right one and it does not break anything, and it also saves our shared executor from exhaustion.
2f9f42d to
bcdcd0a
Compare
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 <[email protected]>
setup() and the first collect() were separate tasks on the shared timer thread, so a busy thread made them run back to back and AndroidCpuCollector divided by a near-zero interval. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tests ran collection on a real executor and slept, so they only proved a 100ms delay was requested, and a collector started for a string id kept running until the JVM exited. A hand-advanced fake executor lets the tests count each collect and leaves nothing running after a test ends. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bcdcd0a to
356cd6e
Compare

DefaultCompositePerformanceCollectorsampled CPU and memory on ajava.util.Timer, which uses the wall clock, so sampling stopped after a backward clock step. It now runs onoptions.getTimerExecutorService(), which usesSystem.nanoTime(). Each run schedules the next one 100ms later, the same fixed delay as before.Worth reviewing:
generationkeeps a run that is already executing from rescheduling afterclose(). The run can trigger thatclose()itself by timing out the last transaction.setup()andcollect()back to back, givingAndroidCpuCollectora near-zero interval.Based on #5816, which was closed without review.
#skip-changelog
🤖 Generated with Claude Code