Initializing the log module takes extra time for each and every process creation
Categories
(Remote Protocol :: Marionette, defect, P3)
Tracking
(firefox91 fixed)
Tracking | Status | |
---|---|---|
firefox91 | --- | fixed |
People
(Reporter: whimboo, Assigned: whimboo)
References
Details
(Keywords: perf)
Attachments
(1 file, 1 obsolete file)
As discovered in the #fission channel there is a bit of noise for performance tests around content process creation time. Especially when the MarionetteEvents child actor is getting created. Here we call logger.trace()
to print actor creation information if the log level is Trace
:
This call always takes around 2ms, which isn't much, but as said above adds noise when analyzing a profile. Problem is that even for log levels of Info
and Debug
we are creating the logger, whereby it's just a no-op and nothing gets logged.
The problem actually is inside the Toolkit logger which doesn't cache the preference name and value, so that manageLevelFromPref takes 50% of the time.
As such any code in Marionette that uses our own logger needs to configure the logger for each and every process, because existing ones aren't shared:
Here a profile:
https://share.firefox.dev/2S62b9W
Nika, I'm not sure how much we can actually do on our side. Also it seems like that each and every consumer of the toolkit logger has the same problem. So fixing it there might be a better approach?
Assignee | ||
Comment 1•4 years ago
|
||
So for the first page load the above mentioned delay gets hit even twice. First when the pagehide
event is fired by about:blank
because that causes the events actor to be instantiated for the given browsing context. And then again for the next page load event (DOMContentLoaded
or pageshow
) because these also cause the actor to be created for the new browsing context. There might even be cases when the process gets switched multiple times...
Easiest solution would be to just remove the call to log.trace() in actorCreated
, but it would also mean we will miss information for failure investigation. As such I would do that only in case of no other solution.
Over the weekend Mark Banner mentioned that there is also console.createInstance()
, and which supports setting a prefix and a maximum level. For Marionette it could look like the following:
const logger = console.createInstance({
maxLogLevelPref: "marionette.log.level",
prefix: "Marionette",
});
I didn't test that yet but it might need devtools.console.stdout.chrome
set to true
so that those log entries also appear on stdout
. Sadly all the other chrome logging from other Firefox components will also end-up there so that we hit bug 1399441. By default we don't want to see anything else beside Marionette and soon the Remote Agent.
Comment 2•4 years ago
|
||
I don't think I have very much I can easily contribute here, so clearing ni?
Assignee | ||
Comment 3•4 years ago
|
||
Randell, how important is it to get these extra calls out of the performance profile? There might be workarounds for now that we could check, but won't have the time to fully fix the underlying problem in the short term due to the filtering problems on geckodriver's side. Thanks.
Comment 4•4 years ago
|
||
we're trying to get rid of ~30ms of delay when loading into new processes (more realistically get it down to 20 or maybe even 10ms), so even 2ms is a significant amount. It occurs at a critical point when there's no way to 'hide' the delay. I'd say it's moderately important.
Assignee | ||
Comment 5•4 years ago
|
||
Ok, so lets see what we can do here. Given that the trace output is helpful to us in case of failure investigations in Marionette we would like to leave the call for logger.trace()
in the actorCreated
method. But we could definitely have a preference check before and only execute it if the logger is indeed set to Trace
level.
Anything else might not work at this time due to the above mentioned issues with geckodriver, which would take much work work to get it properly done.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 6•4 years ago
|
||
Jesup, how does the measurement look like when this patch gets applied to Marionette? Locally I don't see any overhead anymore. If that's the same for you I'm happy to finalize it and get it landed as a workaround for now.
Comment 7•4 years ago
|
||
When I profile with your patch in browsertime, I still see getLogger() and Log.jsm::set parent and updateAppenders(), etc: https://share.firefox.dev/2SoyXTV
I also later see Log.jsm being used by MarionetteEventsChild::actorCreated (calls trace()->log()....)
Comment 8•4 years ago
|
||
Command line to capture the profile:
(what the script I use ends up calling)
./mach browsertime --firefox.binaryPath='/home/jesup/bin/firefox/firefox' --pageCompleteWaitTime 10000 --webdriverPageload true --firefox.preference network.http.speculative-parallel-limit:6 --firefox.preference gfx.webrender.enabled:true --firefox.preference gfx.webrender.precache-shaders:true --firefox.geckoProfiler true --firefox.geckoProfilerParams.interval 0.3 --firefox.geckoProfilerParams.features java,js,stackwalk,leaf,ipcmessages --firefox.geckoProfilerParams.threads GeckoMain,Compositor,IPDL,Worker --firefox.geckoProfilerParams.bufferSize 200000000 --visualMetrics true --video true --visualMetricsContentful true --visualMetricsPerceptual true --videoParams.addTimer false --videoParams.createFilmstrip false --videoParams.keepOriginalVideo false --firefox.windowRecorder=true -n 1 --firefox.preference network.dns.forceResolve:192.168.1.19 --firefox.preference network.socket.forcePort:80=8080;443=8080 --firefox.acceptInsecureCerts true /home/jesup/src/mozilla/browsertime_on_android_scripts/preload.js --browsertime.url https://www.google.com/search?hl=en&q=barack+obama&cad=h --resultDir browsertime-results/www.google.com_search_hl=en_q=barack+obama_cad=h/e10s
Comment 9•4 years ago
|
||
I presume this means that browsertime is telling it to trace, for some reason?
Comment 10•4 years ago
|
||
Never mind, I was running Nightly in that profile I think
Comment 11•4 years ago
|
||
With the right build, I don't see any trace() calls anymore, thanks
Assignee | ||
Comment 12•4 years ago
|
||
(In reply to Randell Jesup [:jesup] (needinfo me) from comment #11)
With the right build, I don't see any trace() calls anymore, thanks
Good to know and thanks for the testing. I'll upload a patch for review tomorrow. Also I will file a new bug to move to console.createInstance()
.
Assignee | ||
Comment 13•4 years ago
|
||
Updated•4 years ago
|
Assignee | ||
Comment 14•4 years ago
|
||
(In reply to Randell Jesup [:jesup] (needinfo me) from comment #11)
With the right build, I don't see any trace() calls anymore, thanks
The recently attached patch was actually broken. I'm sorry for that. So can you please have a look again and this time make use of the patch as uploaded to Phabricator? Would be good to know that the 2ms delay is fully gone. Thanks!
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 15•4 years ago
|
||
I'm going to just land this patch. If it doesn't fully fix the content process startup delay please file a new bug. Thanks.
Comment 16•4 years ago
|
||
Comment 17•4 years ago
|
||
bugherder |
Updated•2 years ago
|
Description
•