Open Bug 1811807 Opened 2 years ago Updated 3 months ago

Store the marker stacks inside the main profiler buffer rather than their own buffers

Categories

(Core :: Gecko Profiler, task, P2)

task

Tracking

()

People

(Reporter: canova, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fxp])

Currently we are capturing the stacks of markers inside their small single-use buffers.
Here's an example: this is where we capture first and this is where we add the marker with this stack after

This is not great for multiple reasons but the main reasons are:

  1. Allocating all these temporary buffers are slow and it skews our profiles when there are a lot of markers with stacks.
  2. They don't abide the global profiler memory limit which means that if there are alot of markers with stacks, it can increase the memory usage significantly (see Bug 1811755).

These are the main reasons that we would prefer to keep them inside the main profiler buffer instead. It would be great to just push this sample inside the main profiler buffer instead of allocating a lot of single-use buffers like this.

Whiteboard: [fxp]

Exploration results from the PerfTools Cluj Workweek:

  • The API for the ProfilerBuffer & ProfilerChunkedStorage is not very amenable to taking references (or views?) to parts of a buffer. We need to implement something that looks like a view onto a buffer, and pass that around instead of a small buffer.
  • The existing code that writes to a profiler buffer while stackwalking needs a threadsafe buffer (platform.cpp:2916), but the main buffer is not threadsafe.
  • It may be that our current buffer implementation isn't amenable to this. We may need a lock-free buffer to allow markers to write to it.
  • An alternative might be having two separate buffers for markers and samples?
You need to log in before you can comment on or make changes to this bug.