perf(core): Use fixed-delay scheduling for performance collector (JAVA-555)#5524
Open
runningcode wants to merge 4 commits into
Open
perf(core): Use fixed-delay scheduling for performance collector (JAVA-555)#5524runningcode wants to merge 4 commits into
runningcode wants to merge 4 commits into
Conversation
Switch the transaction collection timer from scheduleAtFixedRate to schedule. Fixed-rate scheduling fires rapid catch-up executions after a delay or GC pause, which the old code guarded against with a 10ms skip check. Fixed-delay scheduling spaces each collection 100ms after the previous one finishes, so the catch-up bursts cannot happen and the guard, its timestamp field, and the stale comment are no longer needed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
runningcode
commented
Jun 10, 2026
| new TimerTask() { | ||
| @Override | ||
| public void run() { | ||
| long now = System.currentTimeMillis(); |
Contributor
Author
There was a problem hiding this comment.
The issue is that scheduleAtFixedRate could schedule thousands of tasks in a row if the system goes in to deep sleep but then we guard against it using this System.currentTimeMillis() which isn't a monotonic clock meaning it could go forwards and then guard is broken allowing thousands of tasks to run.
The performance collector now uses fixed-delay scheduling, so the timer verifications assert schedule(...) rather than scheduleAtFixedRate(...). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
📲 Install BuildsAndroid
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
Switch the transaction collection timer in
DefaultCompositePerformanceCollectorfromTimer.scheduleAtFixedRatetoTimer.schedule(fixed-delay scheduling).Fixes JAVA-555.
💡 Motivation and Context
scheduleAtFixedRateschedules tasks relative to the initial start time, so after a delay or GC pause it fires a burst of rapid catch-up executions to "make up" for missed runs. The old code defended against this with a 10ms skip check, since collections spaced closer than that are not meaningful. In addition, it is usingSystem.currentTimeMillis()which isn't a monotonic clock meaning it could go forwards and then guard is broken allowing all the tasks to run.scheduleuses fixed-delay scheduling: each collection is scheduled 100ms after the previous one finishes. Catch-up bursts can no longer happen, so the guard and its supporting state are redundant. The result is more even collection spacing and simpler code.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps