summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-07-14 19:10:41 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-07-16 12:18:13 +0900
commitc068f54fc7fe694928239a6218fe6661a67a95a5 (patch)
tree8b1d6da056c0b7d290351eedf13488ea830eda5c
parent12c919a4bb3f8b1383d2e34709739a82874e34ba (diff)
downloadbuildstream-c068f54fc7fe694928239a6218fe6661a67a95a5.tar.gz
_context.py: Added max-jobs configuration
This loads the configuration of the max-jobs variable from the user configuration, where the default is 0 (meaning use the maximum number of cores with a limit of 8). This is a part of #1033
-rw-r--r--src/buildstream/_context.py10
-rw-r--r--src/buildstream/data/userconfig.yaml14
2 files changed, 23 insertions, 1 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index c29910418..286ed6d3d 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -121,6 +121,9 @@ class Context():
# What to do when a build fails in non interactive mode
self.sched_error_action = None
+ # Maximum jobs per build
+ self.build_max_jobs = None
+
# Size of the artifact cache in bytes
self.config_cache_quota = None
@@ -205,7 +208,7 @@ class Context():
"artifactdir is obsolete")
defaults.validate_keys([
- 'cachedir', 'sourcedir', 'builddir', 'logdir', 'scheduler',
+ 'cachedir', 'sourcedir', 'builddir', 'logdir', 'scheduler', 'build',
'artifacts', 'source-caches', 'logging', 'projects', 'cache', 'prompt',
'workspacedir', 'remote-execution',
])
@@ -312,6 +315,11 @@ class Context():
self.sched_pushers = scheduler.get_int('pushers')
self.sched_network_retries = scheduler.get_int('network-retries')
+ # Load build config
+ build = defaults.get_mapping('build')
+ build.validate_keys(['max-jobs'])
+ self.build_max_jobs = build.get_int('max-jobs')
+
# Load per-projects overrides
self._project_overrides = defaults.get_mapping('projects', default={})
diff --git a/src/buildstream/data/userconfig.yaml b/src/buildstream/data/userconfig.yaml
index 34fd300d1..a73c1ce44 100644
--- a/src/buildstream/data/userconfig.yaml
+++ b/src/buildstream/data/userconfig.yaml
@@ -78,6 +78,20 @@ scheduler:
#
+# Build related configuration
+#
+build:
+
+ #
+ # Maximum number of jobs to run per build task.
+ #
+ # The default behavior when this is set to 0, is to use the
+ # maximum number of threads available, with a maximum of 8.
+ #
+ max-jobs: 0
+
+
+#
# Logging
#
logging: