changeset 1441:4923bba45afe

Try to auto-balance FORK=1 and CPUS so as not to overload build server.
author Rob Landley <rob@landley.net>
date Sat, 10 Sep 2011 08:28:32 -0500
parents e93e6c80ebdc
children 1039cd16dc92
files more/buildall.sh
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/more/buildall.sh	Sat Sep 10 08:28:00 2011 -0500
+++ b/more/buildall.sh	Sat Sep 10 08:28:32 2011 -0500
@@ -28,6 +28,17 @@
 
 cp packages/MANIFEST build || dienow
 
+# Adjust $CPUS so as not to overload the machine, max 2 build processes
+# per gigabyte of RAM
+
+if [ ! -z "$FORK" ] && [ -z "$CPUS" ]
+then
+  MEGS=$(($(awk '/MemTotal:/{print $2}' /proc/meminfo)/1024))
+  TARGET_COUNT=$(find sources/targets -maxdepth 1 -type f | wc -l)
+  export CPUS=$(($MEGS/($TARGET_COUNT*512)))
+  [ "$CPUS" -lt 1 ] && CPUS=1
+fi
+
 # Build all non-hw targets, possibly in parallel
 
 more/for-each-target.sh \