Skip to content

[cmake] Option to create Ninja job pools depending on available resources #65274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

jusito
Copy link
Contributor

@jusito jusito commented Sep 4, 2023

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.

@jusito jusito force-pushed the cmake/calculate_job_pools branch from 37d5ef4 to 02a8528 Compare September 4, 2023 19:11
…rces.

Dynamically couple compile time to available resources in memory constrained environments.
Tweaked alternative to LLVM_PARALLEL_{COMPILE,LINK}_JOBS=1.
@Endilll Endilll added the cmake Build system in general and CMake in particular label Sep 5, 2023
@jusito jusito force-pushed the cmake/calculate_job_pools branch from 02a8528 to 4548037 Compare September 5, 2023 11:14
Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see the value of having this.

@jusito
Copy link
Contributor Author

jusito commented Sep 18, 2023

@compnerd Is it necessary for me to fix the pipeline because it doesn't seem to be related to my changes?
image

@artagnon
Copy link
Contributor

This should be ready to merge as-is. The CI failure is spurious, and can be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants