-
Notifications
You must be signed in to change notification settings - Fork 32
Firefox issues vis-a-vis shared memory spec #2
Comments
The "return to event loop" problem is probably not allowed by the current WHATWG spec, but (so far) I have not found enough rigor in that spec to say for sure. The spec for creating a worker says (10.2.4 Processing Model) to fork off a worker and then run it ("Create a separate parallel execution environment (i.e. a separate thread or process or equivalent construct), and run the rest of these steps in that context."). This implies fairly strongly ("parallel", "thread or process") that immediate and true concurrency are required. The issue of not creating the worker it until the creating agent returns to the event loop is observable to a remote server (XHR from the worker) or to the user (lack of output in console) and of course using shared memory (starvation / deadlock when the worker does not update shared memory or wake a waiting agent). |
The spec language quoted in the previous comment actually also prohibits the second Firefox issue. Both are issues regarding the timing of worker creation. But the first issue has a simple workaround (return to the event loop) where the second has only a complicated workaround (create a worker, return to the event loop, wait for a message from that worker that it is running, and if not, you know you're past your limit). |
Bug filed against the WHATWG spec here: https://www.w3.org/Bugs/Public/show_bug.cgi?id=29039 |
One Mozilla bug with plenty of discussion: Bug 1052398, Web workers past the first twenty will silently fail to launch |
With the closing of Issue #36, Firefox no longer allows blocking on the main thread, neutralizing the first of the issues tracked here. (The per-domain limit is still a problem.) |
One idea that won't work but that has been considered (this a according to a conversation I had with Jonas Sicking) as a replacement for the current per-domain limit is a browser-wide thread pool where workers are multiplexed onto threads from the pool, this would allow workers to run as long as there is a thread available to run them, instead of having a static allocation of threads to workers. This won't work because a worker will block in futexWait, hogging that thread. The typical case for asm.js programs will be for workers to run their own event loop, using futexWait to block until data is available (in shared memory). The thread will be unavailable at that point, by design. No other worker can use it, even if the worker is blocked. I suppose the futexWait could surrender the thread. But forward-progress guarantees probably precludes this kind of solution unless there is also some kind of timeslicing (green threads, whatever) involved to make sure that a thread that can run will eventually run. |
Closing this because it's not relevant for the TC39 work and Mozilla tracks the issue locally. I filed a bug against HTML to allow discussion of worker resource management: whatwg/html#851. |
Two issues I'm aware of so far, there might be more:
The text was updated successfully, but these errors were encountered: