If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

Initialize sandbox global properties lazily




6 months ago
11 days ago


(Reporter: kmag, Unassigned)


(Blocks: 1 bug, {perf})

Firefox Tracking Flags

(Not tracked)


(Whiteboard: [qf:p3])

When we create Sandboxes with wantGlobalProperties, those properties, along with their interfaces and prototypes, are created eagerly, even though they may never be used. For content script sandboxes, the time we spend creating XHR and fetch/Response prototypes seems to add up to something significant, even though they're not likely to ever be used by most content scripts.

We should create these objects dynamically, when they're first used, like we do for ordinary DOM windows.
Priority: -- → P2

Comment 1

6 months ago
Kris, has this come up in a profile (perhaps in relation to bug 1317681)?
Flags: needinfo?(kmaglione+bmo)
Yes, but the only profile data I currently have for it is from talos, which is a bit flaky. I need to look into it some more with the profiler add-on, but I wanted to make sure I filed a bug before I forgot.

But creating content script Sandboxes is definitely more expensive than I'd like (though not as expensive as nuking them), and this is the part of the process that seems to consistently show up in profiles.
Flags: needinfo?(kmaglione+bmo)
OK, looking at a profile from the profiler add-on, loading cnn.com a bunch of times with an extension that loads an empty content script into every frame:


it looks a bit better than it did on talos. We spend a total of about 8ms in CreateSandboxObject, which is about a third of the total time we spend loading content scripts (~half after another set of patches land), but it looks like nearly all of that is in defining global properties.


6 months ago
Whiteboard: [qf] → [qf:p3]

Comment 4

6 months ago
Thanks for the extra info, Kris.  :-)


4 months ago
Blocks: 1363905
No longer blocks: 1317681
Keywords: perf
You need to log in before you can comment on or make changes to this bug.