Skip to content
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

[bug] get_cpus is not supporting cgroup2 #11635 #2658

Merged
merged 1 commit into from Jul 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions reference/conanfile/tools/build.rst
Expand Up @@ -98,3 +98,30 @@ Parameters:
- **conanfile**: The current recipe object. Always use ``self``.
- **compiler**: Name of the compiler e.g: gcc
- **compiler_version**: Version of the compiler e.g: 12


conan.tools.build.build_jobs()
------------------------------

.. code-block:: python

def build_jobs(conanfile):



Returns the number of CPUs available for parallel builds.
It returns the configuration value for ``tools.build:jobs`` if exists, otherwise,
it defaults to the helper function ``_cpu_count()``.
``_cpu_count()`` reads cgroup to detect the configured number of CPUs.
Currently, there are two versions of cgroup available.

In the case of cgroup v1, if the data in cgroup is invalid, processor detection comes into play.
Whenever processor detection is not enabled, ``build_jobs()`` will safely return 1.

In the case of cgroup v2, if no limit is set, processor detection is used. When the limit is set,
the behavior is as described in cgroup v1.


Parameters:

- **conanfile**: The current recipe object. Always use ``self``.