-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node Worker pthreads pool reuse #9763
Comments
Or just do what native thread libraries do, i.e. actually create a new thread. I'll bet it's a lot cheaper in Node than it is on the web. |
I agree. Lets just not do the pool thing on node. Creating a pool of threads in userspace is possible if people what to do that (which is also common in the non-web world). |
The problem is that creating the pool is a workaround for the issue of expecting a thread to immediately be usable. That is, creating a thread is an async operation, so the main thread needs to return to the event loop and wait. |
But is that true with node as well? Don't we have synchronous primitives under node? |
It seems to still be true in Node.js, yes, creating a Worker doesn't make it immediately available, the event loop must be returned to. I don't see an API to synchronously create and run a Worker. But maybe I missed something, cc @addaleax |
There’s nothing built-in, but if you want something like this, you could pass an
You can still throw an exception if that’s what you want. If you want it to not bring down the Worker entirely, you can attach a |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
Resolves (partially): emscripten-core#9763.
Resolves (partially): emscripten-core#9763.
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
The corresponding TODO-item is no longer relevant after PR emscripten-core#18305 has landed. Resolves: emscripten-core#9763.
#9745 supports Node Workers and the pthread pool works properly, but the pool elements are not reused. For example,
https://github.com/emscripten-core/emscripten/blob/incoming/tests/pthread/test_pthread_create.cpp
creates many many threads and destroys them (so at every point in time only a small amount exist). This hangs on node as after exhausting the pool, we have no more workers to use.
I think the issue is that
pthread_exit
in workers actually exits the entire Worker in node. We call the node process API to do that, as it's better than throwing an exception - which on the Web halts the worker but leaves the application alone, but in Node brings down the whole thing. So I guess we need to find a way to do what we do on the Web, in Node.The text was updated successfully, but these errors were encountered: