changeset 900:266dc7ea04c2

If there's enough memory (half a gig per processor), use 1.5x as many CPUs to try to keep 'em busy.
author Rob Landley <rob@landley.net>
date Tue, 24 Nov 2009 03:19:07 -0600
parents 726cac165450
children 777af6561b2c
files sources/include.sh
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/sources/include.sh	Mon Nov 23 21:58:49 2009 -0600
+++ b/sources/include.sh	Tue Nov 24 03:19:07 2009 -0600
@@ -29,10 +29,15 @@
 
 # How many processors should make -j use?
 
+MEMTOTAL="$(awk '/MemTotal:/{print $2}' /proc/meminfo)"
 if [ -z "$CPUS" ]
 then
   export CPUS=$(echo /sys/devices/system/cpu/cpu[0-9]* | wc -w)
   [ "$CPUS" -lt 1 ] && CPUS=1
+
+  # If there's enough memory, try to make CPUs stay busy.
+
+  [ $(($CPUS*512*1024)) -le $MEMTOTAL ] && CPUS=$((($CPUS*3)/2))
 fi
 
 [ -z "$STAGE_NAME" ] && STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'`