Closed
Bug 1431353
Opened 7 years ago
Closed 7 years ago
Investigate improving performance of off-thread parsing
Categories
(Core :: JavaScript Engine, enhancement)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla60
| Tracking | Status | |
|---|---|---|
| firefox60 | --- | fixed |
People
(Reporter: jonco, Assigned: jonco)
References
Details
Attachments
(2 files)
|
1.03 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
|
30.08 KB,
patch
|
luke
:
review+
|
Details | Diff | Splinter Review |
We have an API to parse JS code in on a helper thread while leaving the main thread free to do other things. I'd like us to make heavier use of this in the future, specifically for preloading module scripts. This bug is about improving its performance.
| Assignee | ||
Comment 1•7 years ago
|
||
First of all, we currently only allow a single off-thread parse to be active at once. I'd like to remove this limitation.
The comments say:
// Don't allow simultaneous off thread parses, to reduce contention on the
// atoms table. Note that wasm compilation depends on this to avoid
// stalling the helper thread, as off thread parse tasks can trigger and
// block on other off thread wasm compilation tasks.
(see https://searchfox.org/mozilla-central/source/js/src/vm/HelperThreads.cpp#1194 )
We have a per-zone atom cache that was added fairly recently (bug 1350760) so access to the atoms table should not be such a bottleneck now.
Luke, is the point about wasm compilation still valid? What can we do to address this?
Flags: needinfo?(luke)
Comment 2•7 years ago
|
||
Good news: this comment goes back to the beginning and it is to prevent a dining philosophers deadlock since parse tasks with asm.js could block on other helper tasks. Since then, we (Lars) made scheduling a hair more sophisticated by adding the "isMaster" argument (which means "this task can block on other helper tasks completing) to checkTaskThreadLimit() which ensures that we never have all helper threads running master tasks. We even set isMaster=true in canStartParseTask() with a comment for asm.js... but apparently we never bumped maxParseTasks() up from 1 :P
Flags: needinfo?(luke)
Comment 3•7 years ago
|
||
The master task management was inspired by off-thread parsing but was actually implemented for the sake of wasm tiered compilation, which initially had a master task. (I'm fairly sure Luke later rewrote that code to avoid the master task for wasm.) Feel free to increase the maximum number of parse tasks :)
(Insert standard observation about needing a more dynamic scheduler.)
| Assignee | ||
Comment 4•7 years ago
|
||
Great, here's a patch to remove this limit.
Attachment #8943966 -
Flags: review?(luke)
| Assignee | ||
Comment 5•7 years ago
|
||
We should expose this via the shell so that it gets fuzz coverage. Previously we could only compile a single script off-thread at a time.
This patch removes this limitation and gives each shell context a list of off-thread parse jobs. Shell functions that start an off-thread job (offThreadCompileScript, offThreadCompileModule and offThreadDecodeScript) now return an integer ID. This can then be passed to the functions that wait for the jobs to finish (runOffThreadScript, finishOffThreadModule and runOffThreadDecodedScript).
So as not to have to change all the existing test code I made the ID argument optional in the case where there's only a single pending job.
Attachment #8943967 -
Flags: review?(luke)
Comment 6•7 years ago
|
||
Great to have this fixed!
Updated•7 years ago
|
Attachment #8943966 -
Flags: review?(luke) → review+
Comment 7•7 years ago
|
||
Comment on attachment 8943967 [details] [diff] [review]
bug1431353-shell-off-thread-jobs
Review of attachment 8943967 [details] [diff] [review]:
-----------------------------------------------------------------
Nice!
Attachment #8943967 -
Flags: review?(luke) → review+
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/91e2856488e7
Remove limit on number of threads used for off-thread parsing r=luke
https://hg.mozilla.org/integration/mozilla-inbound/rev/467d285e001c
Regoranise the shell interface to off-thread parsing to allow concurrent off-thread parse jobs r=luke
Comment 9•7 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/91e2856488e7
https://hg.mozilla.org/mozilla-central/rev/467d285e001c
Status: NEW → RESOLVED
Closed: 7 years ago
status-firefox60:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
You need to log in
before you can comment on or make changes to this bug.
Description
•