Add way to pre-walk a stack trace in an RAII label-like object, and re-use it for all stack walks
Categories
(Core :: Gecko Profiler, task, P3)
Tracking
()
People
(Reporter: mozbugz, Unassigned)
References
(Blocks 2 open bugs)
Details
A lot of stack traces have frames in common near the root.
For example, in threads with an event queue handler, the stack from the root to the event-handling loop function is always the same for most of the thread lifetime.
But during sampling, we keep reading these frames and storing them in the buffer.
It may be worth investigating a way to avoid re-reading these unchanging frames. It may also help with removing some of the gaps when stack-walking fails.
The basic idea is to provide an RAII object, similar to a label (or a real label itself), that the developer would position in long-lived portions of code.
This object would immediately collect a stack trace, and register itself in some thread-local storage.
Then during normal periodic sampling, and maybe also on-the-spot stack captures (e.g., in markers), the stack walk could stop when it reaches the RAII object frame.
Later, when generating the output JSON, the pre-recorded root-side of the stack would be re-used and stitched with each leaf-side stack.
Description
•