google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
10.79k stars 2.09k forks source link

cmake: update build instructions to recommend parallel build (faster) #4215

Open jjacobsohn opened 2 months ago

jjacobsohn commented 2 months ago

applies to: C++ / CP-SAT, Routing, Linear Solver. Tested on ARM 64 platform (Pi 5)

on some platforms the default cmake build is single threaded and does not expand to fill available cores. current versions of cmake accept a flag "--parallel " which passes platform-specific flags down to the compile steps.

multicore compilation can finish substantially faster. for example, a scratch build on the Pi 5 (ARM 64) building with "cmake --build build" runs on a single core and takes 134 minutes. Running "cmake --build build --parallel 4" runs on all four cores and takes 68 minutes.

recommended solution is to update the cmake build documentation file to inform about this option.

there is also a way to make multicore default, but that assumes all users will prefer it.

reference: https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-build-j

Mizux commented 2 months ago

https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-build-j

here I'm using -j as well as env var

CMAKE_C_COMPILER_LAUNCHER=ccache
CMAKE_CXX_COMPILER_LAUNCHER=ccache