diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-05-07 21:32:14 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-05-08 12:54:17 +0300 |
commit | 0d43d0bcab9aa91fd22971fdb98de94aad0a9e77 (patch) | |
tree | 9fa68928b67ffaa8a6c5e00d02f1ef4a1edba330 /build_files/cmake/macros.cmake | |
parent | 27b9a0cd670ff1dabe031596cef76908df76c3c8 (diff) |
CMake: Add support of Ninja's pools to ease building on limited amount of RAM.
Many modern computers support a lot of threads (parrallel building
jobs), but are somewhat restricted in memory, when some building jobs
can require several GB each.
Ninja builder has pools, which extend the usual `-j X` make
parallelizing option, by allowing to specify different numbers of
parallel jobs for different targets.
This commit defines three pools, one for linking, one for usual compile,
and one for compiling some 'heavy' cpp libs, when a single file can
require GB of RAM in full debug builds.
Simply enabling WITH_NINJA_POOL_JOBS will try to set default sensible
values for those three pools based on your machine specifications, you
can then tweak further the values of NINJA_MAX_NUM_PARALLEL_ settings,
if you like.
On my system (8 cores, 16GB RAM), it allows to build a full debug with
all ASAN options build with roughly 7GB of RAM used at most, pretty much
as quickly as without that option (which would require up to 11GB of
available RAM at some points).
Review task: D4780.
Diffstat (limited to 'build_files/cmake/macros.cmake')
-rw-r--r-- | build_files/cmake/macros.cmake | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index 56d9117e560..10b293c64b4 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -285,6 +285,26 @@ function(blender_add_lib set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name}) endfunction() +# Ninja only: assign 'heavy pool' to some targets that are especially RAM-consuming to build. +function(setup_heavy_lib_pool) + if(WITH_NINJA_POOL_JOBS AND NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS) + if(WITH_CYCLES) + list(APPEND _HEAVY_LIBS "cycles_device" "cycles_kernel") + endif() + if(WITH_LIBMV) + list(APPEND _HEAVY_LIBS "bf_intern_libmv") + endif() + if(WITH_OPENVDB) + list(APPEND _HEAVY_LIBS "bf_intern_openvdb") + endif() + + foreach(TARGET ${_HEAVY_LIBS}) + if(TARGET ${TARGET}) + set_property(TARGET ${TARGET} PROPERTY JOB_POOL_COMPILE compile_heavy_job_pool) + endif() + endforeach() + endif() +endfunction() function(SETUP_LIBDIRS) |