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

Proposal to improve CPU multiprocessing performance #103

Open
kuffmode opened this issue Dec 4, 2023 · 3 comments
Open

Proposal to improve CPU multiprocessing performance #103

kuffmode opened this issue Dec 4, 2023 · 3 comments

Comments

@kuffmode
Copy link

kuffmode commented Dec 4, 2023

Hi all,
I realized the multi-threading performance is good, but probably can be even better for local machines. I noticed that my CPU cores are not engaged fully so a simple solution that I usually use and found to be helpful here is joblib parallel processing.
At its core, all it needs is something like this:

results = Parallel(n_jobs=-1)(
               delayed(network_analysis.analyse_single_target)(
               settings=settings, data=data,target=node) for node in range(n_nodes))

But of course, it can be more user-friendly if this is wrapped in a function, something like an interface where we just tell how many jobs, what to do, some kwargs for the function and potentially some kwargs for the parallel processing backend. This way, each core is occupied with one single_target analysis, so as in my case, it can help a lot with the performance.
About joblib, we used it in our own library and compared to some fancier things like dask and ray it actually is a lot better and less pain! So far, it never broke anything for us.

@mwibral
Copy link
Collaborator

mwibral commented Dec 4, 2023 via email

@pwollstadt
Copy link
Owner

Hi Kayson,

Thanks for sharing this, looks like a nice way to make the parallelization over targets more convenient. My proposal would be to add this as a demo script, so people can build on it. If you like, just open a pull request or send me your script and I will test/adapt it and include it.

Regarding Michael's comment, I just merged @daehrlich's implementation for MPI-supported CMI estimation into master (release v1.5). Maybe this is helpful as well.

Best,
Patricia

@kuffmode
Copy link
Author

Awesome, I will do it in early 2024 then. I think the advantage of joblib is that it basically doesn't need anything but the function so it will be very straight forward for people to use it. I'm not sure if it's any better compared to MPI but I think it's a good simple trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants