[cmake] Option to create Ninja job pools depending on available resources #65274
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds options to let CMake calculate the ninja job pools depending on free memory and available cores.
You can provide memory requirements for each compile and link job which is checked against CMake AVAILABLE_PHYSICAL_MEMORY and NUMBER_OF_LOGICAL_CORES. This information are available since CMake 3.0.
This is very helpful in CI environments with multiple jobs per environment or a VM with multiple users.
Its different to LLVM_PARALLEL_LINK_JOBS / LLVM_PARALLEL_COMPILE_JOBS (or ninja -j 1) because it tries to use the resources more efficient without being terminated. Only downside currently is that compile and link jobs can run at the same time so there is an offset for link job memory suggested which is added to the documentation.
The definitions aren't added as cache because if I understand it correctly this would break it because values could be outdated.