Compute profiling time range from samples and markers #715
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.
Overview
This PR adds
profilingStartTimeandprofilingEndTimefields to the profile metadata, computed from all sample timestamps and marker start/end times across all threads.Tests
I've updated all of the existing tests to check these values, but it doesn't have full coverage of the edge cases I've encountered, where marker times may be before/after sample times, or the converse, on multiple threads, etc.
I did manually verify that it fixes the issues I was seeing in #710 related to the profiling time range.
Example Before: https://share.firefox.dev/4oSRnGW
Example After: https://share.firefox.dev/4p5vUux
However, I'm not entirely sure if the current behavior is correct for every scenario.
For example, I'm not sure if the following start and end time of
10.0, which is the computed result for one of the current test cases, makes sense:I didn't add any additional test cases because I'm still very much a novice when it comes to the internals of the profiles. I bet an LLM could generate more test cases pretty well, given the context, but I wouldn't be able to accurately review whether it represents a realistic profile.
I'm not sure how extensive you want the test coverage, since these cases are pretty long, but I'm happy to try to add more cases if desired.
Additional Thoughts
I considered utilizing rayon for the
compute_profiling_time_range()function, because it seems like a natural use case, and probably would drastically reduce the time to process large profiles. However, I didn't want to introduce a new dependency to this crate without asking.Related Work
This PR was implemented as an alternative to firefox-devtools/profiler#5682.