summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2015-09-29 13:11:27 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2015-09-29 13:19:45 +0000
commit8defcb4365240b130dc50d54c33e9a813089cf05 (patch)
tree57fcd7f77bc868a52d59e380ff526abb0b2e6c46
parent3f8b5c66ff91c338fbca9d99e27b61638e154136 (diff)
downloadbuildslave-scripts-8defcb4365240b130dc50d54c33e9a813089cf05.tar.gz
Divide up available CPUs dynamically for builds
Having 5 builds on ARM is not performant, so we should split it up dynamically.
-rwxr-xr-xbuild_a_system.sh22
1 files changed, 17 insertions, 5 deletions
diff --git a/build_a_system.sh b/build_a_system.sh
index 4dc5b9f..d38b8ce 100755
--- a/build_a_system.sh
+++ b/build_a_system.sh
@@ -7,11 +7,23 @@ set -ex
system_name="$1"
system_arch="$2"
-definitions_dir=$(pwd)/definitions
-ybd_dir=$(pwd)/ybd
-
-# Building is optimal with 5 "instances" on the monster machine
-sudo sed -i '/^instances: /c\instances: 5' "$ybd_dir"/ybd.conf
+definitions_dir="$(pwd)/definitions"
+ybd_dir="$(pwd)/ybd"
+
+# Experimentally we have seen no benefit to a single build with greater
+# than max-jobs: 10, though 8 divides up more nicely, so we previously
+# had 5 builders with 8 cores each for the parallel build on the meaty
+# x86 VPS, but we'd like to see some parallelism on the ARM builders,
+# which have 8 CPUs total, so we'd need to have 4 to see any parallelism.
+cpus_per_instance=4
+
+# Determine the number of instances to have such that each has at least
+# the specified number of CPUs but not more than double it.
+# STYLE NOTE: Substitutions are intentionally not quoted here, since in
+# some shells arithmetic expansion doesn't follow the traditional POSIX
+# word splitting, so quotes aren't removed.
+instances="$(( $(nproc) / $cpus_per_instance == 0 ? 1 : $(nproc) / $cpus_per_instance ))"
+sudo sed -i "/^instances: /c\\instances: $instances" "$ybd_dir"/ybd.conf
# will this build things - No.
# "$ybd_dir"/ybd.py "$definitions_dir"/systems/"$system_name"