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

Install: Build the extensions in parallel if the options has not been set #6774

Merged
merged 4 commits into from Mar 16, 2020

Conversation

Lauszus
Copy link
Contributor

@Lauszus Lauszus commented Mar 13, 2020

This roughly halved my compilation times when using 8 threads instead of just 1.

@matham
Copy link
Member

matham commented Mar 13, 2020

Definitely a good idea, but I'm worried about making this decision for everyone. E.g. for make you can always specify how many threads.

I think we first should look at what other projects do (e.g. numpy), if they make it optional and what the default is!?

@Lauszus
Copy link
Contributor Author

Lauszus commented Mar 14, 2020

Numpy has parallel builds enabled by default, but limits it to maximum of 8 cores: https://github.com/numpy/numpy/blob/8087e1de04d011f7ce66bf80dbef4a0599b14f7a/numpy/distutils/misc_util.py#L78-L112.

This is where the actual code is compiled: https://github.com/numpy/numpy/blob/36a2bf0ce8b072d557af5b58a9003a6bc72caaef/numpy/distutils/ccompiler.py#L352-L361.

What I have done is similar however I do not limit the number of cores, but I can do that if you want to?

FYI here's the relevant code in distutils that checks the parallel attribute: https://github.com/python/cpython/blob/master/Lib/distutils/command/build_ext.py#L443-L469, as you can see it will get the number of cores of the CPU and use all of them, but if we set parallel to an integer, then that number of cores will be used.

@matham
Copy link
Member

matham commented Mar 14, 2020

Ok, makes sense. I'd say that by default we should also limit the number of parallel jobs to like 4 for similar reasons as numpy. Numpy is a much larger project with more code so it makes sense for them to benefit of using upto 8 cores.

For us, there probably isn't much benefit above like 3 or 4 cores so lets limit it to the min of the number of cores and like 4.

@Lauszus
Copy link
Contributor Author

Lauszus commented Mar 14, 2020

@matham fixed in: 63a825a.

@Lauszus Lauszus force-pushed the parallel branch 2 times, most recently from 8625896 to 63a825a Compare March 15, 2020 09:15
@matham matham merged commit e6fccbd into kivy:master Mar 16, 2020
@matham matham added this to the 2.0.0 milestone Oct 28, 2020
@matham matham changed the title Build the extensions in parallel if the options has not been set Install: Build the extensions in parallel if the options has not been set Dec 9, 2020
@matham matham added the Component: distribution Wheels, apt PPA, conda, end user install issues label Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: distribution Wheels, apt PPA, conda, end user install issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants