-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Avoid proxying print handlers back to the main thread #25208
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
base: main
Are you sure you want to change the base?
Conversation
Fantastic, thanks. I have been wondering about how to address the use case that motivated the original PR #17925 in the first place. Reverting that PR will fix the immediate sequential consistency problem, although will there be any problems with existing users..(?) Could they migrate code that was injecting Or if the code pattern for injecting a Module.print() function at startup from the main thread to apply to all Workers still seems worthwhile (even with the performance caveat it would bring), then it would seem that we'd have to figure out a way to proxy logging prints via the WebAssembly proxying queue over to the main thread. Would we need some kind of way (assert/warning) to help users discover that dynamically assigning Module.print() from the main thread will only apply to main thread, and not to pthreads? Or would that be something to expect to be implicitly given. |
For any kind of complex program that uses a real FS we already proxy stdout and stderr anyway so I think continuing to proxy these calls seems good/fine, but we should switch to using the normal in-memory proxying mechanism. The main problem with that is that its not supported with MINIMAL_RUNTIME, but maybe these |
I don't think its reasonable to land this change as is since it breaking anyone doing |
It seems that marking the Hopefully that will resolve the test flakiness, I've removed the flaky decorators to see if it helps. |
... ah, looking at https://circleci.com/gh/emscripten-core/emscripten/1017413, I guess that should only be done for
|
src/lib/libcore.js
Outdated
emscripten_err: (str) => err(UTF8ToString(str)), | ||
emscripten_errn__proxy: 'sync', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for native code calls to emscripten_err
but the err
and out
functions (which are not currently library functions) have many calls sites and those should really be the ones that get proxied.
I'm looking into moving err
and out
to library code, but its a little complex since they used very early on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped this commit. It also failed for test_pthread_cancel
and test_pthread_busy_wait_atexit
, which depend on emscripten_out()
not being proxied back to the main thread.
emscripten/test/pthread/test_pthread_busy_wait_atexit.cpp
Lines 15 to 17 in a4d0dbc
// Avoid using printf here since stdio is proxied back to the | |
// main thread which is busy looping | |
emscripten_out("in thread"); |
Looking at #17688 (comment), I realized why I designed Line 270 in 873dc2e
Line 614 in 873dc2e
Lines 2672 to 2685 in 873dc2e
But WasmFS uses
which bypasses the proxying system entirely. Commit 96da2f2 revises the test to make its purpose clearer. |
This partially reverts commit 97b352e. Resolves: emscripten-core#19683.
This is an automatic change generated by tools/maint/rebaseline_tests.py. The following (2) test expectation files were updated by running the tests with `--rebaseline`: ``` code_size/test_codesize_minimal_pthreads.json: 27251 => 27205 [-46 bytes / -0.17%] code_size/test_codesize_minimal_pthreads_memgrowth.json: 27679 => 27633 [-46 bytes / -0.17%] Average change: -0.17% (-0.17% - -0.17%) ```
96da2f2
to
3d7f74a
Compare
Marking this as a draft since I'm not sure of the best way to proceed. |
My proposal is as follows:
|
This partially reverts commit 97b352e.
Resolves: #19683.