-
Notifications
You must be signed in to change notification settings - Fork 3.4k
parallel_testsuite.py: Use multiprocessing pool #18214
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
Conversation
|
Does this part get tested on Windows on CircleCI? Python has very exotic rules on Windows for what it can pickle and what it cannot, since Windows does not support fork(). |
|
Just tried this locally on Windows and it seems to cause some new issues instead. Seeing a lot of Looks like parallel processes are now somehow stepping on each others toes? |
|
Ah right, I now see that
@juj I suppose that answers your question :) |
00049fc to
9ce2a65
Compare
|
I've very excited about this change.. the inability to interrupt the parallel running without spamming stderr has annoyed me for so many years now. |
|
Windows now passes! |
|
I don't see any difference on Windows, and actually the VSCode issue I described in #18213 seems to apply in regular terminal as well, it's just sporadic and doesn't always reproduce :( Given all those There should be some way to tell it it's not interactive (pass empty stdin at Python level if it's not doing that yet?)... |
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.
Nice simplification - seems worthwhile even if doesn't fully resolve the issue.
Probably worth manual testing to make sure this does what is expected, both in terms of the issue and also in not silently missing test failures. On Linux both look good to me locally.
For a quick check, I tried just doing |
|
yes, this most certainly helps address the issue on linux. I still sometimes see traceback, it its not O(N) in the number of subprocesses which is what was killing me before. |
That is an unfortunate behavior of Windows batch files, I don't think there is a way to get around that :/ But awesome in general to see that the runner shouldn't hang anymore when aborting tests! |
As mentioned above, it is possible to bypass it if it knows it's running in non-interactive mode - aka stdin is not propagated from parent. It will still print "Terminate batch job (Y/N)" but it won't actually wait for user to type Y/N and instead exit immediately, which is what we want here. |
|
Sadly it might be hard to know know a-prior if the compiler needs to read from stdin. |
But, in the tests, we always know the test subprocesses don't need to read from stdin? Is there no way to configure the |
True, the python pool of processes don't need to read from stdin. But those are not I think the e.g.: Lines 10710 to 10717 in ce4c405
|
Indeed.
Right, but those tests already pipe stdin from another input, so if we set a global stdin for Python subprocesses to empty stream, they won't care either way. That is, what I'm suggesting is: Python Pool should set stdin to empty stream. Then, all subprocesses of Pool, whether tests or emcc.bat, will recursively inherit this empty stdin by default, but they can still override it to a custom one so these tests that have |
If that works, and fixes your issue, that sounds like a great solution! |
Indeed... I just don't know that much about Python multiprocessing to know how to configure stdin in said way without digging in 😅 |
It should be fine for all parallel tests to using the same TEMP_DIR. The only limitation is on tests that use the canonical test directory (e.g. EMCC_DEBUG). It looks like we used to use a unique temp directory per process (See emscripten-core#6150). However that we changes to one-directory-per-test in emscripten-core#18214, although I don't remember why. With this change we don't create a new temp directory except for tests that are marked as `uses_canonical_tmp`
It should be fine for all parallel tests to using the same TEMP_DIR. The only limitation is on tests that use the canonical test directory (e.g. EMCC_DEBUG). It looks like we used to use a unique temp directory per process (See emscripten-core#6150). However that we changes to one-directory-per-test in emscripten-core#18214, although I don't remember why. With this change we don't create a new temp directory except for tests that are marked as `uses_canonical_tmp`
Use the
Poolseems to address the longstanding issue we have had with interrupting the test suite usingcrtl-C.Its also a lot less code.
Also, limit the pools size to the number of tests being run. No need to start 56 processes if we are just running 2 tests.
I measured the performance of the running the core2 test suite both before and after this change and it was not effected.
See: #18213
Supersedes: #11299