tl;dr: importGlobalProperties is expensive. If you don't need the imported properties immediately, please use defineLazyGlobalGetters instead.

Calling importGlobalProperties immediately defines the properties that you're importing and any prototypes that they require. Aside from CPU overhead, this also tends to consume a lot of memory, especially for objects with complex prototypes. And it does this once for every global you call it in. This is especially a problem for content processes, since we get this memory overhead in each and every content process (and remember, as a part of Project Fission, we're aiming to be able to run 100 content processes for ordinary users).

Ordinary WebIDL globals don't really have this problem, since they're already defined lazily via resolveProperty hooks. In bug 1464548, I added XPCOMUtils.defineLazyGlobalGetters, which has somewhat similar behavior, and also has the benefit of always creating the global in the shared JSM module scope, no matter which global it's called from. Please use that helper from now on unless you have a very good reason not to.

Thanks.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to