[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:

4 changed files:

Changes:

  • buildstream/_platform/darwin.py
    ... ... @@ -18,7 +18,6 @@
    18 18
     import os
    
    19 19
     import resource
    
    20 20
     
    
    21
    -from .._artifactcache.cascache import CASCache
    
    22 21
     from .._exceptions import PlatformError
    
    23 22
     from ..sandbox import SandboxChroot
    
    24 23
     
    
    ... ... @@ -44,3 +43,6 @@ class Darwin(Platform):
    44 43
     
    
    45 44
         def create_sandbox(self, *args, **kwargs):
    
    46 45
             return SandboxChroot(*args, **kwargs)
    
    46
    +
    
    47
    +    def get_cpu_count(self):
    
    48
    +        return str(os.cpu_count())

  • buildstream/_platform/platform.py
    ... ... @@ -21,6 +21,7 @@ import os
    21 21
     import sys
    
    22 22
     
    
    23 23
     from .._exceptions import PlatformError, ImplError
    
    24
    +from .._artifactcache.cascache import CASCache
    
    24 25
     
    
    25 26
     
    
    26 27
     class Platform():
    
    ... ... @@ -97,3 +98,9 @@ class Platform():
    97 98
         def create_sandbox(self, *args, **kwargs):
    
    98 99
             raise ImplError("Platform {platform} does not implement create_sandbox()"
    
    99 100
                             .format(platform=type(self).__name__))
    
    101
    +
    
    102
    +    def get_cpu_count(self, cap=None):
    
    103
    +        if cap is None:
    
    104
    +            return len(os.sched_getaffinity(0))
    
    105
    +        else:
    
    106
    +            return min(len(os.sched_getaffinity(0)), cap)

  • buildstream/_platform/unix.py
    ... ... @@ -20,7 +20,6 @@
    20 20
     import os
    
    21 21
     import resource
    
    22 22
     
    
    23
    -from .._artifactcache.cascache import CASCache
    
    24 23
     from .._exceptions import PlatformError
    
    25 24
     from ..sandbox import SandboxChroot
    
    26 25
     
    

  • 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'] = str(platform.get_cpu_count(8))
    
    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]