[Notes] [Git][BuildStream/buildstream][mac_fixes] Moving `os.sched_getaffinity(0)` logic



Title: GitLab

Phillip Smyth pushed to branch mac_fixes at BuildStream / buildstream

Commits:

3 changed files:

Changes:

  • buildstream/_platform/darwin.py
    ... ... @@ -45,3 +45,6 @@ class Darwin(Platform):
    45 45
     
    
    46 46
         def create_sandbox(self, *args, **kwargs):
    
    47 47
             return SandboxChroot(*args, **kwargs)
    
    48
    +
    
    49
    +    def get_cpu_count(self):
    
    50
    +        return str(os.cpu_count())

  • buildstream/_platform/platform.py
    ... ... @@ -96,3 +96,6 @@ class Platform():
    96 96
         def create_sandbox(self, *args, **kwargs):
    
    97 97
             raise ImplError("Platform {platform} does not implement create_sandbox()"
    
    98 98
                             .format(platform=type(self).__name__))
    
    99
    +
    
    100
    +    def get_cpu_count(self):
    
    101
    +        return str(min(len(os.sched_getaffinity(0)), 8))

  • buildstream/_project.py
    ... ... @@ -19,6 +19,7 @@
    19 19
     #        Tiago Gomes <tiago gomes codethink co uk>
    
    20 20
     
    
    21 21
     import os
    
    22
    +import sys
    
    22 23
     from collections import Mapping, OrderedDict
    
    23 24
     from pluginbase import PluginBase
    
    24 25
     from . import utils
    
    ... ... @@ -38,6 +39,7 @@ from ._loader import Loader
    38 39
     from .element import Element
    
    39 40
     from ._message import Message, MessageType
    
    40 41
     from ._includes import Includes
    
    42
    +from ._platform import Platform
    
    41 43
     
    
    42 44
     
    
    43 45
     # Project Configuration file
    
    ... ... @@ -594,7 +596,8 @@ class Project():
    594 596
             # Based on some testing (mainly on AWS), maximum effective
    
    595 597
             # max-jobs value seems to be around 8-10 if we have enough cores
    
    596 598
             # users should set values based on workload and build infrastructure
    
    597
    -        output.base_variables['max-jobs'] = str(min(len(os.sched_getaffinity(0)), 8))
    
    599
    +        platform = Platform.get_platform()
    
    600
    +        output.base_variables['max-jobs'] = platform.get_cpu_count()
    
    598 601
     
    
    599 602
             # Export options into variables, if that was requested
    
    600 603
             output.options.export_variables(output.base_variables)
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]