Open Bug 1601087 Opened 6 years ago Updated 12 days ago

Capture profiles off-main thread

Categories

(Core :: Gecko Profiler, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: mozbugz, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [fxp])

When the user selects to capture a profile, nsProfiler::StartGathering() requests profiles from child processes and synchronously grabs the profile from the current process, which can block the main thread for a relatively long time, causing visible jank.

Instead we should move the capture to another thread.

Technical details:

  • This means we'll need to stop or pause the profiler so that no more data is added in the main process.
  • If the profiler is running, we could possibly do the work on the SamplerThread (it's already there, and would block the profiler anyway).
  • In child processes, I think we also gather profiles from the main thread, we should consider moving it off-MT as well.

(In reply to Gerald Squelart [:gerald] (he/him) from comment #0)

No, child processes gather on a background thread. The ProfilerChild protocol endpoint is moved to a dedicated "ProfilerChild" thread when the connection is established.
The other big challenge for capturing parent process profiles off the main thread would be to grab the profile.meta information on the main thread first, because StreamMetaJSCustomObject only grabs a limited amount of information when called on a background thread.

(In reply to Markus Stange [:mstange] from comment #1)

(In reply to Gerald Squelart [:gerald] (he/him) from comment #0)

No, child processes gather on a background thread. The ProfilerChild protocol endpoint is moved to a dedicated "ProfilerChild" thread when the connection is established.

Thank you. Easy then 😄

The other big challenge for capturing parent process profiles off the main thread would be to grab the profile.meta information on the main thread first, because StreamMetaJSCustomObject only grabs a limited amount of information when called on a background thread.

Good to know. I think most of the time is spent streaming data from the profile buffer, so it's shouldn't be a problem to quickly gather meta information from the main thread, and add the main profile data on a separate thread.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.