1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/common/autoconf/build-performance.m4 Thu Jul 05 18:27:07 2012 -0700 1.3 @@ -0,0 +1,378 @@ 1.4 +# 1.5 +# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 +# 1.8 +# This code is free software; you can redistribute it and/or modify it 1.9 +# under the terms of the GNU General Public License version 2 only, as 1.10 +# published by the Free Software Foundation. Oracle designates this 1.11 +# particular file as subject to the "Classpath" exception as provided 1.12 +# by Oracle in the LICENSE file that accompanied this code. 1.13 +# 1.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 1.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 +# version 2 for more details (a copy is included in the LICENSE file that 1.18 +# accompanied this code). 1.19 +# 1.20 +# You should have received a copy of the GNU General Public License version 1.21 +# 2 along with this work; if not, write to the Free Software Foundation, 1.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 +# 1.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.25 +# or visit www.oracle.com if you need additional information or have any 1.26 +# questions. 1.27 +# 1.28 + 1.29 +AC_DEFUN([BPERF_CHECK_CORES], 1.30 +[ 1.31 + AC_MSG_CHECKING([for number of cores]) 1.32 + NUM_CORES=1 1.33 + FOUND_CORES=no 1.34 + 1.35 + if test -f /proc/cpuinfo; then 1.36 + # Looks like a Linux system 1.37 + NUM_CORES=`cat /proc/cpuinfo | grep -c processor` 1.38 + FOUND_CORES=yes 1.39 + fi 1.40 + 1.41 + if test -x /usr/sbin/psrinfo; then 1.42 + # Looks like a Solaris system 1.43 + NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line` 1.44 + FOUND_CORES=yes 1.45 + fi 1.46 + 1.47 + if test -x /usr/sbin/system_profiler; then 1.48 + # Looks like a MacOSX system 1.49 + NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk '{print [$]5}'` 1.50 + FOUND_CORES=yes 1.51 + fi 1.52 + 1.53 + if test "x$build_os" = xwindows; then 1.54 + NUM_CORES=4 1.55 + fi 1.56 + 1.57 + # For c/c++ code we run twice as many concurrent build 1.58 + # jobs than we have cores, otherwise we will stall on io. 1.59 + CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` 1.60 + 1.61 + if test "x$FOUND_CORES" = xyes; then 1.62 + AC_MSG_RESULT([$NUM_CORES]) 1.63 + else 1.64 + AC_MSG_RESULT([could not detect number of cores, defaulting to 1!]) 1.65 + fi 1.66 + 1.67 +]) 1.68 + 1.69 +AC_DEFUN([BPERF_CHECK_MEMORY_SIZE], 1.70 +[ 1.71 + AC_MSG_CHECKING([for memory size]) 1.72 + # Default to 1024MB 1.73 + MEMORY_SIZE=1024 1.74 + FOUND_MEM=no 1.75 + 1.76 + if test -f /proc/cpuinfo; then 1.77 + # Looks like a Linux system 1.78 + MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'` 1.79 + MEMORY_SIZE=`expr $MEMORY_SIZE / 1024` 1.80 + FOUND_MEM=yes 1.81 + fi 1.82 + 1.83 + if test -x /usr/sbin/prtconf; then 1.84 + # Looks like a Solaris system 1.85 + MEMORY_SIZE=`/usr/sbin/prtconf | grep "Memory size" | awk '{ print [$]3 }'` 1.86 + FOUND_MEM=yes 1.87 + fi 1.88 + 1.89 + if test -x /usr/sbin/system_profiler; then 1.90 + # Looks like a MacOSX system 1.91 + MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk '{print [$]2}'` 1.92 + MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024` 1.93 + FOUND_MEM=yes 1.94 + fi 1.95 + 1.96 + if test "x$build_os" = xwindows; then 1.97 + MEMORY_SIZE=`systeminfo | grep 'Total Physical Memory:' | awk '{ print [$]4 }' | sed 's/,//'` 1.98 + FOUND_MEM=yes 1.99 + fi 1.100 + 1.101 + if test "x$FOUND_MEM" = xyes; then 1.102 + AC_MSG_RESULT([$MEMORY_SIZE MB]) 1.103 + else 1.104 + AC_MSG_RESULT([could not detect memory size defaulting to 1024MB!]) 1.105 + fi 1.106 +]) 1.107 + 1.108 +AC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES], 1.109 +[ 1.110 +# How many cores do we have on this build system? 1.111 +AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores], 1.112 + [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])]) 1.113 +if test "x$with_num_cores" = x; then 1.114 + # The number of cores were not specified, try to probe them. 1.115 + BPERF_CHECK_CORES 1.116 +else 1.117 + NUM_CORES=$with_num_cores 1.118 + CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` 1.119 +fi 1.120 +AC_SUBST(NUM_CORES) 1.121 +AC_SUBST(CONCURRENT_BUILD_JOBS) 1.122 +]) 1.123 + 1.124 +AC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY], 1.125 +[ 1.126 +# How much memory do we have on this build system? 1.127 +AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size], 1.128 + [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])]) 1.129 +if test "x$with_memory_size" = x; then 1.130 + # The memory size was not specified, try to probe it. 1.131 + BPERF_CHECK_MEMORY_SIZE 1.132 +else 1.133 + MEMORY_SIZE=$with_memory_size 1.134 +fi 1.135 +AC_SUBST(MEMORY_SIZE) 1.136 +]) 1.137 + 1.138 +AC_DEFUN([BPERF_SETUP_CCACHE], 1.139 +[ 1.140 + AC_ARG_ENABLE([ccache], 1.141 + [AS_HELP_STRING([--disable-ccache], 1.142 + [use ccache to speed up recompilations @<:@enabled@:>@])], 1.143 + [ENABLE_CCACHE=${enable_ccache}], [ENABLE_CCACHE=yes]) 1.144 + if test "x$ENABLE_CCACHE" = xyes; then 1.145 + AC_PATH_PROG(CCACHE, ccache) 1.146 + else 1.147 + AC_MSG_CHECKING([for ccache]) 1.148 + AC_MSG_RESULT([explicitly disabled]) 1.149 + CCACHE= 1.150 + fi 1.151 + AC_SUBST(CCACHE) 1.152 + 1.153 + AC_ARG_WITH([ccache-dir], 1.154 + [AS_HELP_STRING([--with-ccache-dir], 1.155 + [where to store ccache files @<:@~/.ccache@:>@])]) 1.156 + 1.157 + if test "x$with_ccache_dir" != x; then 1.158 + # When using a non home ccache directory, assume the use is to share ccache files 1.159 + # with other users. Thus change the umask. 1.160 + SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002" 1.161 + fi 1.162 + CCACHE_FOUND="" 1.163 + if test "x$CCACHE" != x; then 1.164 + BPERF_SETUP_CCACHE_USAGE 1.165 + fi 1.166 +]) 1.167 + 1.168 +AC_DEFUN([BPERF_SETUP_CCACHE_USAGE], 1.169 +[ 1.170 + if test "x$CCACHE" != x; then 1.171 + CCACHE_FOUND="true" 1.172 + # Only use ccache if it is 3.1.4 or later, which supports 1.173 + # precompiled headers. 1.174 + AC_MSG_CHECKING([if ccache supports precompiled headers]) 1.175 + HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null` 1.176 + if test "x$HAS_GOOD_CCACHE" = x; then 1.177 + AC_MSG_RESULT([no, disabling ccache]) 1.178 + CCACHE= 1.179 + else 1.180 + AC_MSG_RESULT([yes]) 1.181 + AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers]) 1.182 + PUSHED_FLAGS="$CXXFLAGS" 1.183 + CXXFLAGS="-fpch-preprocess $CXXFLAGS" 1.184 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no]) 1.185 + CXXFLAGS="$PUSHED_FLAGS" 1.186 + if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then 1.187 + AC_MSG_RESULT([yes]) 1.188 + else 1.189 + AC_MSG_RESULT([no, disabling ccaching of precompiled headers]) 1.190 + CCACHE= 1.191 + fi 1.192 + fi 1.193 + fi 1.194 + 1.195 + if test "x$CCACHE" != x; then 1.196 + CCACHE_SLOPPINESS=time_macros 1.197 + CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE" 1.198 + CCACHE_FLAGS=-fpch-preprocess 1.199 + 1.200 + if test "x$SET_CCACHE_DIR" != x; then 1.201 + mkdir -p $CCACHE_DIR > /dev/null 2>&1 1.202 + chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1 1.203 + fi 1.204 + fi 1.205 +]) 1.206 + 1.207 +AC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS], 1.208 +[ 1.209 + 1.210 +############################################################################### 1.211 +# 1.212 +# Can the C/C++ compiler use precompiled headers? 1.213 +# 1.214 +AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers], 1.215 + [use precompiled headers when compiling C++ @<:@enabled@:>@])], 1.216 + [ENABLE_PRECOMPH=${enable_precompiled-headers}], [ENABLE_PRECOMPH=yes]) 1.217 + 1.218 +USE_PRECOMPILED_HEADER=1 1.219 +if test "x$ENABLE_PRECOMPH" = xno; then 1.220 + USE_PRECOMPILED_HEADER=0 1.221 +fi 1.222 + 1.223 +if test "x$ENABLE_PRECOMPH" = xyes; then 1.224 + # Check that the compiler actually supports precomp headers. 1.225 + if test "x$GCC" = xyes; then 1.226 + AC_MSG_CHECKING([that precompiled headers work]) 1.227 + echo "int alfa();" > conftest.h 1.228 + $CXX -x c++-header conftest.h -o conftest.hpp.gch 1.229 + if test ! -f conftest.hpp.gch; then 1.230 + echo Precompiled header is not working! 1.231 + USE_PRECOMPILED_HEADER=0 1.232 + AC_MSG_RESULT([no]) 1.233 + else 1.234 + AC_MSG_RESULT([yes]) 1.235 + fi 1.236 + rm -f conftest.h 1.237 + fi 1.238 +fi 1.239 + 1.240 +AC_SUBST(USE_PRECOMPILED_HEADER) 1.241 +]) 1.242 + 1.243 + 1.244 +AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC], 1.245 +[ 1.246 +AC_ARG_WITH(server-java, [AS_HELP_STRING([--with-server-java], 1.247 + [use this java binary for running the javac background server and other long running java tasks in the build process, 1.248 + e.g. ---with-server-java="/opt/jrockit/bin/java -server"])]) 1.249 + 1.250 +if test "x$with_server_java" != x; then 1.251 + SERVER_JAVA="$with_server_java" 1.252 + FOUND_VERSION=`$SERVER_JAVA -version 2>&1 | grep " version \""` 1.253 + if test "x$FOUND_VERSION" = x; then 1.254 + AC_MSG_ERROR([Could not execute server java: $SERVER_JAVA]) 1.255 + fi 1.256 +else 1.257 + SERVER_JAVA="" 1.258 + # Hotspot specific options. 1.259 + ADD_JVM_ARG_IF_OK([-XX:+UseParallelOldGC],SERVER_JAVA,[$JAVA]) 1.260 + ADD_JVM_ARG_IF_OK([-verbosegc],SERVER_JAVA,[$JAVA]) 1.261 + # JRockit specific options. 1.262 + ADD_JVM_ARG_IF_OK([-Xverbose:gc],SERVER_JAVA,[$JAVA]) 1.263 + SERVER_JAVA="$JAVA $SERVER_JAVA" 1.264 +fi 1.265 +AC_SUBST(SERVER_JAVA) 1.266 + 1.267 +AC_MSG_CHECKING([whether to use shared server for javac]) 1.268 +AC_ARG_ENABLE([javac-server], [AS_HELP_STRING([--enable-javac-server], 1.269 + [enable the shared javac server during the build process @<:@disabled@:>@])], 1.270 + [ENABLE_JAVAC_SERVER="${enableval}"], [ENABLE_JAVAC_SERVER='no']) 1.271 +AC_MSG_RESULT([$ENABLE_JAVAC_SERVER]) 1.272 +if test "x$ENABLE_JAVAC_SERVER" = xyes; then 1.273 + JAVAC_USE_REMOTE=true 1.274 + JAVAC_SERVERS="$OUTPUT_ROOT/javacservers" 1.275 +else 1.276 + JAVAC_USE_REMOTE=false 1.277 + JAVAC_SERVERS= 1.278 +fi 1.279 +AC_SUBST(JAVAC_USE_REMOTE) 1.280 +AC_SUBST(JAVAC_SERVERS) 1.281 + 1.282 +AC_ARG_WITH(javac-server-cores, [AS_HELP_STRING([--with-javac-server-cores], 1.283 + [use at most this number of concurrent threads on the javac server @<:@probed@:>@])]) 1.284 +if test "x$with_javac_server_cores" != x; then 1.285 + JAVAC_SERVER_CORES="$with_javac_server_cores" 1.286 +else 1.287 + if test "$NUM_CORES" -gt 16; then 1.288 + # We set this arbitrary limit because we want to limit the heap 1.289 + # size of the javac server. 1.290 + # In the future we will make the javac compilers in the server 1.291 + # share more and more state, thus enabling us to use more and 1.292 + # more concurrent threads in the server. 1.293 + JAVAC_SERVER_CORES="16" 1.294 + else 1.295 + JAVAC_SERVER_CORES="$NUM_CORES" 1.296 + fi 1.297 + 1.298 + if test "$MEMORY_SIZE" -gt "17000"; then 1.299 + MAX_HEAP_MEM=10000 1.300 + ADD_JVM_ARG_IF_OK([-d64],SERVER_JAVA,[$SERVER_JAVA]) 1.301 + ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SERVER_JAVA,[$SERVER_JAVA]) 1.302 + ADD_JVM_ARG_IF_OK([-Xmn2G],SERVER_JAVA,[$SERVER_JAVA]) 1.303 + elif test "$MEMORY_SIZE" -gt "10000"; then 1.304 + MAX_HEAP_MEM=6000 1.305 + ADD_JVM_ARG_IF_OK([-d64],SERVER_JAVA,[$SERVER_JAVA]) 1.306 + ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SERVER_JAVA,[$SERVER_JAVA]) 1.307 + ADD_JVM_ARG_IF_OK([-Xmn1G],SERVER_JAVA,[$SERVER_JAVA]) 1.308 + elif test "$MEMORY_SIZE" -gt "5000"; then 1.309 + MAX_HEAP_MEM=3000 1.310 + ADD_JVM_ARG_IF_OK([-d64],SERVER_JAVA,[$SERVER_JAVA]) 1.311 + ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SERVER_JAVA,[$SERVER_JAVA]) 1.312 + ADD_JVM_ARG_IF_OK([-Xmn256M],SERVER_JAVA,[$SERVER_JAVA]) 1.313 + elif test "$MEMORY_SIZE" -gt "3800"; then 1.314 + MAX_HEAP_MEM=2500 1.315 + ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SERVER_JAVA,[$SERVER_JAVA]) 1.316 + ADD_JVM_ARG_IF_OK([-Xmn256M],SERVER_JAVA,[$SERVER_JAVA]) 1.317 + elif test "$MEMORY_SIZE" -gt "1900"; then 1.318 + MAX_HEAP_MEM=1200 1.319 + ADD_JVM_ARG_IF_OK([-Xms700M -Xmx1200M],SERVER_JAVA,[$SERVER_JAVA]) 1.320 + ADD_JVM_ARG_IF_OK([-Xmn256M],SERVER_JAVA,[$SERVER_JAVA]) 1.321 + elif test "$MEMORY_SIZE" -gt "1000"; then 1.322 + MAX_HEAP_MEM=900 1.323 + ADD_JVM_ARG_IF_OK([-Xms400M -Xmx900M],SERVER_JAVA,[$SERVER_JAVA]) 1.324 + ADD_JVM_ARG_IF_OK([-Xmn128M],SERVER_JAVA,[$SERVER_JAVA]) 1.325 + else 1.326 + MAX_HEAP_MEM=512 1.327 + ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SERVER_JAVA,[$SERVER_JAVA]) 1.328 + ADD_JVM_ARG_IF_OK([-Xmn128M],SERVER_JAVA,[$SERVER_JAVA]) 1.329 + fi 1.330 + 1.331 + MAX_COMPILERS_IN_HEAP=`expr $MAX_HEAP_MEM / 501` 1.332 + if test "$JAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then 1.333 + AC_MSG_CHECKING([if number of server cores must be reduced]) 1.334 + JAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP" 1.335 + AC_MSG_RESULT([yes, to $JAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB]) 1.336 + fi 1.337 +fi 1.338 +AC_SUBST(JAVAC_SERVER_CORES) 1.339 + 1.340 +AC_MSG_CHECKING([whether to track dependencies between Java packages]) 1.341 +AC_ARG_ENABLE([javac-deps], [AS_HELP_STRING([--enable-javac-deps], 1.342 + [enable the dependency tracking between Java packages @<:@disabled@:>@])], 1.343 + [ENABLE_JAVAC_DEPS="${enableval}"], [ENABLE_JAVAC_DEPS='no']) 1.344 +AC_MSG_RESULT([$ENABLE_JAVAC_DEPS]) 1.345 +if test "x$ENABLE_JAVAC_DEPS" = xyes; then 1.346 + JAVAC_USE_DEPS=true 1.347 +else 1.348 + JAVAC_USE_DEPS=false 1.349 +fi 1.350 +AC_SUBST(JAVAC_USE_DEPS) 1.351 + 1.352 +AC_MSG_CHECKING([whether to use multiple cores for javac compilation]) 1.353 +AC_ARG_ENABLE([javac-multi-core], [AS_HELP_STRING([--enable-javac-multi-core], 1.354 + [compile Java packages concurrently @<:@disabled@:>@])], 1.355 + [ENABLE_JAVAC_MULTICORE="${enableval}"], [ENABLE_JAVAC_MULTICORE='no']) 1.356 +AC_MSG_RESULT([$ENABLE_JAVAC_MULTICORE]) 1.357 +if test "x$ENABLE_JAVAC_MULTICORE" = xyes; then 1.358 + JAVAC_USE_MODE=MULTI_CORE_CONCURRENT 1.359 +else 1.360 + JAVAC_USE_MODE=SINGLE_THREADED_BATCH 1.361 + if test "x$ENABLE_JAVAC_DEPS" = xyes; then 1.362 + AC_MSG_WARN([Dependency tracking is not supported with single threaded batch compiles of Java source roots. Please add --disable-javac-deps to your configure options.]) 1.363 + AC_MSG_WARN([Disabling dependency tracking for you now.]) 1.364 + JAVAC_USE_DEPS=false 1.365 + fi 1.366 + if test "x$ENABLE_JAVAC_SERVER" = xyes; then 1.367 + AC_MSG_WARN([The javac server will not be used since single threaded batch compiles are run within their own JVM. Please add --disable-javac-server to your configure options.]) 1.368 + AC_MSG_WARN([Disabling javac server for you now.]) 1.369 + JAVAC_USE_REMOTE=false 1.370 + fi 1.371 +fi 1.372 +AC_SUBST(JAVAC_USE_MODE) 1.373 + 1.374 +AC_MSG_CHECKING([whether to use sjavac]) 1.375 +AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac], 1.376 + [use sjavac to do fast incremental compiles @<:@disabled@:>@])], 1.377 + [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no']) 1.378 +AC_MSG_RESULT([$ENABLE_SJAVAC]) 1.379 +AC_SUBST(ENABLE_SJAVAC) 1.380 + 1.381 +])