Skip to content

Commit ed8b585

Browse files
committed
Limit riscv64 wheel build parallelism
Cap the CMake/Ninja build jobs to two when cibuildwheel is targeting riscv64. The riscv64 job runs under QEMU on GitHub-hosted runners; unconstrained Ninja parallelism can fan out across all host cores and make the emulated build look stuck or run much slower than a small, steady job count.\n\nThis keeps RVV enabled and leaves the default unconstrained parallel build behavior unchanged for native Linux, macOS, and Windows wheels. EMBEDDINGS_CPP_BUILD_JOBS remains available as an explicit override for maintainers and self-hosted runners.
1 parent d1d6686 commit ed8b585

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

setup.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ def _platform_cmake_args() -> list[str]:
4141
]
4242

4343

44+
def _cmake_build_jobs() -> str | None:
45+
jobs = os.environ.get("EMBEDDINGS_CPP_BUILD_JOBS")
46+
if jobs is not None:
47+
jobs = jobs.strip()
48+
return jobs or None
49+
if _is_riscv64_target():
50+
# QEMU user-mode builds can get slower or appear stuck when Ninja fans
51+
# out across all hosted-runner cores. Keep RVV enabled, but use a small
52+
# parallelism cap for the emulated wheel build.
53+
return "2"
54+
return None
55+
56+
4457
# A CMakeExtension needs a sourcedir instead of a file list.
4558
# The name must be the _single_ output extension from the CMake build.
4659
# If you need multiple extensions, see scikit-build.
@@ -145,8 +158,10 @@ def build_extension(self, ext: CMakeExtension) -> None:
145158
# # CMake 3.12+ only.
146159
# build_args += [f"-j{self.parallel}"]
147160

148-
# Compile in parallel by default
149-
build_args += [f"-j"]
161+
# Compile in parallel by default. RISC-V cibuildwheel uses QEMU, where
162+
# unconstrained parallelism can be counterproductive.
163+
build_jobs = _cmake_build_jobs()
164+
build_args += [f"-j{build_jobs}" if build_jobs else "-j"]
150165

151166
build_temp = os.path.abspath(os.path.join(self.build_temp, ext.name))
152167
os.makedirs(build_temp, exist_ok=True)

0 commit comments

Comments
 (0)