Skip to content

CI Enable parallel build on CI via an env variable #18826

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

Merged
merged 8 commits into from
Nov 13, 2020

Conversation

ogrisel
Copy link
Member

@ogrisel ogrisel commented Nov 12, 2020

On the wheel build, it's not easy to do the usual python setup.py build_ext -j 3 because cibuildwheel does not allow to customize the build command and it uses pip wheel that does the build in an isolated environment (which is otherwise nice to make sure we respect the pinned versions of the build dependencies from pyproject.toml).

Furthermore, I expect that on some future ARM builds we will get many more cores than on x86 hosts but we need to be able to automatically defect the number of usable cores for optimal performance and avoiding over-subscription caused by docker CPU quotas for instance.

So here is a tentative update of our custom build_ext command to automatically use as many core as possible by setting SKLEARN_BUILD_PARALLEL=auto to use 3 parallel tasks by setting SKLEARN_BUILD_PARALLEL=3 in the various CI environments.

Edit: use a static level of parallel build task to allow for overlapping IO and CPU bound tasks.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

This makes loky an optional build time dependency, which makes it a little strange to put into the pyproject.toml as "required".

But I think this is very nice to have and would be worth putting in advanced_installation.rst.

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
@ogrisel ogrisel changed the title Enable auto parallel build on CI [cd build] Enable auto parallel build on CI Nov 13, 2020
@ogrisel
Copy link
Member Author

ogrisel commented Nov 13, 2020

Actually the azure builds now last 30 min instead of 25 min on master. I suspect that this is because it's worth using -j 3 instead of -j 2 (auto detected number of usable cores) because building the compiled extensions is a mix of IO bound operations (reading source files and writing the generating binary files) and CPU bound operations (actually compiling).

So maybe I will remove the auto mode and just allow to pass an integer as an environment variable. This will be simpler to maintain.

@jeremiedbb
Copy link
Member

On the wheel build, it's not easy to do the usual python setup.py build_ext -j 3 because.

You did not finish your sentence :) What's the issue with this ?

@ogrisel
Copy link
Member Author

ogrisel commented Nov 13, 2020

You did not finish your sentence :) What's the issue with this ?

Ooops. I edited the description.

@ogrisel ogrisel changed the title Enable auto parallel build on CI Enable parallel build on CI via an en variable Nov 13, 2020
@ogrisel
Copy link
Member Author

ogrisel commented Nov 13, 2020

Setting parallelism to 3 instead of 2 on a 2 core machine is not necessarily that beneficial in retrospect. But it does not seem to hurt either.

Anyways, I don't plan to tweak this PR any further.

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasjpfan thomasjpfan changed the title Enable parallel build on CI via an en variable CI Enable parallel build on CI via an env variable Nov 13, 2020
@thomasjpfan thomasjpfan merged commit 7149558 into scikit-learn:master Nov 13, 2020
@ogrisel ogrisel deleted the auto-parallel-build branch November 13, 2020 15:49
@ogrisel
Copy link
Member Author

ogrisel commented Nov 13, 2020

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants