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

Parallel builds support #392

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Parallel builds support #392

wants to merge 6 commits into from

Conversation

indygreg
Copy link
Owner

@indygreg indygreg commented Nov 16, 2024

This is an attempt to support building multiple Python versions at the same time. The impetus for this is reducing the amount of work that CI does by amortizing the costs for building common dependencies.

The first 3 commits should be relatively safe to merge. 4 and 5 need a bit of testing.

Open issues:

  • Race condition downloading pip/setuptools when building in parallel.
  • Handle 3.13 and freethreaded builds better in CI (still room for job consolidation).
  • macOS builds broken due to old version of GNU Make.

@zanieb
Copy link
Collaborator

zanieb commented Nov 16, 2024

Cool thanks for looking into this!

@indygreg indygreg force-pushed the gps/parallel-builds branch from 74a9dc0 to 76cdbd9 Compare November 16, 2024 23:56
@indygreg
Copy link
Owner Author

The 3.13 CI jobs aren't yet fully optimized and already this PR drops Linux builder total time from ~64h to ~43h, or ~67% of baseline. Not bad.

I'm about to enable support for parallel CPython builds. This
function was currently not safe if called in parallel. This was
causing setuptools / pip downloads to race writing to the same file
and failing builds.
This is less ergonomic (oh Make). But it will make it easier to
build multiple Python versions at the same time in a future commit.
Previously we generated the same Makefile for every Python version.
We can simplify things by only writing 1 Makefile per target
configuration.
This refactor allows targets for each major Python version to be
defined simultaneously. This opens the door to a single `make`
invocation building multiple versions in parallel.
`build-main.py` now passes in space delimited Python versions to
build, which the Makefile can happily translate to appropriate make
targets for us.

We added support for `--python all` to allow building all supported
Python versions.
Our build system supports this now. So update CI to make use of
the feature.

On Linux, 3.13 freethreaded builds are still their own CI job. We
may need to tweak `build-main.py` to allow intelligently selecting
freethreaded compatible versions. We could potentially also allow
building freethreaded in parallel with non-freethreaded. This can be
done as a followup.
@indygreg indygreg force-pushed the gps/parallel-builds branch from 76cdbd9 to d17e9dc Compare December 7, 2024 19:02
@indygreg
Copy link
Owner Author

indygreg commented Dec 7, 2024

The macOS builds should be fixed. Issue turned out to be a compatibility issue changed in GNU Make 3.82 (macOS ships 3.81). Specifically commit 81f3e4babd128f6740d05b371122762924522fb6 (because I bisected it).

define syntax in GNU Make 3.82 supports an optional =. e.g. define foo =. 3.81 doesn't. I was using the = and it broke 3.81.

@indygreg
Copy link
Owner Author

indygreg commented Dec 8, 2024

Ok. CI came back clean.

macOS CI total time drops from 10:27 to 8:49. 529/627=84% of baseline. Not the percentage savings as Linux. And 3.13 is still on the table for optimization. But still a nice win.

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.

2 participants