summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknownexus <phillip.smyth@codethink.co.uk>2018-09-07 12:03:13 +0100
committerJürg Billeter <j@bitron.ch>2018-09-27 15:22:09 +0100
commit5e81573bc1f3d4a7245793b24df8a36eb3dc9e94 (patch)
treec01a91a3492edd6381f48f4d03296e6acb0b7949
parent80ebdd2cbf3ddb5f4bb9b2078b2ffe86d20a74c8 (diff)
downloadbuildstream-5e81573bc1f3d4a7245793b24df8a36eb3dc9e94.tar.gz
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
-rw-r--r--buildstream/_platform/platform.py3
-rw-r--r--buildstream/_project.py4
2 files changed, 6 insertions, 1 deletions
diff --git a/buildstream/_platform/platform.py b/buildstream/_platform/platform.py
index d3878652e..9e5051dd7 100644
--- a/buildstream/_platform/platform.py
+++ b/buildstream/_platform/platform.py
@@ -63,6 +63,9 @@ class Platform():
cls._create_instance()
return cls._instance
+ def get_cpu_count(self, cap=None):
+ return min(len(os.sched_getaffinity(0)), cap)
+
##################################################################
# Sandbox functions #
##################################################################
diff --git a/buildstream/_project.py b/buildstream/_project.py
index b72318af9..44e5171e6 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)