Closed Bug 1568197 Opened 4 years ago Closed 4 years ago

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


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




Firefox 70
Tracking Status
firefox70 --- fixed


(Reporter: mconley, Assigned: mcheang)


(Blocks 3 open bugs)


(Whiteboard: [fxperf:p1])


(1 file)

ActivityStream.jsm loads JSM's eagerly here:

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:

The time spans roughly 200ms.

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

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):

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:

Pushed by
load JSMs lazily in ActivityStream.jsm and OnboardingMessageProvider.jsm. r=mconley
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 70
You need to log in before you can comment on or make changes to this bug.