changeset 1476:a4714d7d6769

Tweak CPUS calculation again: don't overcommit when using hyper-threading.
author Rob Landley <rob@landley.net>
date Thu, 22 Dec 2011 16:49:03 -0600
parents c3b5be048ba4
children 431d5b4ee537
files sources/include.sh
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sources/include.sh	Thu Dec 22 13:29:11 2011 -0600
+++ b/sources/include.sh	Thu Dec 22 16:49:03 2011 -0600
@@ -55,9 +55,12 @@
   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.
+  # If we're not using hyper-threading, and there's plenty of memory,
+  # use 50% more CPUS than we actually have to keep system busy
 
-  [ $(($CPUS*512*1024)) -le $MEMTOTAL ] && CPUS=$((($CPUS*3)/2))
+  [ -z "$(cat /proc/cpuinfo | grep '^flags' | head -n 1 | grep -w ht)" ] &&
+    [ $(($CPUS*512*1024)) -le $MEMTOTAL ] &&
+      CPUS=$((($CPUS*3)/2))
 fi
 
 export_if_blank STAGE_NAME=`echo $0 | sed 's@.*/\(.*\)\.sh@\1@'`