[browser][MT] pool don't yield to event loop - #94600
Conversation
|
Tagging subscribers to 'arch-wasm': @lewing Issue Detailstesting ...
|
|
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/azp run runtime-wasm |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
I still need ability of all managed threads to receive messages via The scenario is "use HTTP client from any managed thread". I'm afraid Alternative to this would be |
|
If we can signal But we have that dream that UI thread would not be attached Mono thread ... just emscripten C. Could we pin |
I need to chase down what it actually is. I think it's a runtime/src/native/libs/System.Native/pal_threading.c Lines 31 to 38 in c643fed So at some point it does all boil down to posix. Although the "fun" thing about |
I wanted to simplify stuff, but this is not simpler. I guess we just abandon this idea of threads without JS event loop. |
do you mean also for This waitAsync stuff in Emscripten is pretty new. Are we on a version that includes it already? I thought we were still doing the postMessage-through-main-thread thing. emscripten-core/emscripten#18861 |
Yes, good point. Maybe it means that
I think we have version with
I'm not confident, in what i say now: This problem of dispatching resolve/reject back to managed thread is not same problem as posting to UI thread. Messages via SharedArrayBuffer and wasm blocking wait instruction, should make it possible to receive messages while waiting on another wait handle ?
Is that relying on "wasm async proposal" ? Because
I think when you signal the SharedArrayBuffer address then |
|
Does emscripten POSIX wait for signals check If so that would be great, but I can't find it. |
Yes,
I think only on the main thread. The code moved to |
No, I was wrong when I said "all", because I have not realize this. I guess we need to receive messages on thread pool and on JSWebWorker and on main/UI.
Thanks! The So, there is But I guess it's not better than external event loop? What do you think ? I also wonder if running arbitrary task from random futex could cause deadlock, if the something on pre-existing stack already held some lock. Perhaps they are re-entrant ? |
They might be re-entrant, but probably there will be problems with higher level code that isn't re-entrant
Probably both are fine, I wonder if webworkers that use an external event loop are better for battery on mobile. |

Context:
Because pthreads are re-used and user code could leave that web worker state in any shape.
And so I could switch to standard unix thread pool. It will make lot of things simpler.
On this PR I also removed managed part of external loop handling around
WebWorkerEventLoop.We will need it again later for dedicated
JSWebWorker, but I imagine different API.Essentially from C# perspective it will be just something like:
And worker/thread will be kept alive only until the promise of the callback is not resolved/rejected.
Details of how to do the keep alive plumbing TBD.