RUM-16039: Upgrade Mach profiler sampler to sample CPU-time#2896
Draft
simaoseica-dd wants to merge 1 commit into
Draft
RUM-16039: Upgrade Mach profiler sampler to sample CPU-time#2896simaoseica-dd wants to merge 1 commit into
simaoseica-dd wants to merge 1 commit into
Conversation
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.
Important
This PR is intended to validate backend and frontend support for iOS CPU Time samples, and to assess whether the resulting data and visualization improve the current Wall Time only profiling experience.
What and why?
This PR adds optional CPU time sample collection to the iOS Mach profiler.
The current iOS profiler emits Wall Time samples, which are useful for understanding user-perceived latency, blocked threads, waits, and runloop stalls. However, Wall Time profiles can be noisy when many threads are idle or waiting, and they do not clearly isolate code that is actively consuming CPU.
CPU Time samples add a complementary view focused on active CPU work, such as expensive parsing, image processing, layout, etc. This should help validate whether CPU Time profiling provides better signal for compute hotspots while preserving the existing Wall Time behavior.
How?
The Mach sampler continues to run on the existing wall clock sampling interval. When CPU Time sampling is enabled, each sampled thread also reads its accumulated Mach thread CPU time from
THREAD_BASIC_INFOusinguser_time + system_time.The profiler stores the previous CPU Time value per thread and emits the delta between observations as a
cpu-timesample value. Wall Time remains unchanged and is still emitted aswall-time.CPU Time sampling is disabled by default and controlled through a feature flag. The Swift profiling feature writes the flag to profiling user defaults before the native profiler is created, allowing both app launch and continuous profiling paths to read the same configuration.
The resulting
pprofcan contain bothwall-timeandcpu-timesample types in the same profile, enabling backend and frontend validation without replacing the existing wall-time profiler.Review checklist
make api-surfacewhen adding new APIs