Skip to content
Snippets Groups Projects
Commit 828c8d7b authored by knownexus's avatar knownexus
Browse files

Moving `os.sched_getaffinity(0)` logic

Removed `os.sched_getaffinity(0)` from _project.py
Added `os.sched_getaffinity(0)` to platform.py
Added `os.cpu_count()` to darwin.py
parent 5f4ad644
No related branches found
No related tags found
No related merge requests found
Pipeline #29052143 failed
......@@ -49,3 +49,6 @@ class Darwin(Platform):
def create_sandbox(self, *args, **kwargs):
return SandboxChroot(*args, **kwargs)
def get_cpu_count(self):
return str(min(len(os.cpu_count())))
......@@ -96,3 +96,6 @@ class Platform():
def create_sandbox(self, *args, **kwargs):
raise ImplError("Platform {platform} does not implement create_sandbox()"
.format(platform=type(self).__name__))
def get_cpu_count(self):
return str(min(len(os.sched_getaffinity(0)), 8))
......@@ -19,6 +19,7 @@
# Tiago Gomes <tiago.gomes@codethink.co.uk>
import os
import sys
from collections import Mapping, OrderedDict
from pluginbase import PluginBase
from . import utils
......@@ -38,6 +39,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
......@@ -140,6 +142,7 @@ class Project():
profile_start(Topics.LOAD_PROJECT, self.directory.replace(os.sep, '-'))
self._load(parent_loader=parent_loader, tempdir=tempdir)
profile_end(Topics.LOAD_PROJECT, self.directory.replace(os.sep, '-'))
self.platform = Platform.get_platform()
self._partially_loaded = True
......@@ -594,7 +597,7 @@ 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))
output.base_variables['max-jobs'] = self.platform.get_cpu_count()
# Export options into variables, if that was requested
output.options.export_variables(output.base_variables)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment