Closed Bug 1713287 Opened 4 years ago Closed 4 years ago

Parallel wasm compilation makes assumptions about the number of helper threads

Categories

(Core :: JavaScript: WebAssembly, task, P3)

task

Tracking

()

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

Details

Attachments

(3 files, 1 obsolete file)

Parallel wasm compilation depends on being able to run a master task that generates work at the same times as least one other task to consume the work, otherwise we can deadlock. Currently we always create at least two threads when the helper thread system is in use, but when we move to using an external thread pool that will no longer be the case.

We should check the number of threads before started parallel compilation. The helper thread system will ensure that the number of threads reported is correct when using an external thread pool.

This adds a check that there is more than one helper thread before starting
parallel compilation. It also changes the number of helper threads created so
there's only a single thread on unicore systems, which will be the case when
using the external thread pool.

Depends on D116220

This won't necessarily be true when using an external thread pool.

The maximum number of Wasm tasks is now limited by the number of cores though.

Depends on: 1704923
Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ea0e06d3b037 Check helper thread count before starting parallel wasm compilation r=lth https://hg.mozilla.org/integration/autoland/rev/99afd8d13d30 Relax the assumtion that there will be at least as many helper threads as cores r=lth
Backout by abutkovits@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/963df76dc655 Backed out 2 changesets for causing build bustages. CLOSED TREE

Backed out for causing build bustages

Push with failures

Failure Log

Backout link

Flags: needinfo?(jcoppeard)

It seems that skipping parallel Wasm compliation when there's only a single thread is not enough to make this work. There are are still deadlocks when waiting for off-thread promise helper tasks with the previous patches in this bug.

Maybe a better approach is to make the XPCOM pool more like the current JS helper thread system and ensure that there are at least two threads at all times. This would also reduce the chance of performance regressions when switching over.

Flags: needinfo?(jcoppeard)
Summary: Don't use parallel wasm compilation if there's only a single helper thread → Parallel wasm compilation makes assumptions about the number of helper threads
Attachment #9223971 - Attachment is obsolete: true

Currently parallel Wasm compilation requires at least two threads for
architectural reasons. This patch updates the TaskController thread policy such
that there are always two threads available, even on single core systems.

Pushed by jcoppeard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ade4570ab563 Change the number of threads TaskController creates to match those required by the JS engine r=bas https://hg.mozilla.org/integration/autoland/rev/9bc99e4fcbff Relax the assumtion that there will be at least as many helper threads as cores r=lth https://hg.mozilla.org/integration/autoland/rev/31567d7bd975 Add test for Wasm compilation with a single core r=lth
Blocks: 1713335
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: