common/autoconf/build-performance.m4

changeset 635
907a926d3c96
parent 512
582c696033f5
child 717
e247ee3924d5
     1.1 --- a/common/autoconf/build-performance.m4	Thu Feb 28 20:29:19 2013 -0800
     1.2 +++ b/common/autoconf/build-performance.m4	Mon Mar 04 16:45:07 2013 +0100
     1.3 @@ -47,10 +47,6 @@
     1.4          FOUND_CORES=yes
     1.5      fi
     1.6  
     1.7 -    # For c/c++ code we run twice as many concurrent build
     1.8 -    # jobs than we have cores, otherwise we will stall on io.
     1.9 -    CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2`
    1.10 -
    1.11      if test "x$FOUND_CORES" = xyes; then
    1.12          AC_MSG_RESULT([$NUM_CORES])
    1.13      else
    1.14 @@ -98,32 +94,62 @@
    1.15  
    1.16  AC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES],
    1.17  [
    1.18 -# How many cores do we have on this build system?
    1.19 -AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores],
    1.20 +  # How many cores do we have on this build system?
    1.21 +  AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores],
    1.22      [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])])
    1.23 -if test "x$with_num_cores" = x; then
    1.24 +  if test "x$with_num_cores" = x; then
    1.25      # The number of cores were not specified, try to probe them.
    1.26      BPERF_CHECK_CORES
    1.27 -else
    1.28 +  else
    1.29      NUM_CORES=$with_num_cores
    1.30 -    CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2`
    1.31 -fi
    1.32 -AC_SUBST(NUM_CORES)
    1.33 -AC_SUBST(CONCURRENT_BUILD_JOBS)
    1.34 +  fi
    1.35 +  AC_SUBST(NUM_CORES)
    1.36  ])
    1.37  
    1.38  AC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY],
    1.39  [
    1.40 -# How much memory do we have on this build system?
    1.41 -AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size],
    1.42 +  # How much memory do we have on this build system?
    1.43 +  AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size],
    1.44      [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])])
    1.45 -if test "x$with_memory_size" = x; then
    1.46 +  if test "x$with_memory_size" = x; then
    1.47      # The memory size was not specified, try to probe it.
    1.48      BPERF_CHECK_MEMORY_SIZE
    1.49 -else
    1.50 +  else
    1.51      MEMORY_SIZE=$with_memory_size
    1.52 -fi
    1.53 -AC_SUBST(MEMORY_SIZE)
    1.54 +  fi
    1.55 +  AC_SUBST(MEMORY_SIZE)
    1.56 +])
    1.57 +
    1.58 +AC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS],
    1.59 +[
    1.60 +  # Provide a decent default number of parallel jobs for make depending on 
    1.61 +  # number of cores, amount of memory and machine architecture.
    1.62 +  AC_ARG_WITH(jobs, [AS_HELP_STRING([--with-jobs],
    1.63 +    [number of parallel jobs to let make run @<:@calculated based on cores and memory@:>@])])
    1.64 +  if test "x$with_jobs" = x; then
    1.65 +    # Number of jobs was not specified, calculate.
    1.66 +    AC_MSG_CHECKING([for appropriate number of jobs to run in parallel])
    1.67 +    # Approximate memory in GB, rounding up a bit.
    1.68 +    memory_gb=`expr $MEMORY_SIZE / 1100`
    1.69 +    # Pick the lowest of memory in gb and number of cores.
    1.70 +    if test "$memory_gb" -lt "$NUM_CORES"; then
    1.71 +      JOBS="$memory_gb"
    1.72 +    else
    1.73 +      JOBS="$NUM_CORES"
    1.74 +      # On bigger machines, leave some room for other processes to run
    1.75 +      if test "$JOBS" -gt "4"; then
    1.76 +        JOBS=`expr $JOBS '*' 90 / 100`
    1.77 +      fi
    1.78 +    fi
    1.79 +    # Cap number of jobs to 16
    1.80 +    if test "$JOBS" -gt "16"; then
    1.81 +      JOBS=16
    1.82 +    fi
    1.83 +    AC_MSG_RESULT([$JOBS])
    1.84 +  else
    1.85 +    JOBS=$with_jobs
    1.86 +  fi
    1.87 +  AC_SUBST(JOBS)
    1.88  ])
    1.89  
    1.90  AC_DEFUN([BPERF_SETUP_CCACHE],

mercurial