perf: build external cmake deps in parallel #21

Merged
jorijnvdgraaf merged 1 commit from claude/issue-20 into master 2026-06-02 01:23:40 +02:00
Member

Summary

External cmake dependencies (DPP, msquic, glslang, …) were built single-threaded: BuildCMake invoked cmake --build <dir> with no --parallel, so the default Unix Makefiles generator compiled one translation unit at a time, leaving all but one core idle. On a multi-core host this made every cold dep build ~N× slower than necessary, and long dep builds (DPP is ~178 .cpp at -O3) looked like hangs to anything watching the build.

Fix

Pass an explicit --parallel N to cmake --build in BuildCMake, using std::thread::hardware_concurrency(). An explicit count is used deliberately — a bare --parallel maps to an unbounded make -j (fork bomb) on the Makefiles generator.

unsigned jobs = std::max(1u, std::thread::hardware_concurrency());
std::string cmd = std::format("cmake --build {} --parallel {}",
    ShellQuote(fs::absolute(cmakeBuildDir).string()), jobs);

Testing

  • crafter-build builds clean (rebuilt the glslang external dep through the modified path).
  • crafter-build test — all 12 tests pass.

Resolves #20

## Summary External cmake dependencies (DPP, msquic, glslang, …) were built **single-threaded**: `BuildCMake` invoked `cmake --build <dir>` with no `--parallel`, so the default Unix Makefiles generator compiled one translation unit at a time, leaving all but one core idle. On a multi-core host this made every cold dep build ~N× slower than necessary, and long dep builds (DPP is ~178 .cpp at -O3) looked like hangs to anything watching the build. ## Fix Pass an explicit `--parallel N` to `cmake --build` in `BuildCMake`, using `std::thread::hardware_concurrency()`. An explicit count is used deliberately — a bare `--parallel` maps to an unbounded `make -j` (fork bomb) on the Makefiles generator. ```cpp unsigned jobs = std::max(1u, std::thread::hardware_concurrency()); std::string cmd = std::format("cmake --build {} --parallel {}", ShellQuote(fs::absolute(cmakeBuildDir).string()), jobs); ``` ## Testing - `crafter-build` builds clean (rebuilt the glslang external dep through the modified path). - `crafter-build test` — all 12 tests pass. Resolves #20
perf: build external cmake deps in parallel
All checks were successful
CI / build-test-release (pull_request) Successful in 9m0s
06cccc3921
cmake --build was invoked with no --parallel, so the default Unix
Makefiles generator compiled external deps (DPP, msquic, glslang, …)
one translation unit at a time, leaving all but one core idle.

Pass an explicit --parallel N using hardware_concurrency() so dep
builds use the available cores. An explicit count (not a bare
--parallel) avoids an unbounded make -j fork bomb on the Makefiles
generator.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jorijnvdgraaf deleted branch claude/issue-20 2026-06-02 01:23:40 +02:00
Sign in to join this conversation.
No description provided.