Module-based parallel JS strawman

Florian Bösch pyalot at
Sun Nov 6 21:04:32 UTC 2016

On Sun, Nov 6, 2016 at 9:29 PM, Isiah Meadows <isiahmeadows at>

> My main focus on this was CPU scheduling and time sharing. Most runtimes
> already shove most outside I/O to another thread, so I wasn't that
> concerned about that. (You could use some indirection and deferral to
> implement cooperative multitasking.)
The problem isn't that the platform can't execute this in another thread.
The problem is that you can't write synchronous code anymore to do
synchronous code, this comes at a considerable cost of complexity to

>> Please note that efficiency in scheduling is always a function of how
>> well the scheduler matches the use-case in question. Thus it is important
>> to have a low level concept like coroutines upon which user-code can exist
>> that implements the scheduling. Examples of scheduling problems may include:
>>    - wait for user-input arrives (i.e. wait for input)
>>    - wait for network actcivity (download or upload) has finished (i.e.
>>    wait for xhr)
>>    - wait for a WebWorker has finished processing (i.e. wait for
>>    worker.postMessage)
>>    - wait for GPU activity (i.e. query results, texImage2D, bufferData,
>>    shader compile etc.)
>> These could be handled by simply returning a promise. Each thread has its
> own event loop which runs within that thread. So just not doing it
> synchronously would be the solution.
Promises are a very bad model to handle cooperative multitasking and
quasi-synchronous code (I believe I don't have to illustrate that).

>>    - evaluation of a dependency graph
>>    - evaluation finite state machines (without resorting to state
>>    transition methods)
>>    - etc.
>> I believe it would be much better to introduce true coroutines to JS,
>> than to try to introduce preemptive threading.
> Cooperative multithreading and coroutines can be done with async
> iterators. When those get standardized, it'll become easy to use
> cooperative multitasking. (I need to make well-known symbols identical
> cross-realm to make it work, though.)
> ```js
> export atomic async function *sync(file) {
>   while (true) {
>     if (await yield) await updateFile(file)
>   }
> }
> ```

More random line noise atop a broken model of co-routines, isn't going to
fix the lack of proper co-routines (in fact, I think this just exasperates
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list