You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:55:17 UTC

[buildstream] 03/09: Max-jobs is now defined on a platform basis

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch workspace_list_error_message
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 454b1aaffd1b9d29a5b772ddb19ea917a612f261
Author: knownexus <ph...@codethink.co.uk>
AuthorDate: Fri Sep 7 12:03:13 2018 +0100

    Max-jobs is now defined on a platform basis
    
    This is due to Darwin (MacOS) having a different Max-Jobs limit
    _platform/platform.py: Adding max-jobs call
    
    _project.py: redirected 'max-jobs' to point at the platform
---
 buildstream/_platform/platform.py | 3 +++
 buildstream/_project.py           | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/buildstream/_platform/platform.py b/buildstream/_platform/platform.py
index a10c66d..524985c 100644
--- a/buildstream/_platform/platform.py
+++ b/buildstream/_platform/platform.py
@@ -68,6 +68,9 @@ class Platform():
             raise PlatformError("Platform needs to be initialized first")
         return cls._instance
 
+    def get_cpu_count(self, cap=None):
+        return min(len(os.sched_getaffinity(0)), cap)
+
     ##################################################################
     #                       Platform properties                      #
     ##################################################################
diff --git a/buildstream/_project.py b/buildstream/_project.py
index b72318a..44e5171 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -38,6 +38,7 @@ from ._loader import Loader
 from .element import Element
 from ._message import Message, MessageType
 from ._includes import Includes
+from ._platform import Platform
 
 
 # Project Configuration file
@@ -617,7 +618,8 @@ class Project():
         # Based on some testing (mainly on AWS), maximum effective
         # max-jobs value seems to be around 8-10 if we have enough cores
         # users should set values based on workload and build infrastructure
-        output.base_variables['max-jobs'] = str(min(len(os.sched_getaffinity(0)), 8))
+        platform = Platform.get_platform()
+        output.base_variables['max-jobs'] = str(platform.get_cpu_count(8))
 
         # Export options into variables, if that was requested
         output.options.export_variables(output.base_variables)