External cmake deps build single-threaded: cmake --build lacks --parallel #20
Labels
No labels
bug
claude:done
claude:failed
claude:in-progress
claude:ready
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Build#20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
External cmake dependencies (DPP, msquic, glslang, …) are built single-threaded:
BuildCMakeinvokescmake --build <dir>with no--parallel/-j, andConfigureCMakeuses the default generator (Unix Makefiles on Linux), which is serial unless told otherwise. On a multi-core host this is a large, avoidable slowdown — every external dep compiles one translation unit at a time.Evidence (live build)
Building the 3DForts lobby server, which pulls in DPP (Discord++) via an external cmake dependency:
clang++at a time, each pegging a single core at ~99%, the rest idle. Sampled 6 s apart → different processes on different files (dpp/guild.cpp→dpp/http_server_request.cpp), i.e. strictly sequential..cppfiles; at-O3, single-threaded, that's many minutes.clang++.This isn't a hang — it's just serial. But it's slow enough that automated runners polling the build look stuck and can burn their time budget waiting on a dep build that should take ~1/N as long.
Root cause (code references)
implementations/Crafter.Build-External.cpp:Contributing:
ConfigureCMake(line 194) configures with the default generator —Unix Makefiles is serial without
-j; Ninja would parallelize by default. Either way,cmake --buildwithout--paralleldoesn't use the cores.Fix
Pass an explicit parallel job count to
cmake --build, reusing the same concurrency crafter-build already uses elsewhere. The test runner already does exactly this inimplementations/Crafter.Build-Test.cpp:603:So in
BuildCMake:Notes:
--parallel N), not a bare--parallel— on the Makefiles generator a bare--parallelmaps tomake -jwith no limit (unbounded fork), which is worse.--jobs=CLI flag (Crafter.Build-Clang.cpp:1378) socrafter-build --jobs=Ngoverns dep builds too, instead of duplicatinghardware_concurrency().-G Ninja(parallel by default, and faster incremental).--parallel Nis the smaller, lower-risk change.Impact
Every external-dependency build (DPP, msquic, glslang, …) is ~N× slower than it should be on an N-core machine. Fixing it cuts cold-build time for any project with cmake deps substantially, and stops long dep builds from looking like hangs to anything watching the build.