summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <jjardon@gnome.org>2018-08-09 14:23:13 +0100
committerJavier Jardón <jjardon@gnome.org>2018-08-09 17:31:15 +0100
commit2d0611737481825fe20113723a5e6c3a7e0bbc53 (patch)
tree7b2a6d5dbaf2fcfb8222b89e2423f2b31a076253
parentef7810f37bff2a85ad8d874b068121ac50b77801 (diff)
downloadbuildstream-2d0611737481825fe20113723a5e6c3a7e0bbc53.tar.gz
buildstream/_project.py:
Multiprocessing with n_jobs given by multiprocessing.cpu_count() is not optimal for systems where not all CPU can be used (in particular, Docker, CI etc). As suggested in the multiprocessing docs (http://docs.python.org/3/library/multiprocessing.html#multiprocessing.cpu_count) using len(os.sched_getaffinity(0)) might be better.
-rw-r--r--buildstream/_project.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/buildstream/_project.py b/buildstream/_project.py
index a0f3a5059..ba49f7d73 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -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,7 @@ 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())
+ output.base_variables['max-jobs'] = str(len(os.sched_getaffinity(0)))
# Export options into variables, if that was requested
output.options.export_variables(output.base_variables)