Expose a "Services" property on all privileged JS scopes (like Cu/Cc/Ci)
Categories
(Core :: XPCOM, task)
Tracking
()
People
(Reporter: Gijs, Assigned: arai)
References
Details
(Keywords: perf, perf-alert, perf:startup)
Attachments
(27 files, 2 obsolete files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
After bug 1464542, Services.jsm is just a thin wrapper around Cu.createServicesCache();
We could expose it as a property on Chrome scopes similar to how bug 767640 exposed Cu/Cc/Ci . Then we can remove the thousands of ChromeUtils.import(".../Services.jsm")
calls from our codebase.
Reporter | ||
Comment 1•4 years ago
|
||
Marking fxperf as the reduction in import calls could conceivably have memory/cpu benefits
Comment 2•4 years ago
|
||
Tentatively marking fxperf:p2 as I think this is worth doing, if only to reduce the amont of ChromeUtils.import markers we see in startup profiles. I doubt the impact will be measurable for users though, so could have been p3.
Reporter | ||
Updated•3 years ago
|
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Comment 4•2 years ago
|
||
WIP: https://treeherder.mozilla.org/jobs?repo=try&group_state=expanded&revision=cacc0ce3a9d09c996297a87e6d17285d45937a9b
still some error
and also it doesn't touch require
consumers and SpecialPowers
consumers, and some edge cases, such as generated file.
Assignee | ||
Comment 5•2 years ago
|
||
https://github.com/mozilla/fxa-pairing-channel/issues/74 needs to be done concurrently
(maybe it's not urgent, given there's no frequent update on the repo)
Comment 6•2 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #5)
https://github.com/mozilla/fxa-pairing-channel/issues/74 needs to be done concurrently
(maybe it's not urgent, given there's no frequent update on the repo)
The general rule is that anything without in-tree tests doesn't block landing any change. External add-ons without in-tree tests are responsible for keeping up with breaking changes on their own. Though it's nice to warn them ahead of time.
Assignee | ||
Comment 7•2 years ago
|
||
Sorry, my comment lacks the context.
the file is the source of in-tree auto-generated file
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
Comment 8•2 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #7)
Sorry, my comment lacks the context.
the file is the source of in-tree auto-generated fileconst {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
OK, in that case it may make sense to just leave Services.jsm for now and remove it when that is updated. Or just update the generated file in the meantime. It's a fairly trivial change.
Assignee | ||
Comment 9•2 years ago
|
||
There's another issue with Android host utils.
https://treeherder.mozilla.org/logviewer?job_id=383202080&repo=try&lineNumber=1783
The latest code is interpreted with older binary.
So the related code there (at least httpd.js
) needs to be compatible both with new and old code until the host utils gets updated, that can happen only after the patch gets landed.
I'll check what part gets affected.
Assignee | ||
Comment 10•2 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #9)
There's another issue with Android host utils.
https://treeherder.mozilla.org/logviewer?job_id=383202080&repo=try&lineNumber=1783The latest code is interpreted with older binary.
So the related code there (at leasthttpd.js
) needs to be compatible both with new and old code until the host utils gets updated, that can happen only after the patch gets landed.I'll check what part gets affected.
I hope const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
works.
If that's the case, the same declaration can be used also in extensions etc.
Comment 11•2 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #9)
There's another issue with Android host utils.
https://treeherder.mozilla.org/logviewer?job_id=383202080&repo=try&lineNumber=1783The latest code is interpreted with older binary.
So the related code there (at leasthttpd.js
) needs to be compatible both with new and old code until the host utils gets updated, that can happen only after the patch gets landed.
Yes, that's an unfortunate problem I've run into more than once. It can be updated before the code lands, but keeping a stub Services.jsm until it gets updated is fine too.
Comment 12•2 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #10)
I hope
const Services = globalThis.Services || ChromeUtils.import("resource://gre/modules/Services.jsm").Services;
works.
If that's the case, the same declaration can be used also in extensions etc.
It may, depending on the kind of scope it's used in and how the global Services
is declared. But for host-utils, I don't think we have to worry. We can land the binary changes that add the Services
global and leave a stub Services.jsm, and then after host-utils is updated, land the migration to relying on the global and the removal of Services.jsm
.
We can also just deploy a new version of host-utils from a try build, and land the config changes to start using it with the rest of this bug.
Assignee | ||
Comment 13•2 years ago
|
||
Thanks, so far the above workaround seems to work.
We can use the Services.jsm stub approach as fallback path if there's any other issue.
Assignee | ||
Comment 14•2 years ago
|
||
Given the Services
object must belong to the loader's shared global,
there are 2 paths added.
For loader's shared global, xpc::CREATE_SERVICES option is passed to
xpc::InitClassesWithNewWrappedGlobal and it creates the Services
object
and defines it on the global.
For other globals, xpc::DEFINE_SERVICES option is passed to
xpc::InitClassesWithNewWrappedGlobal and it gets the Services
object
from the loader's shared global and defines it on the newly created global.
Depends on D150885
Assignee | ||
Comment 15•2 years ago
|
||
Depends on D150890
Assignee | ||
Comment 16•2 years ago
|
||
Given Services
object is already created and defined on the loader's shared
global, Services.jsm shouldn't create yet another instance.
Just return the shared global's property, to make it keeps working in the
middle of this patch's stack.
Depends on D150891
Assignee | ||
Comment 17•2 years ago
|
||
Depends on D150892
Assignee | ||
Comment 18•2 years ago
|
||
Depends on D150893
Assignee | ||
Comment 19•2 years ago
|
||
Depends on D150894
Assignee | ||
Comment 20•2 years ago
|
||
Depends on D150895
Assignee | ||
Comment 21•2 years ago
|
||
Depends on D150896
Assignee | ||
Comment 22•2 years ago
|
||
Depends on D150897
Assignee | ||
Comment 23•2 years ago
|
||
Depends on D150898
Assignee | ||
Comment 24•2 years ago
|
||
Depends on D150899
Assignee | ||
Comment 25•2 years ago
|
||
Depends on D150900
Assignee | ||
Comment 26•2 years ago
|
||
Depends on D150901
Assignee | ||
Comment 27•2 years ago
|
||
Depends on D150902
Assignee | ||
Comment 28•2 years ago
|
||
Depends on D150903
Assignee | ||
Comment 29•2 years ago
|
||
Depends on D150904
Assignee | ||
Comment 30•2 years ago
|
||
Depends on D150905
Assignee | ||
Comment 31•2 years ago
|
||
Depends on D150906
Assignee | ||
Comment 32•2 years ago
|
||
Depends on D150907
Assignee | ||
Comment 33•2 years ago
|
||
- Remove Services.jsm
- Add Services global variable
Depends on D150908
Assignee | ||
Comment 34•2 years ago
|
||
The source of the file is updated in https://github.com/mozilla/fxa-pairing-channel/issues/74
Depends on D150909
Assignee | ||
Comment 35•2 years ago
|
||
Depends on D150910
Assignee | ||
Comment 36•2 years ago
|
||
Depends on D150911
Assignee | ||
Comment 37•2 years ago
|
||
Depends on D150912
Assignee | ||
Comment 38•2 years ago
|
||
Depends on D150913
Assignee | ||
Comment 39•2 years ago
|
||
Assignee | ||
Comment 40•2 years ago
|
||
Depends on D150890
Updated•2 years ago
|
Updated•2 years ago
|
Comment 41•2 years ago
|
||
There may be out-of-tree code that loads Services.jsm, i.e. privileged extensions.
Privileged extensions that rely on Services.jsm in a WebExtension experiment can simply use Services
as a global if it targets Firefox 88 and later, since the Services
global was introduced to that scope in bug 1698158.
Assignee | ||
Comment 42•2 years ago
|
||
(In reply to Rob Wu [:robwu] from comment #41)
There may be out-of-tree code that loads Services.jsm, i.e. privileged extensions.
discussion about out-of-tree code in bug 1777486.
Privileged extensions that rely on Services.jsm in a WebExtension experiment can simply use
Services
as a global if it targets Firefox 88 and later, since theServices
global was introduced to that scope in bug 1698158.
Good to know. I'll draft an email for privileged extensions authors.
Assignee | ||
Comment 43•2 years ago
|
||
So far, I don't see any performance impact in talos
https://treeherder.mozilla.org/perfherder/compare?originalProject=try&originalRevision=48549ef578058976af2c6149c2b4361212f8ed86&newProject=try&newRevision=125af292176784acb0ac2f3618e7a758a5824fff&framework=1
Assignee | ||
Comment 44•2 years ago
|
||
given bug 1777906 will take some time, we'd better deferring the Services.jsm
file removal into followup bug, or land it later with leave-open
.
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 45•2 years ago
|
||
Depends on D150913
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 46•2 years ago
|
||
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Comment 47•2 years ago
|
||
I'll land up to Part 24, keeping the Services.jsm
file in tree, so that quitter.xpi
keeps working, while there's no other Services.jsm
consumer
Comment 48•2 years ago
|
||
Updated•2 years ago
|
Comment 49•2 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/34c394b9c75f
https://hg.mozilla.org/mozilla-central/rev/87ac3e68b65c
https://hg.mozilla.org/mozilla-central/rev/b1b9c2253479
https://hg.mozilla.org/mozilla-central/rev/3ca5cef1f6a5
https://hg.mozilla.org/mozilla-central/rev/740d9d3682db
https://hg.mozilla.org/mozilla-central/rev/05f96b585cb1
https://hg.mozilla.org/mozilla-central/rev/ad6234248f3d
https://hg.mozilla.org/mozilla-central/rev/ae74e5acc07a
https://hg.mozilla.org/mozilla-central/rev/67c4a154b997
https://hg.mozilla.org/mozilla-central/rev/77adca5277bb
https://hg.mozilla.org/mozilla-central/rev/2bfc02b367b2
https://hg.mozilla.org/mozilla-central/rev/cdaef3be8f9b
https://hg.mozilla.org/mozilla-central/rev/2b9c6e981362
https://hg.mozilla.org/mozilla-central/rev/cc60fad3242f
https://hg.mozilla.org/mozilla-central/rev/ddf8e7192a86
https://hg.mozilla.org/mozilla-central/rev/47c896d5a269
https://hg.mozilla.org/mozilla-central/rev/a653b4080d9e
https://hg.mozilla.org/mozilla-central/rev/61f066cec38f
https://hg.mozilla.org/mozilla-central/rev/1eb3c259c000
https://hg.mozilla.org/mozilla-central/rev/56af53154205
https://hg.mozilla.org/mozilla-central/rev/3fdd6fd30f3c
https://hg.mozilla.org/mozilla-central/rev/79a7ec7c55c6
https://hg.mozilla.org/mozilla-central/rev/7d1ca779e507
https://hg.mozilla.org/mozilla-central/rev/4a78e424e248
https://hg.mozilla.org/mozilla-central/rev/911d540fce6f
https://hg.mozilla.org/mozilla-central/rev/4529b79391c8
https://hg.mozilla.org/mozilla-central/rev/563470602734
Assignee | ||
Comment 50•2 years ago
|
||
Adding reminder to move the remaining patches to followup bug at the point of soft freeze.
(this is not actually "test" reminder, but using it for now)
If quitter.xpi dependency gets sorted out before that point, we can land them here.
Comment 51•2 years ago
|
||
== Change summary for alert #34800 (as of Wed, 13 Jul 2022 05:25:36 GMT) ==
Improvements:
Ratio | Test | Platform | Options | Absolute values (old vs new) |
---|---|---|---|---|
0.38% | Base Content JS | macosx1015-64-shippable-qr | fission | 1,639,512.00 -> 1,633,304.00 |
0.34% | Base Content JS | linux1804-64-shippable-qr | fission | 1,610,467.33 -> 1,604,954.67 |
0.33% | Base Content JS | windows10-64-2004-shippable-qr | fission | 1,612,408.00 -> 1,607,128.00 |
0.31% | Base Content JS | linux1804-64-shippable-qr | fission | 1,610,452.67 -> 1,605,466.67 |
For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=34800
Updated•2 years ago
|
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Comment 52•2 years ago
|
||
I'll move the removal patches to followup bug
Comment 53•2 years ago
|
||
Comment on attachment 9283939 [details]
Bug 1667455 - Part 25: Remove Services.jsm. r?kmag!
Revision D150914 was moved to bug 1780695. Setting attachment 9283939 [details] to obsolete.
Comment 54•2 years ago
|
||
Comment on attachment 9283942 [details]
Bug 1667455 - Part 26: Remove Cu.createServicesCache. r?kmag!
Revision D150915 was moved to bug 1780695. Setting attachment 9283942 [details] to obsolete.
Updated•2 years ago
|
Assignee | ||
Updated•2 years ago
|
Updated•2 years ago
|
Description
•