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

[server] Use the multiprocess library on every platform #4095

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vodorok
Copy link
Collaborator

@vodorok vodorok commented Nov 22, 2023

Multiprocessing is broken on osx, (probably because of the fork -> spawn change). This patch intends to correct it by using the newly added multiprocess library.

@vodorok vodorok added CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands bugfix 🔨 platform-macOS 🍎 labels Nov 22, 2023
@vodorok vodorok added this to the release 6.23.0 milestone Nov 22, 2023
@vodorok vodorok self-assigned this Nov 22, 2023
@vodorok
Copy link
Collaborator Author

vodorok commented Nov 27, 2023

Did some tests on windows, and I could use the multiprocess lib without issues. I will remove the branching completely.

@vodorok vodorok force-pushed the osx_multiproc_store branch 3 times, most recently from 8d12a44 to 12888c1 Compare November 27, 2023 15:05
@whisperity
Copy link
Member

Did some tests on windows, and I could use the multiprocess lib without issues. I will remove the branching completely.

@vodorok Let's just make sure these claims hold true for sufficiently old Python versions such as 3.9. Other than that, I think this is good to go.

Copy link
Member

@whisperity whisperity left a comment

Choose a reason for hiding this comment

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

(Barring the stylistic changes, LGTM! @vodorok)

@whisperity whisperity changed the title Fix multiprocess store on OSX [osx][requirements] Fix multiprocess store on OSX Dec 7, 2023
Even though we swapped a higher level interface to a lower level
(ProcessPoolExecutor -> Multiprocess.Pool), it is worth it because on
all 3 systems the multiprocess handling is the same.
Multiprocessing is broken on osx, (probably because of the fork -> spawn
change.) This patch intends to correct it by using the newly added
multiprocess library.
On Windows only single threaded execution is supported. With the
introduction of the multiprocess lib multiprocessing is now available.
Copy link
Member

@whisperity whisperity left a comment

Choose a reason for hiding this comment

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

LGTM. But please re-check everything on real machines as well. Does the WINDOWS library version appropriately ignore the pool.map which was previously not passed? Or with this new library, everything works fine in a pool?

@vodorok
Copy link
Collaborator Author

vodorok commented Dec 7, 2023

Do not merge yet
Edit: more explanation: The web tests got really flaky after non functIon change modification (changed import order).
I am not completely sure why is this happens, but there can be cases where the zip file disappears during the store process.

@vodorok vodorok marked this pull request as draft December 7, 2023 15:59
@whisperity
Copy link
Member

  1. Create a new file codechecker_common/multiprocessing.py which deals with the platform-specific branching.
if sys.platform in ["darwin", "win32"]:
  from multiprocessing import Pool as MultiProcessPool
elif sys.platform == ":
  from concurrent.futures import ProcessPoolExecutor as MultiProcessPool
  1. In the usage places, import this new module and use the aliased name
from codechecker_common.multiprocessing import MultiProcessPool

# ...

with MultiProcessPool(...) as pool:
  ...(..., pool.map)

@vodorok
Copy link
Collaborator Author

vodorok commented Dec 7, 2023

Made a different implementation where the linux platform still uses the ProcessPoolExecutor class.
See #4118
Will debug this after the release.

@vodorok vodorok modified the milestones: release 6.23.0, release 6.24.0 Dec 8, 2023
@vodorok vodorok changed the title [osx][requirements] Fix multiprocess store on OSX [osx][requirements] switch to multiprocess lib on every platform Dec 8, 2023
@vodorok vodorok changed the title [osx][requirements] switch to multiprocess lib on every platform [osx][requirements] make store command use the multiprocess module on every platform Dec 8, 2023
@vodorok vodorok changed the title [osx][requirements] make store command use the multiprocess module on every platform [server] make store command use the multiprocess module on every platform Dec 8, 2023
@whisperity whisperity changed the title [server] make store command use the multiprocess module on every platform [server] Use the multiprocess library on every platform Dec 8, 2023
@whisperity whisperity added dependencies 📦 Pull requests that update a dependency file python Pull requests that update Python code (used by DependaBot) labels Mar 27, 2024
@bruntib bruntib modified the milestones: release 6.24.0, release 6.25.0 Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix 🔨 CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands dependencies 📦 Pull requests that update a dependency file python Pull requests that update Python code (used by DependaBot) server 🖥️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants