Repository navigation
fix(profiling): Place CPU and memory samples by their monotonic tick (JAVA-578) - #6591
Draft
runningcode wants to merge 3 commits into
Draft
runningcode wants to merge 3 commits into
runningcode wants to merge 3 commits into
Conversation
📲 Install BuildsAndroid
|
…(JAVA-578) AndroidProfiler and PerfettoContinuousProfiler's chunk collector placed each CPU and memory sample on the profile timeline by projecting its wall-clock timestamp through one wall-to-elapsedRealtime offset taken when the profile ended. A wall-clock step during the profile shifted every earlier sample relative to the trace. PerformanceCollectionData now carries a tick from options.getMonotonicTicker(), read when the sample is taken. On Android that is SystemClock.elapsedRealtimeNanos(), the clock both profilers read their start from, so the offset is a plain subtraction. Fixes JAVA-578 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ction start() already returns the start tick in ProfileStartData, so the test no longer depends on a private field name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runningcode
force-pushed
the
no/java-578-profiler-sample-ticks
branch
from
November 23, 2026 10:20
c45c666 to
f4b465c
Compare
Contributor
PR risk: highFor commit Main concerns: public contract, reach, data sent to Sentry. Rules that block low also fired:
This label is a hint for reviewers, not an approval. |
4 of 9 tasks
This branch has not been deployed
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
Android profiles place each CPU and memory sample at an offset from the profile start.
AndroidProfilerandPerfettoContinuousProfilercomputed that offset from the sample's wall-clock time, converted with one wall-to-elapsedRealtimedifference read when the profile ended:If the wall clock jumped during the profile, every sample taken before the jump moved by the size of the jump.
Each
PerformanceCollectionDatanow also records a tick fromoptions.getMonotonicTicker()when it is taken. On Android that isSystemClock.elapsedRealtimeNanos(), the clock the profile start comes from, so the offset is a plain subtraction. The sample's wall-clock time is still sent as its absolute timestamp.Without a clock jump, offsets change by less than a millisecond: the old math inherited the wall clock's millisecond rounding.
Internal API change: the
@ApiStatus.InternalPerformanceCollectionDataconstructor now takes the tick,(nanoTimestamp, tickNanos), and the class gainsgetTickNanos(). The SDK's collector is the only producer. sentry-react-native'sRNSentryProfilingPerformanceCollectionTestcalls the old constructor and needs a second argument when it picks up this change.💡 Motivation and Context
The ticket names
AndroidProfiler;PerfettoContinuousProfilerhas the same bug, so this fixes both.💚 How did you test it?
AndroidProfilerTestandChunkMeasurementCollectorTestgive samples wall timestamps that disagree with their ticks, as after a clock jump, and check that each offset is its tick minus the start. Both fail on the old code.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
#6589 (JAVA-837) changes the line in
DefaultCompositePerformanceCollectorthat creates samples, so whichever PR lands second needs a small rebase.🤖 Generated with Claude Code