Build native extensions in parallel (multi-core) - #100
Open
JustinMDotNet wants to merge 2 commits into
Open
Conversation
Add parallel-build flags to the native CMake/make invocations that were building single-threaded, matching the pattern already used by the R, ONNX and EKM extensions: - Java/Python (windows .cmd, linux .sh): cmake --build ... --parallel - GoogleTest windows: mingw32-make -j all - GoogleTest linux: cmake --build ... --parallel --parallel defaults to the available core count; no behavioral change to outputs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: acb7e6f8-cf0c-4635-92e7-df8559d2d677
Extend the --parallel build flag to the sibling native CMake builds that were still compiling single-threaded: - Python extension test (windows .cmd, linux .sh) - R extension + R extension test (linux .sh) - dotnet-core-CSharp extension test native cmake step (windows .cmd) Completes the parallelization so the extension test builds match their main-extension counterparts. No behavioral change to outputs or targets. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR speeds up CI by enabling parallel compilation for native extension builds (CMake builds and MinGW make) so native code uses available CPU cores instead of building single-threaded.
Changes:
- Add
--parallelto allcmake --build ... --target install/INSTALLinvocations across Java, Python, R, GoogleTest, and dotnet-core-CSharp test builds. - Enable parallel MinGW builds for Windows GoogleTest via
mingw32-make -j all.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/googletest/build/windows/build-googletest.cmd | Build GoogleTest with parallel MinGW make (-j). |
| test/googletest/build/linux/build-googletest.sh | Build/install GoogleTest with cmake --build --parallel. |
| language-extensions/R/test/build/linux/build-RExtension-test.sh | Build/install R extension tests with cmake --build --parallel. |
| language-extensions/R/build/linux/build-RExtension.sh | Build/install R extension with cmake --build --parallel. |
| language-extensions/python/test/build/windows/build-pythonextension-test.cmd | Build/install Python extension tests with cmake --build --parallel. |
| language-extensions/python/test/build/linux/build-pythonextension-test.sh | Build/install Python extension tests with cmake --build --parallel. |
| language-extensions/python/build/windows/build-python-extension.cmd | Build/install Python extension with cmake --build --parallel. |
| language-extensions/python/build/linux/build-python-extension.sh | Build/install Python extension with cmake --build --parallel. |
| language-extensions/java/build/windows/build-java-extension.cmd | Build/install Java extension with cmake --build --parallel. |
| language-extensions/java/build/linux/build-java-extension.sh | Build/install Java extension with cmake --build --parallel. |
| language-extensions/dotnet-core-CSharp/test/build/windows/build-dotnet-core-CSharp-extension-test.cmd | Build/install native dotnet-core-CSharp test components with cmake --build --parallel. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Speed up native extension builds by compiling with all available CPU cores instead of single-threaded.
What
Add a parallel-build flag to every native CMake/make invocation that was building single-threaded:
Main extension builds
.cmd, Linux.sh):cmake --build ... --target install --parallelmingw32-make all->mingw32-make -j allcmake --build ... --target install --parallelTest / R builds (so the test builds match their main-extension counterparts)
.cmd, Linux.sh): add--parallel.sh): add--parallel.cmd): add--parallelThe Windows R / GoogleTest builds use
mingw32-make -j all; the manageddotnet buildsteps already compile multi-core via/m.Why
These were the native builds still compiling on a single core.
--paralleldefaults to the available core count; there is no change to build outputs or targets. After this change nocmake --build ... --target installinvocation is left single-threaded.Performance
The flag parallelizes the C++ compile phase, which scales with cores up to the number of translation units per extension (Java 16, R 16, Python 13, CSharp native shim 3). The gain is Amdahl-bounded: the serial cmake configure and shared-lib link within each step, and the separate package-restore step, do not parallelize. Realistic expectation is roughly a 2-4x reduction in each native compile step on a typical 4-8 core machine (the 3-TU CSharp shim benefits least; Java/R/Python most) rather than a whole-build speedup.
No hard before/after numbers are included: this repo has no committed CI that builds these scripts (the only PR checks are GitHub-managed CodeQL default setup and license/cla, and CodeQL's c-cpp analysis uses its own autobuild, not these scripts). Timings should be captured from whatever process runs these scripts (release/official builds and local developer builds) by comparing per-step wall-clock before vs. after.
Risk
Low. Eleven one-line changes; error handling untouched.