wasm JIT preferences are sometimes ignored
Categories
(Core :: JavaScript: WebAssembly, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox90 | --- | fixed |
People
(Reporter: jseward, Assigned: lth)
References
Details
Attachments
(2 files)
5.63 KB,
patch
|
Details | Diff | Splinter Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
When running wasm in a full browser build, it can happen that some about:config
options are ignored. I believe this happens, but is impossible to observe, in
unmodified m-c sources. However, when the attached patch is applied, the
problem is obvious.
STR: build on x86_64-linux. Start. Ensure that
javascript.options.wasm_baselinejit = true
javascript.options.wasm_optimizingjit = false
(meaning that we request Baseline-only). Load
https://beta.unity3d.com/jonas/AngryBots
and observe that only Ion compiles are initiated -- 40366 of them.
By contrast, loading
https://www.funkykarts.rocks/demo.html
produces only Baseline compilation, as expected.
I hypothesise (guess wildly, without much insight) that this is somehow to do
with the fact that AngryBots test case gets a child process in order to do
WebGL stuff (or something like that), whilst Funky Karts doesn't.
Reporter | ||
Comment 1•3 years ago
|
||
Patch that prints a line for each wasm function compiled, so as to make it
easy to figure out when compilation is happening and which compiler has
been used.
Assignee | ||
Comment 2•3 years ago
|
||
The first thing to do might be to carefully read docs for StaticPrefs.yml to see if we're doing something stupid / something that should be done differently. Or experiment with moving those prefs into the regular prefs to see what happens.
Comment 3•3 years ago
|
||
For the JIT prefs we've moved to process-wide flags that are only read on startup (see LoadStartupJSPrefs
). That way we don't have to worry about setting the right JSContext options for DOM workers, worklets, the PAC thread etc.
Assignee | ||
Updated•3 years ago
|
Reporter | ||
Comment 4•3 years ago
|
||
Possibly relevant (although not the cause of this bug):
bug 1697904 (Migrate more JS prefs to StaticPrefs)
Reporter | ||
Comment 5•3 years ago
|
||
Results of investigation so far (with much help from Jan):
For wasm compilation initiated by DOM worker threads, default options are
created in ContextOptions::ContextOptions(). That is copied into a JSContext
by JSContext::JSContext(). The copy is later updated by a call to
InitJSContextForWorker(), and so acquires the correct values.
For wasm compilation initiated by the main thread, default options are updated
by a call to ReloadPrefsCallback().
The problem occurs for asm.js compilations triggered by a parse task, running
in a JS helper thread. There [1], IsAsmJSCompilerAvailable() is called using
a (shared) JSContext which possibly does not have an up-to-date options_
field.
Currently I have no plan for how to fix it.
Assignee | ||
Comment 6•3 years ago
|
||
I think this is a serious problem, because it affects other JS prefs too, see bug 1698473. ReloadPrefsCallback is not called for the worker's JSContext, so it only gets default settings. This could be an old bug.
Reporter | ||
Comment 7•3 years ago
•
|
||
I should add (which I forgot, earlier) .. this isn't related to the process structure.
At least for this case. For Lars' possibly-related bug 1698473, I can't say.
For this bug, I can reproduce it (show that wrong prefs are getting used, via
debug printing) purely in the firefox "root" process. Although my minimal test
case involves both a root process and one content process, debug printing
showed the problem exists within the root process. So it must be a thread-
structure thing, per comment 5.
Comment 8•3 years ago
|
||
The wasm_baselinejit
pref was not being mirrored to Workers, but I've fixed that on https://phabricator.services.mozilla.com/D108491 .
Reporter | ||
Comment 9•3 years ago
|
||
(In reply to Ted Campbell [:tcampbell] from comment #8)
The
wasm_baselinejit
pref was not being mirrored to Workers, [..]
So .. (unclear) .. are you saying that that will fix this problem?
I kinda suspect not, because this was about the wasm_optimizingjit
pref not being mirrored to JS helper threads.
Comment 10•3 years ago
|
||
The wasm_baselinejit pref seemed wrong for workers, but based on your observations might also be wrong for other reasons, so probably not solved.
Comment 11•3 years ago
|
||
Looking at this again, I now understand what you are saying. Yes, I agree that HelperThreads don't have up-to-date ContextOptions. For JS-parsing, I tried to ensure that CompileOptions
snapshotted what it needed from the JSContext while on main-thread. For other types of options, we use JitOptions
as a global option state. These few WASM options seem to fit in their own category of ContextOptions.
Migrating them to JitOptions probably makes the most sense if they can be global state. In the future I'd like to auto-generate most of the JitOptions state from the StaticPrefsList.yaml
file.
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 12•3 years ago
|
||
Ship blocker for ARM64 Ion (FF90), though as we're disabling Cranelift at the time we can discuss to what extent it needs to be fixed by that milestone.
Assignee | ||
Comment 13•3 years ago
|
||
In addition to the above, we probably have no clear policy about whether asm.js compilation should pay attention to the wasm compiler selection, even if the asm.js compiler generates wasm that we then compile using the wasm compiler. I think this could be argued either way; and if we cared about asm.js much, we might worry about it further.
To summarize:
- this appears to affect only asm.js, for a well understood reason (comment 5, comment 11)
- with cranelift out of the picture, asm.js compilation gets only ion, which is available everywhere
A point fix that might address the issue is to update JS::CompileOptions::CompileOptions (link in comment 11) so that asm.js is disabled also if the wasm optimizing jit is unavailable or if cranelift is selected. That way, the asm.js setting is the one that controls everything. Calling IsAsmJSCompilerAvailable(cx) is possibly the right remedy.
I'll take this to play around with that, but at this stage this bug probably doesn't block shipping Ion on ARM64 in any serious way.
Assignee | ||
Comment 14•3 years ago
|
||
The computation of CompileOptions captures only the asmjs flag value,
but this is insufficient to determine if asmjs compilation is actually
supported: we must also determine whether a wasm compiler is available
to compile the wasm that is emitted by the asmjs front end.
This has been a pretty typical error pattern for us in the past, hence
the introduction of the class of wasm::WhateverAvailable(cx)
predicates to work around this. That fix needs to be used here too.
This patch adds the necessary check to the computation of
CompileOptions and for maximum clarity also distinguishes this case
from the case where the asmjs pref is turned off, even though that's
not necessary. A couple of new predicates are introduced to keep the
check clean.
Comment 15•3 years ago
|
||
Pushed by lhansen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8ebf02188fbf Compute asm.js pref correctly for CompileOptions. r=jseward
Comment 16•3 years ago
|
||
Backed out 2 changesets (bug 1697560, bug 1709803) for Spidermonkey failures in Debugger-allowUnobservedAsmJS-02.js. CLOSED TREE
Log:
https://treeherder.mozilla.org/logviewer?job_id=339074581&repo=autoland&lineNumber=17100
Push with failures:
https://treeherder.mozilla.org/jobs?repo=autoland&group_state=expanded&revision=15c327320950ae6a44cb9607a5848cf48d6ce65f
Backout:
https://hg.mozilla.org/integration/autoland/rev/d148a17a6711a31cbebd725fd2e7c02039ce7ef9
Assignee | ||
Comment 17•3 years ago
|
||
Test case enumerates all possible (and some impossible) error messages; we just need to add one more, because the patch adds one more.
Comment 18•3 years ago
|
||
Pushed by lhansen@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/b3a25413321c Compute asm.js pref correctly for CompileOptions. r=jseward
Comment 19•3 years ago
|
||
bugherder |
Description
•