Closed Bug 1572538 Opened 6 years ago Closed 3 years ago

Running ExtensionProcessScript.jsm during page load takes significant amount time

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(Performance Impact:high)

RESOLVED WORKSFORME
Performance Impact high

People

(Reporter: smaug, Unassigned)

References

Details

(Keywords: perf:pageload)

instagram on G5 through geckoview nightly from taskcluster
https://perfht.ml/2MYc9Wz

I think the biggest part of the problem here is that these modules aren't in the script preloader, which means they have to be compiled from source whenever they're loaded, since we have no other form of startup cache in content processes.

Ted and I have talked about populating the child preloader cache with scripts that aren't needed at startup so that we can still use their entries for bytecode sharing, but it would also help with problems like this.

Whiteboard: [qf?] → [qf:p1:pageload]
Priority: -- → P3

We should take another profile, see if this is still a problem now. This bug is about loading a page inside a new content process.

I think I still see the same thing as of today. It looks like PreloadContentScript takes 130ms on the G5+ which is a notch above the g5

From the profile, it looks like we spend quite some time in _log (this is a lot less than the import obviously, but still quite some time) => https://share.firefox.dev/3ef9Lrj.

(but maybe you enabled logs specifically here?)

Hey Marc,
it looks like that your link in comment 3 links to the old profile! Have you shared the wrong link?
I should have seen that earlier, sorry about that!

Flags: needinfo?(mleclair)
Flags: needinfo?(mleclair)
Performance Impact: --- → P1
Keywords: perf:pageload
Whiteboard: [qf:p1:pageload]

Can a new profile be collected to determine if this is still a significant issue?

Flags: needinfo?(bugs)

We improved start up script caching in bug 1632682. In comment 5, I specifically reference ExtensionProcessScript.jsm. When I worked on the bug in Feb 2022, it sounds like I didn't observe ExtensionProcessScript to be as slow as when this bug was originally filed. Also, my changes didn't do much to improve ExtensionProcessScript. Here's a snippet of that comment:

and see that each script takes less time to import (though some still take surprisingly long, e.g. ExtensionProcessScript.jsm goes from 26.2ms to 25.3ms).

I think it'd still be worth capturing a new profile to see if this is still an issue.

Depends on: 1632682

hmm, the profiles looks all different. We're loading something totally different these days?
See for example https://share.firefox.dev/3IPTM0H

But anyhow, ExtensionProcessScript.jsm or such doesn't show up. I'll file a new but about instagram record.

filed https://bugzilla.mozilla.org/show_bug.cgi?id=1779879

Status: NEW → RESOLVED
Closed: 3 years ago
Flags: needinfo?(bugs)
Resolution: --- → WORKSFORME

(In reply to Michael Comella (:mcomella) [needinfo or I won't see it] from comment #7)

We improved start up script caching in bug 1632682. In comment 5, I specifically reference ExtensionProcessScript.jsm. When I worked on the bug in Feb 2022, it sounds like I didn't observe ExtensionProcessScript to be as slow as when this bug was originally filed. Also, my changes didn't do much to improve ExtensionProcessScript. Here's a snippet of that comment:

I don't think those changes should have affected ExtensionProcessScript at all. They didn't change when it would run, and it's loaded as a message manager process script, which have been loaded after the script preloader was initialized as long as there has been a preloader in the content process.

(In reply to Marc Leclair [not active] from comment #3)

I think I still see the same thing as of today. It looks like PreloadContentScript takes 130ms on the G5+ which is a notch above the g5

The problem with the preloader here is actually that ExtensionContent.jsm is loaded too late to be available in a bytecode cache, for reasons related to security. We would ideally like to fix that.

That said, only about 18ms of the time spent running that function is in reading/compiling ExtensionContent.jsm, and another 19ms reading/compiling ExtensionChild.jsm. The rest is in running their initialization code. But it would be nice if we weren't wasting that 37ms.

You need to log in before you can comment on or make changes to this bug.