Skip to content
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

Always use EM_PYTHON_MULTIPROCESSING after win32 bugfix #17881

Closed
wants to merge 1 commit into from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Sep 19, 2022

This removes the need for the aternative implementation and mirrors the upstream bugfix in python 3.8.0.

Fixes: #13785

@sbc100 sbc100 force-pushed the windows_python_max_multiprocessing branch 2 times, most recently from d816f6b to 5a47a81 Compare September 19, 2022 07:32
@sbc100 sbc100 changed the title Fix for pythons multiprocessing issue on win32 Fix for python multiprocessing issue on win32 Sep 19, 2022
@sbc100 sbc100 requested a review from juj September 19, 2022 07:33
@sbc100 sbc100 force-pushed the windows_python_max_multiprocessing branch from 5a47a81 to 48d7a64 Compare September 19, 2022 07:40
@sbc100 sbc100 requested a review from kripken September 19, 2022 07:41
sbc100 added a commit that referenced this pull request Sep 19, 2022
This codepath is not normally used since once currently needs to
opt into using via EM_PYTHON_MULTIPROCESSING=1.

However, I'm hoping to remove that limitation in #17881.  This
cleaanup/fix should land before #17881 does.

The primary change here is to switch from `subprocessrun.Popen` to
`subprocess.run` which supports the `check=True` argument.  As well
as avoiding the need for the call to `communicate()`
sbc100 added a commit that referenced this pull request Sep 19, 2022
This codepath is not normally used since once currently needs to
opt into using via EM_PYTHON_MULTIPROCESSING=1.

However, I'm hoping to remove that limitation in #17881.  This
cleaanup/fix should land before #17881 does.

The primary change here is to switch from `subprocessrun.Popen` to
`subprocess.run` which supports the `check=True` argument.  As well
as avoiding the need for the call to `communicate()`
sbc100 added a commit that referenced this pull request Sep 19, 2022
This codepath is not normally used since once currently needs to
opt into using via EM_PYTHON_MULTIPROCESSING=1.

However, I'm hoping to remove that limitation in #17881.  This
cleaanup/fix should land before #17881 does.

The primary change here is to switch from `subprocessrun.Popen` to
`subprocess.run` which supports the `check=True` argument.  As well
as avoiding the need for the call to `communicate()`
sbc100 added a commit that referenced this pull request Sep 19, 2022
This codepath is not normally used since once currently needs to
opt into using via EM_PYTHON_MULTIPROCESSING=1.

However, I'm hoping to remove that limitation in #17881.  This
cleaanup/fix should land before #17881 does.

The primary change here is to switch from `subprocessrun.Popen` to
`subprocess.run` which supports the `check=True` argument.  As well
as avoiding the need for the call to `communicate()`
tools/shared.py Outdated
If True, an array of stdouts is returned, for each subprocess.
"""
# On windows, there is limit on the total number of tasks which is
# enforced bu multiprocessing, but only on newer version of python:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# enforced bu multiprocessing, but only on newer version of python:
# enforced by multiprocessing, but only on newer version of python:

if not multiprocessing_pool:
max_workers = get_num_cores()
if WINDOWS:
max_workers = min(max_workers, 61)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the fix just this, to limit to 61? So this was only ever a problem for machines with >61 cores..?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is my understanding. see the python bug for details. I guess for emcc users it would also effect users who set EMCC_CORES > 61.. since you can create more threads that cores if you want to using that variable.b

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm a little surprised then that we got but reports about this. How many people have that many cores..?

If we can confirm this works, or we can ask someone that has encountered the bug, that would make me more confident here. But, maybe I'm being overly cautious, if this is in upstream Python it's probably fine..?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it makes sense it you look at the original bug report : "On the other Windows system, this issue does not seem to ever occur. The affected system is a 64-thread Threadripper 2990WX, and the numbers are quite close to 64, so I wonder if that has a meaning here. The unaffected system is a 16-thread system."

Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, makes sense. Sounds like this really is a 61+ cores issue then...

@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.

3.1.22 (in development)
-----------------------
- Remove EM_PYTHON_MULTIPROCESSING=1 environment variable which is no longer
required. (#17881)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this needs to move)

@sbc100 sbc100 changed the title Fix for python multiprocessing issue on win32 Always use EM_PYTHON_MULTIPROCESSING after win32 bugfix Sep 20, 2022
@sbc100
Copy link
Collaborator Author

sbc100 commented Sep 20, 2022

Actually I decided it would be safer to do this incrementally and first land #17892

@sbc100 sbc100 force-pushed the windows_python_max_multiprocessing branch 2 times, most recently from 8a28283 to 9022814 Compare September 20, 2022 08:01
@sbc100 sbc100 force-pushed the windows_python_max_multiprocessing branch from 9022814 to 7c20ffe Compare September 20, 2022 08:48
This removes the need for the alternative implementation now that
the primary windows issue has been resolved.
@sbc100 sbc100 force-pushed the windows_python_max_multiprocessing branch from 7c20ffe to 35cad0d Compare September 20, 2022 08:49
@sbc100
Copy link
Collaborator Author

sbc100 commented Sep 20, 2022

Closing this change for now until we can measure and decide if we want to go with EM_PYTHON_MULTIPROCESSING by default, or not.

@sbc100 sbc100 closed this Sep 20, 2022
@sbc100 sbc100 deleted the windows_python_max_multiprocessing branch September 20, 2022 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python multiprocessing regression on Windows after updating to Python 3.9.2
2 participants