Closed Bug 1388221 Opened 7 years ago Closed 6 years ago

Cache existing module exports when defining lazy module getters

Categories

(Core :: XPConnect, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
Performance Impact high

People

(Reporter: kmag, Assigned: kmag)

References

(Blocks 1 open bug)

Details

(Keywords: perf, Whiteboard: [fxperf:p3])

Attachments

(1 file)

We burn a bunch of cycles at startup just creating and populating temporary export holder objects in defineLazyModuleGetter calls, to say nothing of other Cu.import overhead. On my machine, it looks like caching the temporary exports objects saves about 30ms of startup overhead.
Is this as simple as making defineLazyModuleGetter do a Cu.isModuleLoaded check and if it's true call Cu.import directly instead of defineLazyGetter?
(In reply to Florian Quèze [:florian] [:flo] from comment #1)
> Is this as simple as making defineLazyModuleGetter do a Cu.isModuleLoaded
> check and if it's true call Cu.import directly instead of defineLazyGetter?

Hm. No, that's a separate issue, but it's an interesting idea. Defining and then redefining lazy getters tends to get fairly expensive, so that might speed things up even more.
Whiteboard: [qf] → [qf:p2]
Comment on attachment 8895047 [details]
Bug 1388221: Optimize defineLazyModuleGetter for already-loaded modules.

https://reviewboard.mozilla.org/r/166178/#review171708

Looks good to me, thanks!
Attachment #8895047 - Flags: review?(florian) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/eca521df662fffe4d3b6de833a01a5f152a3db6e
Bug 1388221: Optimize defineLazyModuleGetter for already-loaded modules. r=florian
Priority: -- → P2
Keywords: perf
Kris, do you think you'll be able to get back to this some time soon? Should it be qf:p1 or is it more of a qf:p3 thing?
Flags: needinfo?(kmaglione+bmo)
Whiteboard: [qf:p2] → [qf:i60][qf:p1]
Whiteboard: [qf:i60][qf:p1] → [qf:f60][qf:p1]
Whiteboard: [qf:f60][qf:p1] → [qf:f61][qf:p1]
Whiteboard: [qf:f61][qf:p1] → [qf:f61][qf:p1] [fxperf]
Whiteboard: [qf:f61][qf:p1] [fxperf] → [qf:f61][qf:p1] [fxperf:p3]
I wound up fixing this in ChromeUtils, so these patches aren't necessary anymore.
Status: NEW → RESOLVED
Closed: 6 years ago
Flags: needinfo?(kmaglione+bmo)
Resolution: --- → FIXED
Performance Impact: --- → P1
Whiteboard: [qf:f61][qf:p1] [fxperf:p3] → [fxperf:p3]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: