common/autoconf/build-performance.m4

Thu, 12 Sep 2013 12:29:17 -0700

author
simonis
date
Thu, 12 Sep 2013 12:29:17 -0700
changeset 971
584dc2e95e04
parent 740
c0fa87863427
child 972
f3697e0783e2
permissions
-rw-r--r--

8024265: Enable new build on AIX
Reviewed-by: ihse

erikj@459 1 #
erikj@459 2 # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
erikj@459 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
erikj@459 4 #
erikj@459 5 # This code is free software; you can redistribute it and/or modify it
erikj@459 6 # under the terms of the GNU General Public License version 2 only, as
erikj@459 7 # published by the Free Software Foundation. Oracle designates this
erikj@459 8 # particular file as subject to the "Classpath" exception as provided
erikj@459 9 # by Oracle in the LICENSE file that accompanied this code.
erikj@459 10 #
erikj@459 11 # This code is distributed in the hope that it will be useful, but WITHOUT
erikj@459 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
erikj@459 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
erikj@459 14 # version 2 for more details (a copy is included in the LICENSE file that
erikj@459 15 # accompanied this code).
erikj@459 16 #
erikj@459 17 # You should have received a copy of the GNU General Public License version
erikj@459 18 # 2 along with this work; if not, write to the Free Software Foundation,
erikj@459 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
erikj@459 20 #
erikj@459 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
erikj@459 22 # or visit www.oracle.com if you need additional information or have any
erikj@459 23 # questions.
erikj@459 24 #
erikj@459 25
erikj@459 26 AC_DEFUN([BPERF_CHECK_CORES],
erikj@459 27 [
erikj@459 28 AC_MSG_CHECKING([for number of cores])
erikj@459 29 NUM_CORES=1
erikj@459 30 FOUND_CORES=no
erikj@459 31
erikj@459 32 if test -f /proc/cpuinfo; then
ohair@478 33 # Looks like a Linux (or cygwin) system
erikj@459 34 NUM_CORES=`cat /proc/cpuinfo | grep -c processor`
erikj@459 35 FOUND_CORES=yes
ohair@478 36 elif test -x /usr/sbin/psrinfo; then
erikj@459 37 # Looks like a Solaris system
erikj@459 38 NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line`
erikj@459 39 FOUND_CORES=yes
ohair@478 40 elif test -x /usr/sbin/system_profiler; then
erikj@459 41 # Looks like a MacOSX system
erikj@459 42 NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk '{print [$]5}'`
erikj@459 43 FOUND_CORES=yes
simonis@971 44 elif test "x$OPENJDK_BUILD_OS" = xaix ; then
simonis@971 45 NUM_CORES=`/usr/sbin/prtconf | grep "^Number Of Processors" | awk '{ print [$]4 }'`
simonis@971 46 FOUND_CORES=yes
ohair@494 47 elif test -n "$NUMBER_OF_PROCESSORS"; then
ohair@494 48 # On windows, look in the env
ohair@494 49 NUM_CORES=$NUMBER_OF_PROCESSORS
ohair@494 50 FOUND_CORES=yes
erikj@459 51 fi
erikj@459 52
erikj@459 53 if test "x$FOUND_CORES" = xyes; then
erikj@459 54 AC_MSG_RESULT([$NUM_CORES])
erikj@459 55 else
ohair@494 56 AC_MSG_RESULT([could not detect number of cores, defaulting to 1])
ohair@494 57 AC_MSG_WARN([This will disable all parallelism from build!])
erikj@459 58 fi
erikj@459 59
erikj@459 60 ])
erikj@459 61
erikj@459 62 AC_DEFUN([BPERF_CHECK_MEMORY_SIZE],
erikj@459 63 [
erikj@459 64 AC_MSG_CHECKING([for memory size])
ohair@478 65 # Default to 1024 MB
erikj@459 66 MEMORY_SIZE=1024
erikj@459 67 FOUND_MEM=no
erikj@459 68
ohair@478 69 if test -f /proc/meminfo; then
ohair@478 70 # Looks like a Linux (or cygwin) system
erikj@459 71 MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'`
erikj@459 72 MEMORY_SIZE=`expr $MEMORY_SIZE / 1024`
erikj@459 73 FOUND_MEM=yes
ohair@478 74 elif test -x /usr/sbin/prtconf; then
simonis@971 75 # Looks like a Solaris or AIX system
simonis@971 76 MEMORY_SIZE=`/usr/sbin/prtconf | grep "^Memory [[Ss]]ize" | awk '{ print [$]3 }'`
erikj@459 77 FOUND_MEM=yes
ohair@478 78 elif test -x /usr/sbin/system_profiler; then
erikj@459 79 # Looks like a MacOSX system
erikj@459 80 MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk '{print [$]2}'`
erikj@459 81 MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024`
erikj@459 82 FOUND_MEM=yes
ohair@494 83 elif test "x$OPENJDK_BUILD_OS" = xwindows; then
ohair@478 84 # Windows, but without cygwin
ohair@494 85 MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-`
ohair@494 86 MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
erikj@459 87 FOUND_MEM=yes
erikj@459 88 fi
erikj@459 89
erikj@459 90 if test "x$FOUND_MEM" = xyes; then
erikj@459 91 AC_MSG_RESULT([$MEMORY_SIZE MB])
erikj@459 92 else
ohair@494 93 AC_MSG_RESULT([could not detect memory size, defaulting to 1024 MB])
ohair@494 94 AC_MSG_WARN([This might seriously impact build performance!])
erikj@459 95 fi
erikj@459 96 ])
erikj@459 97
erikj@459 98 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES],
erikj@459 99 [
erikj@635 100 # How many cores do we have on this build system?
erikj@635 101 AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores],
erikj@459 102 [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])])
erikj@635 103 if test "x$with_num_cores" = x; then
erikj@459 104 # The number of cores were not specified, try to probe them.
erikj@459 105 BPERF_CHECK_CORES
erikj@635 106 else
erikj@459 107 NUM_CORES=$with_num_cores
erikj@635 108 fi
erikj@635 109 AC_SUBST(NUM_CORES)
erikj@459 110 ])
erikj@459 111
erikj@459 112 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY],
erikj@459 113 [
erikj@635 114 # How much memory do we have on this build system?
erikj@635 115 AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size],
erikj@459 116 [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])])
erikj@635 117 if test "x$with_memory_size" = x; then
erikj@459 118 # The memory size was not specified, try to probe it.
erikj@459 119 BPERF_CHECK_MEMORY_SIZE
erikj@635 120 else
erikj@459 121 MEMORY_SIZE=$with_memory_size
erikj@635 122 fi
erikj@635 123 AC_SUBST(MEMORY_SIZE)
erikj@635 124 ])
erikj@635 125
erikj@635 126 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS],
erikj@635 127 [
erikj@635 128 # Provide a decent default number of parallel jobs for make depending on
erikj@635 129 # number of cores, amount of memory and machine architecture.
erikj@635 130 AC_ARG_WITH(jobs, [AS_HELP_STRING([--with-jobs],
erikj@635 131 [number of parallel jobs to let make run @<:@calculated based on cores and memory@:>@])])
erikj@635 132 if test "x$with_jobs" = x; then
erikj@635 133 # Number of jobs was not specified, calculate.
erikj@635 134 AC_MSG_CHECKING([for appropriate number of jobs to run in parallel])
erikj@635 135 # Approximate memory in GB, rounding up a bit.
erikj@635 136 memory_gb=`expr $MEMORY_SIZE / 1100`
erikj@635 137 # Pick the lowest of memory in gb and number of cores.
erikj@635 138 if test "$memory_gb" -lt "$NUM_CORES"; then
erikj@635 139 JOBS="$memory_gb"
erikj@635 140 else
erikj@635 141 JOBS="$NUM_CORES"
erikj@635 142 # On bigger machines, leave some room for other processes to run
erikj@635 143 if test "$JOBS" -gt "4"; then
erikj@635 144 JOBS=`expr $JOBS '*' 90 / 100`
erikj@635 145 fi
erikj@635 146 fi
erikj@635 147 # Cap number of jobs to 16
erikj@635 148 if test "$JOBS" -gt "16"; then
erikj@635 149 JOBS=16
erikj@635 150 fi
erikj@724 151 if test "$JOBS" -eq "0"; then
erikj@724 152 JOBS=1
erikj@724 153 fi
erikj@635 154 AC_MSG_RESULT([$JOBS])
erikj@635 155 else
erikj@635 156 JOBS=$with_jobs
erikj@635 157 fi
erikj@635 158 AC_SUBST(JOBS)
erikj@459 159 ])
erikj@459 160
erikj@459 161 AC_DEFUN([BPERF_SETUP_CCACHE],
erikj@459 162 [
erikj@459 163 AC_ARG_ENABLE([ccache],
erikj@459 164 [AS_HELP_STRING([--disable-ccache],
ohair@494 165 [disable using ccache to speed up recompilations @<:@enabled@:>@])],
erikj@459 166 [ENABLE_CCACHE=${enable_ccache}], [ENABLE_CCACHE=yes])
erikj@459 167 if test "x$ENABLE_CCACHE" = xyes; then
erikj@740 168 OLD_PATH="$PATH"
erikj@740 169 if test "x$TOOLS_DIR" != x; then
erikj@740 170 PATH=$TOOLS_DIR:$PATH
erikj@740 171 fi
erikj@459 172 AC_PATH_PROG(CCACHE, ccache)
erikj@740 173 PATH="$OLD_PATH"
erikj@459 174 else
erikj@459 175 AC_MSG_CHECKING([for ccache])
erikj@459 176 AC_MSG_RESULT([explicitly disabled])
erikj@459 177 CCACHE=
erikj@459 178 fi
erikj@459 179 AC_SUBST(CCACHE)
erikj@459 180
erikj@459 181 AC_ARG_WITH([ccache-dir],
erikj@459 182 [AS_HELP_STRING([--with-ccache-dir],
erikj@459 183 [where to store ccache files @<:@~/.ccache@:>@])])
erikj@459 184
erikj@459 185 if test "x$with_ccache_dir" != x; then
erikj@459 186 # When using a non home ccache directory, assume the use is to share ccache files
erikj@459 187 # with other users. Thus change the umask.
erikj@459 188 SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002"
erikj@459 189 fi
erikj@459 190 CCACHE_FOUND=""
erikj@459 191 if test "x$CCACHE" != x; then
erikj@459 192 BPERF_SETUP_CCACHE_USAGE
erikj@459 193 fi
erikj@459 194 ])
erikj@459 195
erikj@459 196 AC_DEFUN([BPERF_SETUP_CCACHE_USAGE],
erikj@459 197 [
erikj@459 198 if test "x$CCACHE" != x; then
erikj@459 199 CCACHE_FOUND="true"
erikj@459 200 # Only use ccache if it is 3.1.4 or later, which supports
erikj@459 201 # precompiled headers.
erikj@459 202 AC_MSG_CHECKING([if ccache supports precompiled headers])
erikj@459 203 HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null`
erikj@459 204 if test "x$HAS_GOOD_CCACHE" = x; then
erikj@459 205 AC_MSG_RESULT([no, disabling ccache])
erikj@459 206 CCACHE=
erikj@459 207 else
erikj@459 208 AC_MSG_RESULT([yes])
erikj@459 209 AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers])
erikj@459 210 PUSHED_FLAGS="$CXXFLAGS"
erikj@459 211 CXXFLAGS="-fpch-preprocess $CXXFLAGS"
erikj@459 212 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no])
erikj@459 213 CXXFLAGS="$PUSHED_FLAGS"
erikj@459 214 if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then
erikj@459 215 AC_MSG_RESULT([yes])
erikj@459 216 else
erikj@459 217 AC_MSG_RESULT([no, disabling ccaching of precompiled headers])
erikj@459 218 CCACHE=
erikj@459 219 fi
erikj@459 220 fi
erikj@459 221 fi
erikj@459 222
erikj@459 223 if test "x$CCACHE" != x; then
erikj@459 224 CCACHE_SLOPPINESS=time_macros
erikj@459 225 CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE"
erikj@459 226 CCACHE_FLAGS=-fpch-preprocess
erikj@459 227
erikj@459 228 if test "x$SET_CCACHE_DIR" != x; then
erikj@459 229 mkdir -p $CCACHE_DIR > /dev/null 2>&1
erikj@459 230 chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1
erikj@459 231 fi
erikj@459 232 fi
erikj@459 233 ])
erikj@459 234
erikj@459 235 AC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS],
erikj@459 236 [
erikj@459 237
erikj@459 238 ###############################################################################
erikj@459 239 #
erikj@459 240 # Can the C/C++ compiler use precompiled headers?
erikj@459 241 #
erikj@459 242 AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers],
ohair@494 243 [disable using precompiled headers when compiling C++ @<:@enabled@:>@])],
tbell@512 244 [ENABLE_PRECOMPH=${enable_precompiled_headers}], [ENABLE_PRECOMPH=yes])
erikj@459 245
erikj@459 246 USE_PRECOMPILED_HEADER=1
erikj@459 247 if test "x$ENABLE_PRECOMPH" = xno; then
erikj@459 248 USE_PRECOMPILED_HEADER=0
erikj@459 249 fi
erikj@459 250
erikj@459 251 if test "x$ENABLE_PRECOMPH" = xyes; then
erikj@459 252 # Check that the compiler actually supports precomp headers.
erikj@459 253 if test "x$GCC" = xyes; then
tbell@512 254 AC_MSG_CHECKING([that precompiled headers work])
erikj@459 255 echo "int alfa();" > conftest.h
tbell@512 256 $CXX -x c++-header conftest.h -o conftest.hpp.gch 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD
erikj@459 257 if test ! -f conftest.hpp.gch; then
erikj@459 258 USE_PRECOMPILED_HEADER=0
erikj@459 259 AC_MSG_RESULT([no])
erikj@459 260 else
erikj@459 261 AC_MSG_RESULT([yes])
erikj@459 262 fi
tbell@512 263 rm -f conftest.h conftest.hpp.gch
erikj@459 264 fi
erikj@459 265 fi
erikj@459 266
erikj@459 267 AC_SUBST(USE_PRECOMPILED_HEADER)
erikj@459 268 ])
erikj@459 269
erikj@459 270
erikj@459 271 AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC],
erikj@459 272 [
ohair@478 273 AC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java],
ohair@494 274 [use this java binary for running the sjavac background server @<:@Boot JDK java@:>@])])
erikj@459 275
ohair@478 276 if test "x$with_sjavac_server_java" != x; then
ohair@478 277 SJAVAC_SERVER_JAVA="$with_sjavac_server_java"
ohair@478 278 FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""`
erikj@459 279 if test "x$FOUND_VERSION" = x; then
ohair@478 280 AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA])
erikj@459 281 fi
erikj@459 282 else
ohair@478 283 SJAVAC_SERVER_JAVA=""
erikj@459 284 # Hotspot specific options.
ohair@478 285 ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA])
erikj@459 286 # JRockit specific options.
ohair@478 287 ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA])
ohair@478 288 SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA"
erikj@459 289 fi
ohair@478 290 AC_SUBST(SJAVAC_SERVER_JAVA)
erikj@459 291
erikj@717 292 if test "$MEMORY_SIZE" -gt "2500"; then
erikj@717 293 ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 294 if test "$JVM_ARG_OK" = true; then
erikj@717 295 JVM_64BIT=true
erikj@717 296 JVM_ARG_OK=false
erikj@717 297 fi
erikj@459 298 fi
erikj@459 299
erikj@717 300 if test "$JVM_64BIT" = true; then
erikj@459 301 if test "$MEMORY_SIZE" -gt "17000"; then
ohair@478 302 ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 303 fi
erikj@717 304 if test "$MEMORY_SIZE" -gt "10000" && test "$JVM_ARG_OK" = false; then
ohair@478 305 ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 306 fi
erikj@717 307 if test "$MEMORY_SIZE" -gt "5000" && test "$JVM_ARG_OK" = false; then
ohair@478 308 ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 309 fi
erikj@717 310 if test "$MEMORY_SIZE" -gt "3800" && test "$JVM_ARG_OK" = false; then
ohair@478 311 ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@459 312 fi
erikj@717 313 fi
erikj@717 314 if test "$MEMORY_SIZE" -gt "2500" && test "$JVM_ARG_OK" = false; then
erikj@717 315 ADD_JVM_ARG_IF_OK([-Xms1000M -Xmx1500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 316 fi
erikj@717 317 if test "$MEMORY_SIZE" -gt "1000" && test "$JVM_ARG_OK" = false; then
erikj@717 318 ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 319 fi
erikj@717 320 if test "$JVM_ARG_OK" = false; then
erikj@717 321 ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
erikj@717 322 fi
erikj@459 323
erikj@459 324 AC_MSG_CHECKING([whether to use sjavac])
erikj@459 325 AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac],
erikj@459 326 [use sjavac to do fast incremental compiles @<:@disabled@:>@])],
erikj@459 327 [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no'])
erikj@459 328 AC_MSG_RESULT([$ENABLE_SJAVAC])
erikj@459 329 AC_SUBST(ENABLE_SJAVAC)
erikj@459 330
ohair@478 331 if test "x$ENABLE_SJAVAC" = xyes; then
ohair@478 332 SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers"
ohair@478 333 else
ohair@478 334 SJAVAC_SERVER_DIR=
ohair@478 335 fi
ohair@478 336 AC_SUBST(SJAVAC_SERVER_DIR)
ohair@478 337
erikj@459 338 ])

mercurial