Enable Wasm Workers to call pthread APIs in hybrid mode#26757
Open
sbc100 wants to merge 2 commits intoemscripten-core:mainfrom
Open
Enable Wasm Workers to call pthread APIs in hybrid mode#26757sbc100 wants to merge 2 commits intoemscripten-core:mainfrom
sbc100 wants to merge 2 commits intoemscripten-core:mainfrom
Conversation
This change ends up adding ~200 bytes of data to each Wasm Worker (in hybrid mode only) to store the `struct pthread`. If the `pthread_key_create` API is used in the program then each worker needs an additional 512 bytes to store the PTHREAD_KEYS_MAX (128) pointers. This change also essentially reverts the musl patch from emscripten-core#26673 since it is no longer needed. See emscripten-core#26631
787860e to
71028cb
Compare
juj
reviewed
Apr 23, 2026
| as locks and condvars will now fail with ENOTSUP. (#26743) | ||
| - When building code with bith Wasm Workers and pthreads (hybrid mode) it is now | ||
| possible to call most of the core pthread APIs (e.g. lock, condvar, etc) from | ||
| a Wasm Worker. This mode increase the memroy used by each Wasm Worker by |
Collaborator
There was a problem hiding this comment.
(not critical, though noticed bith, increase->increases, memroy)
juj
approved these changes
Apr 23, 2026
Collaborator
juj
left a comment
There was a problem hiding this comment.
Nice - was the design doc something that AI was able to work through?
Collaborator
Author
I was hoping so.. but I actually took over and did this myself, since I have strong feeling about exactly how to do it. For the first design doc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change ends up adding ~200 bytes of data to each Wasm Worker (in
hybrid mode only) to store the
struct pthread.If the
pthread_key_createAPI is used in the program then each workerneeds an additional 512 bytes to store the PTHREAD_KEYS_MAX (128)
pointers.
This change also essentially reverts the musl patch from #26673 since it
is no longer needed.
See #26631