Open Bug 1625546 Opened 5 years ago Updated 1 year ago

Add support for startup profiling

Categories

(DevTools :: Performance Tools (Profiler/Timeline), enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: gregtatum, Unassigned)

References

Details

(Whiteboard: [fxp-profiler])

We should automate the process of doing startup profiling by providing a button in about:profiling.

This was brought up in the add-on as well: https://github.com/firefox-devtools/Gecko-Profiler-Addon/issues/31

Markus wrote

The old add-on's code to handle this is inside main.js, search for profileRestart. Basically, if the environment variable MOZ_PROFILER_STARTUP is set to a non-empty string, the profiler automatically starts itself on initialization, and if the env var MOZ_PROFILER_SHUTDOWN is set to a filename, then the profiler dumps out a profile to that file during shutdown. Restarting Firefox using appStartup.quit(appStartup.eForceQuit | appStartup.eRestart); preserves environment variables.

Let's scope this bug just to startup profiling. We can have a new bug for shutdown profiling.

This should be all we need for startup profiling:

    let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
    env.set("MOZ_PROFILER_STARTUP", "1");
    Services.startup.quit(Ci.nsIAppStartup.eRestart | Ci.nsIAppStartup.eAttemptQuit);
Summary: Add support for restart profiling → Add support for startup profiling

Now we just need to find a good spot for the button.

Oh, and for extra credit, we should read the profiler settings and set the other environment variables so that the settings get applied during startup profiling: MOZ_PROFILER_STARTUP_ENTRIES, MOZ_PROFILER_STARTUP_INTERVAL, MOZ_PROFILER_STARTUP_FEATURES, MOZ_PROFILER_STARTUP_FILTERS

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