Commit cd59993d authored by Javier Jardón's avatar Javier Jardón
Browse files

Merge branch 'jjardon/max-jobs_1.2' into 'bst-1.2'

[1.2] Backport of !620: Restrict max-jobs

See merge request !629
parents f5683244 5adf32f1
Loading
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
#        Tiago Gomes <tiago.gomes@codethink.co.uk>

import os
import multiprocessing  # for cpu_count()
from collections import Mapping, OrderedDict
from pluginbase import PluginBase
from . import utils
@@ -572,7 +571,10 @@ class Project():

        # Extend variables with automatic variables and option exports
        # Initialize it as a string as all variables are processed as strings.
        output.base_variables['max-jobs'] = str(multiprocessing.cpu_count())
        # 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))

        # Export options into variables, if that was requested
        output.options.export_variables(output.base_variables)