POSIX signals and the Firefox Profiler

114 views
Skip to first unread message

Adam Brouwers-Harries

unread,
Nov 13, 2024, 1:03:23 PM11/13/24
to dev-pl...@mozilla.org, firef...@mozilla.org
Hello all,

In Firefox 131 we shipped the ability to control the Firefox profiler
using POSIX signals on MacOS and Linux [0]. Send SIGUSR1 to Firefox's
main process to start the profiler, and SIGUSR2 to stop the profiler and
dump a json profile to disk.

We hope that this feature will be useful for debugging Firefox in
situations where controlling the profiler via "traditional" means (such
as the UI or keyboard shortcuts) is not possible. We are already using
this functionality to attempt to gather a profile if Firefox hangs while
being tested in CI [1], so if you find yourself facing any intermittent
hangs, look to the artefacts panel in treeherder for a useful profile!

Please see profiler front-end documentation for more details of using
the feature [2], and the inline documentation if you are interested in
the implementation [3].

Finally, please reach out if you find any issues, novel uses, or manage
to fix any particularly gnarly bugs using this!

Many thanks,
Adam & The Profiler Team

[0] See Bug 1823370 for the meta-bug tracking this work.
[1] https://phabricator.services.mozilla.com/D214842
[2] https://profiler.firefox.com/docs/#/./async-posix-signal-control
[3]
https://searchfox.org/mozilla-central/source/tools/profiler/core/platform.cpp#552

Nick Alexander

unread,
Nov 13, 2024, 1:33:52 PM11/13/24
to Adam Brouwers-Harries, dev-pl...@mozilla.org, firef...@mozilla.org
Adam,

On Wed, Nov 13, 2024 at 10:03 AM 'Adam Brouwers-Harries' via firef...@mozilla.org <firef...@mozilla.org> wrote:
Hello all,

In Firefox 131 we shipped the ability to control the Firefox profiler
using POSIX signals on MacOS and Linux [0]. Send SIGUSR1 to Firefox's
main process to start the profiler, and SIGUSR2 to stop the profiler and
dump a json profile to disk.

We hope that this feature will be useful for debugging Firefox in
situations where controlling the profiler via "traditional" means (such
as the UI or keyboard shortcuts) is not possible. We are already using
this functionality to attempt to gather a profile if Firefox hangs while
being tested in CI [1], so if you find yourself facing any intermittent
hangs, look to the artefacts panel in treeherder for a useful profile!

Please see profiler front-end documentation for more details of using
the feature [2], and the inline documentation if you are interested in
the implementation [3].

Finally, please reach out if you find any issues, novel uses, or manage
to fix any particularly gnarly bugs using this!

This is great news!  I've wanted this -- very infrequently -- for a long time.

Would it be possible to forward SIGUSRn from child processes to the parent process, so that it's easier to use this?  I.e., so that consumers can't screw up searching for the relevant process?

Finally: I want it for Windows, where I do most of my work.  Is there a technical path to achieving this?

Thanks again!
Nick

Adam Brouwers-Harries

unread,
Nov 13, 2024, 2:54:23 PM11/13/24
to Nick Alexander, dev-pl...@mozilla.org, firef...@mozilla.org
Hi Nick,

> Would it be possible to forward SIGUSRn from child processes to the
> parent process, so that it's easier to use this? I.e., so that
> consumers can't screw up searching for the relevant process?

Absolutely. This is a bit of follow-on work that I've not quite got
around to just yet. It should be fairly straightforward, modulo a bit of
IPC funkiness.

> Finally: I want it for Windows, where I do most of my work. Is there a
> technical path to achieving this?

Yes, I hope! I know of some approaches that might work (though I'm no
windows expert), and I'm tracking this work in Bug 1867328.

Cheers,
Adam

On 13/11/2024 18:33, Nick Alexander wrote:
> Adam,
>
> On Wed, Nov 13, 2024 at 10:03 AM 'Adam Brouwers-Harries' via firefox-
> d...@mozilla.org <mailto:firef...@mozilla.org> <firefox-
Reply all
Reply to author
Forward
0 new messages