-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Multithreading worker issue #21959
Comments
Emscripten will only only create new workers when there are no unused workers in the pool. Workers are returned to the "unused" pool each time a C++ thread exits. If you are seeing the pool continue to grow then that means that your C++ threads probably are not exiting correctly and emscripten things that they are still running. Perhaps there is some issue with the way C++ threads are built on top of pthreads? Perhaps libc++ is pooling pthreads at some level? I wonder if you could share a simple example of a program that continues to grow the worker pool even though the number of active C++ threads is not going up? |
thank you for the response @sbc100 ! I found that even with the following code, at some point, will try to create workers:
I can see the output printed, but after some iterations, it fails because of the same error. I tried also not allowing the memory to grow but it doesn't change the result. I am sorry if this is a noob error, I am new to Emscripten, so please bear with me. EDIT: EDIT2: if you need more info don't hesitate to ask! |
You can see this explanation, and I believe you will get a good solution. |
V.3.1.39
I am compiling and running a program which use 3rd party C++ library.
the 3rd party library uses multithreading.
theoretically uses the number of processors as maximum number of threads, (that number is an input I give using
std::thread::hardware_concurrency();
)but when this program is compiled with Emscripten and run in the browser, seems that it creates/uses a different web worker for each iteration, instead of "reusing" already created threads/workers, as it should.
this is where multithreading starts
init_future_ = std::async(std::launch::async, [this]() { process_concurrently(); });
:this is processConcurrently function
I think this could be somehow related to https://github.com/emscripten-core/emscripten/issues/8201
ps. I tried setting THREAD_POOL_SIZE to 490 (just as a test) and the iteration goes for more or less 490 objects.
this is an example on how I use the iterator
errors:
any tip will be much appreciated!!
The text was updated successfully, but these errors were encountered: