Closed Bug 1612310 Opened 4 years ago Closed 3 years ago

Ease recording profile when running mochitests

Categories

(Core :: Gecko Profiler, enhancement, P3)

enhancement

Tracking

()

RESOLVED DUPLICATE of bug 1628073

People

(Reporter: ochameau, Unassigned)

References

Details

It is currently easy to record a profile when running talos via ./mach talos-test ... --geckoProfile command line argument.

But there is currently no equivalent for ./mach test, nor ./mach mochitest.
It would be super handy to have an equivalent for mochitests.
It helps recording profiles while following an automated STR, instead of having to manually replay the STR manually in Firefox UI.

I've been told that the following command helps recording a profile:
MOZ_PROFILER_STARTUP=1 MOZ_PROFILER_SHUTDOWN=mochitestprofile.json ./mach mochitest
But:

  1. it isn't discoverable
  2. not documented, nor known by much folks
  3. it puts a file in some hidden location ./obj-firefox-artifact/_tests/testing/mochitest/mochitestprofile.json. We may want to put it in a simplier location and print the location while the test ends. If we could open the profiler webpage with the profile loaded, like we do for DAMP, it may be even better?

Thanks for the bug report. We're planning on improving the integrated profiling ecosystem sometime soon, either Q2 or Q3. This will probably be a P1 once we finish up some of our current work and change our focus to that.

(In reply to Alexandre Poirot [:ochameau] from comment #0)

Thank you for your comments.

About this:

I've been told that the following command helps recording a profile:
MOZ_PROFILER_STARTUP=1 MOZ_PROFILER_SHUTDOWN=mochitestprofile.json ./mach mochitest
But:

  1. it isn't discoverable
  2. not documented, nor known by much folks

It's documented in some places, e.g.: https://profiler.firefox.com/docs/#/./guide-startup-shutdown (follow the big "Documentation" button on profiler.firefox.com 😉).
How could we make it more discoverable?

Priority: -- → P3

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

It's documented in some places, e.g.: https://profiler.firefox.com/docs/#/./guide-startup-shutdown (follow the big "Documentation" button on profiler.firefox.com 😉).
How could we make it more discoverable?

You would have to strech your mind in order to imagine that you could have a mochitest being recorded via startup and shutdown environment variables set at the same time.
This documention involves clicking manually in the popup to either stop or start the profiler. It documents the independant usage of these two variables. It isn't obbious that, when using both variables, you don't need any UI interation and would get the record start and stop automatically.

The best way to make this discoverable would be to have something to appear in ./mach mochitest --help.
That's where I was looking for something, then I fallback to asking to Florian ;)

(In reply to Alexandre Poirot [:ochameau] from comment #3)

The best way to make this discoverable would be to have something to appear in ./mach mochitest --help.

Makes sense, thank you.

But as you said if you very first comment, it would be nice to just have ./mach test --geckoProfile, and avoid setting envvars.

See Also: → 1421972

One additional note, I tried using only MOZ_PROFILER_STARTUP=1, as I wanted to end the profile at a very precise time (when the test ends, to figure out a leak).
But you can't capture the record via the profiler toolbar icon because it opens non-local requests, which triggers assertions in mochitests:

 0:35.15 GECKO(68757) FATAL ERROR: Non-local network connections are disabled and a connection attempt to profiler.firefox.com (167.99.137.12) was made.
 0:35.15 GECKO(68757) You should only access hostnames available via the test networking proxy (if running mochitests) or from a test-specific httpd.js server (if running xpcshell tests). Browser services should be disabled or redirected to a local server.

What were you trying to achieve exactly? To stop the profiler you can maybe capture the profile and call the StopProfiler method directly in the test instead of clicking the icon in the test. There should be numerous examples in the profiler tests.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.