Closed Bug 1568197 Opened Last month Closed 9 days ago

Avoid loading JSMs eagerly in ActivityStream.jsm and other Activity Stream modules

Categories

(Firefox :: New Tab Page, task, P1)

task

Tracking

()

RESOLVED FIXED
Firefox 70
Tracking Status
firefox70 --- fixed

People

(Reporter: mconley, Assigned: mcheang)

References

(Blocks 4 open bugs)

Details

(Whiteboard: [fxperf:p1])

Attachments

(1 file)

ActivityStream.jsm loads JSM's eagerly here:

https://searchfox.org/mozilla-central/rev/4436573fa3d5c4311822090e188504c10c916c6f/browser/components/newtab/lib/ActivityStream.jsm#24-69

It looks like this was done in bug 1376984 to avoid the overhead from XPCOMUtils.

Thankfully, I believe these days, ChromeUtils.defineModuleGetter has far less overhead than XPCOMUtils, so we might be able to make these JSMs lazy again - presuming there exist ones that aren't going to be used immediately after ActivityStream.jsm loads.

Here's a profile demonstrating the impact of loading all of these JSM's eagerly: https://perfht.ml/2YtTtEg

The time spans roughly 200ms.

I'll also note that the OnboardingMessageProvider.jsm also loads some JSMs eagerly here:

https://searchfox.org/mozilla-central/rev/4436573fa3d5c4311822090e188504c10c916c6f/browser/components/newtab/lib/OnboardingMessageProvider.jsm#6-14

There might be some cheap start-up wins if we switch these all to use ChromeUtils.defineModuleGetter instead.

Here's an example of the impact of loading these JSMs eagerly on a fresh start (brand new profile):

https://perfht.ml/2YqgpE4

This time is greatly magnified, probably because the JSMs aren't being loaded from the StartupCache - the imports span a period of about 4 seconds.

Blocks: 1546460
Blocks: perf-tweaks
Blocks: 1541259
Assignee: nobody → mcheang
Whiteboard: [fxperf] → [fxperf:p1]
Priority: -- → P1

I'm going to be on PTO next week, and will be unable to test this on my 2018 reference device frame recording rig... Scott, do you think you'd have a moment to test this patch to see what (if any) impact there is on cold start-up times for about:home?

Flags: needinfo?(sdowne)

Hey sorry just saw this (Holiday Monday through me off), yeah I can try to fit it in today or tomorrow. That work?

Flags: needinfo?(sdowne)

Hi Scott,
I think that will work. Thank you.

Looks like there is a benefit from making these changes, more details here: https://docs.google.com/document/d/1V3MEcS9bi-zMk-mLtoiVR7PN5gVlRGYz1o6u5SguzzY/edit#heading=h.u2htzavssm71

Pushed by mconley@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/52afb5d23b15
load JSMs lazily in ActivityStream.jsm and OnboardingMessageProvider.jsm. r=mconley
Status: NEW → RESOLVED
Closed: 9 days ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 70
You need to log in before you can comment on or make changes to this bug.