1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/common/autoconf/build-performance.m4 Wed Apr 27 01:39:08 2016 +0800 1.3 @@ -0,0 +1,336 @@ 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 (or cygwin) system 1.37 + NUM_CORES=`cat /proc/cpuinfo | grep -c processor` 1.38 + FOUND_CORES=yes 1.39 + elif test -x /usr/sbin/psrinfo; then 1.40 + # Looks like a Solaris system 1.41 + NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line` 1.42 + FOUND_CORES=yes 1.43 + elif test -x /usr/sbin/system_profiler; then 1.44 + # Looks like a MacOSX system 1.45 + NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk '{print [$]5}'` 1.46 + FOUND_CORES=yes 1.47 + elif test "x$OPENJDK_BUILD_OS" = xaix ; then 1.48 + NUM_CORES=`/usr/sbin/prtconf | grep "^Number Of Processors" | awk '{ print [$]4 }'` 1.49 + FOUND_CORES=yes 1.50 + elif test -n "$NUMBER_OF_PROCESSORS"; then 1.51 + # On windows, look in the env 1.52 + NUM_CORES=$NUMBER_OF_PROCESSORS 1.53 + FOUND_CORES=yes 1.54 + fi 1.55 + 1.56 + if test "x$FOUND_CORES" = xyes; then 1.57 + AC_MSG_RESULT([$NUM_CORES]) 1.58 + else 1.59 + AC_MSG_RESULT([could not detect number of cores, defaulting to 1]) 1.60 + AC_MSG_WARN([This will disable all parallelism from build!]) 1.61 + fi 1.62 +]) 1.63 + 1.64 +AC_DEFUN([BPERF_CHECK_MEMORY_SIZE], 1.65 +[ 1.66 + AC_MSG_CHECKING([for memory size]) 1.67 + # Default to 1024 MB 1.68 + MEMORY_SIZE=1024 1.69 + FOUND_MEM=no 1.70 + 1.71 + if test -f /proc/meminfo; then 1.72 + # Looks like a Linux (or cygwin) system 1.73 + MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'` 1.74 + MEMORY_SIZE=`expr $MEMORY_SIZE / 1024` 1.75 + FOUND_MEM=yes 1.76 + elif test -x /usr/sbin/prtconf; then 1.77 + # Looks like a Solaris or AIX system 1.78 + MEMORY_SIZE=`/usr/sbin/prtconf | grep "^Memory [[Ss]]ize" | awk '{ print [$]3 }'` 1.79 + FOUND_MEM=yes 1.80 + elif test -x /usr/sbin/system_profiler; then 1.81 + # Looks like a MacOSX system 1.82 + MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk '{print [$]2}'` 1.83 + MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024` 1.84 + FOUND_MEM=yes 1.85 + elif test "x$OPENJDK_BUILD_OS" = xwindows; then 1.86 + # Windows, but without cygwin 1.87 + MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-` 1.88 + MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024` 1.89 + FOUND_MEM=yes 1.90 + fi 1.91 + 1.92 + if test "x$FOUND_MEM" = xyes; then 1.93 + AC_MSG_RESULT([$MEMORY_SIZE MB]) 1.94 + else 1.95 + AC_MSG_RESULT([could not detect memory size, defaulting to 1024 MB]) 1.96 + AC_MSG_WARN([This might seriously impact build performance!]) 1.97 + fi 1.98 +]) 1.99 + 1.100 +AC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES], 1.101 +[ 1.102 + # How many cores do we have on this build system? 1.103 + AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores], 1.104 + [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])]) 1.105 + if test "x$with_num_cores" = x; then 1.106 + # The number of cores were not specified, try to probe them. 1.107 + BPERF_CHECK_CORES 1.108 + else 1.109 + NUM_CORES=$with_num_cores 1.110 + fi 1.111 + AC_SUBST(NUM_CORES) 1.112 +]) 1.113 + 1.114 +AC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY], 1.115 +[ 1.116 + # How much memory do we have on this build system? 1.117 + AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size], 1.118 + [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])]) 1.119 + if test "x$with_memory_size" = x; then 1.120 + # The memory size was not specified, try to probe it. 1.121 + BPERF_CHECK_MEMORY_SIZE 1.122 + else 1.123 + MEMORY_SIZE=$with_memory_size 1.124 + fi 1.125 + AC_SUBST(MEMORY_SIZE) 1.126 +]) 1.127 + 1.128 +AC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS], 1.129 +[ 1.130 + # Provide a decent default number of parallel jobs for make depending on 1.131 + # number of cores, amount of memory and machine architecture. 1.132 + AC_ARG_WITH(jobs, [AS_HELP_STRING([--with-jobs], 1.133 + [number of parallel jobs to let make run @<:@calculated based on cores and memory@:>@])]) 1.134 + if test "x$with_jobs" = x; then 1.135 + # Number of jobs was not specified, calculate. 1.136 + AC_MSG_CHECKING([for appropriate number of jobs to run in parallel]) 1.137 + # Approximate memory in GB, rounding up a bit. 1.138 + memory_gb=`expr $MEMORY_SIZE / 1100` 1.139 + # Pick the lowest of memory in gb and number of cores. 1.140 + if test "$memory_gb" -lt "$NUM_CORES"; then 1.141 + JOBS="$memory_gb" 1.142 + else 1.143 + JOBS="$NUM_CORES" 1.144 + # On bigger machines, leave some room for other processes to run 1.145 + if test "$JOBS" -gt "4"; then 1.146 + JOBS=`expr $JOBS '*' 90 / 100` 1.147 + fi 1.148 + fi 1.149 + # Cap number of jobs to 16 1.150 + if test "$JOBS" -gt "16"; then 1.151 + JOBS=16 1.152 + fi 1.153 + if test "$JOBS" -eq "0"; then 1.154 + JOBS=1 1.155 + fi 1.156 + AC_MSG_RESULT([$JOBS]) 1.157 + else 1.158 + JOBS=$with_jobs 1.159 + fi 1.160 + AC_SUBST(JOBS) 1.161 +]) 1.162 + 1.163 +AC_DEFUN([BPERF_SETUP_CCACHE], 1.164 +[ 1.165 + AC_ARG_ENABLE([ccache], 1.166 + [AS_HELP_STRING([--disable-ccache], 1.167 + [disable using ccache to speed up recompilations @<:@enabled@:>@])], 1.168 + [ENABLE_CCACHE=${enable_ccache}], [ENABLE_CCACHE=yes]) 1.169 + if test "x$ENABLE_CCACHE" = xyes; then 1.170 + OLD_PATH="$PATH" 1.171 + if test "x$TOOLS_DIR" != x; then 1.172 + PATH=$TOOLS_DIR:$PATH 1.173 + fi 1.174 + AC_PATH_PROG(CCACHE, ccache) 1.175 + PATH="$OLD_PATH" 1.176 + else 1.177 + AC_MSG_CHECKING([for ccache]) 1.178 + AC_MSG_RESULT([explicitly disabled]) 1.179 + CCACHE= 1.180 + fi 1.181 + AC_SUBST(CCACHE) 1.182 + 1.183 + AC_ARG_WITH([ccache-dir], 1.184 + [AS_HELP_STRING([--with-ccache-dir], 1.185 + [where to store ccache files @<:@~/.ccache@:>@])]) 1.186 + 1.187 + if test "x$with_ccache_dir" != x; then 1.188 + # When using a non home ccache directory, assume the use is to share ccache files 1.189 + # with other users. Thus change the umask. 1.190 + SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002" 1.191 + fi 1.192 + CCACHE_FOUND="" 1.193 + if test "x$CCACHE" != x; then 1.194 + BPERF_SETUP_CCACHE_USAGE 1.195 + fi 1.196 +]) 1.197 + 1.198 +AC_DEFUN([BPERF_SETUP_CCACHE_USAGE], 1.199 +[ 1.200 + if test "x$CCACHE" != x; then 1.201 + CCACHE_FOUND="true" 1.202 + # Only use ccache if it is 3.1.4 or later, which supports 1.203 + # precompiled headers. 1.204 + AC_MSG_CHECKING([if ccache supports precompiled headers]) 1.205 + HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null` 1.206 + if test "x$HAS_GOOD_CCACHE" = x; then 1.207 + AC_MSG_RESULT([no, disabling ccache]) 1.208 + CCACHE= 1.209 + else 1.210 + AC_MSG_RESULT([yes]) 1.211 + AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers]) 1.212 + PUSHED_FLAGS="$CXXFLAGS" 1.213 + CXXFLAGS="-fpch-preprocess $CXXFLAGS" 1.214 + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no]) 1.215 + CXXFLAGS="$PUSHED_FLAGS" 1.216 + if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then 1.217 + AC_MSG_RESULT([yes]) 1.218 + else 1.219 + AC_MSG_RESULT([no, disabling ccaching of precompiled headers]) 1.220 + CCACHE= 1.221 + fi 1.222 + fi 1.223 + fi 1.224 + 1.225 + if test "x$CCACHE" != x; then 1.226 + CCACHE_SLOPPINESS=time_macros 1.227 + CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE" 1.228 + CCACHE_FLAGS=-fpch-preprocess 1.229 + 1.230 + if test "x$SET_CCACHE_DIR" != x; then 1.231 + mkdir -p $CCACHE_DIR > /dev/null 2>&1 1.232 + chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1 1.233 + fi 1.234 + fi 1.235 +]) 1.236 + 1.237 +AC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS], 1.238 +[ 1.239 + 1.240 + ############################################################################### 1.241 + # 1.242 + # Can the C/C++ compiler use precompiled headers? 1.243 + # 1.244 + AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers], 1.245 + [disable using precompiled headers when compiling C++ @<:@enabled@:>@])], 1.246 + [ENABLE_PRECOMPH=${enable_precompiled_headers}], [ENABLE_PRECOMPH=yes]) 1.247 + 1.248 + USE_PRECOMPILED_HEADER=1 1.249 + if test "x$ENABLE_PRECOMPH" = xno; then 1.250 + USE_PRECOMPILED_HEADER=0 1.251 + fi 1.252 + 1.253 + if test "x$ENABLE_PRECOMPH" = xyes; then 1.254 + # Check that the compiler actually supports precomp headers. 1.255 + if test "x$GCC" = xyes; then 1.256 + AC_MSG_CHECKING([that precompiled headers work]) 1.257 + echo "int alfa();" > conftest.h 1.258 + $CXX -x c++-header conftest.h -o conftest.hpp.gch 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD 1.259 + if test ! -f conftest.hpp.gch; then 1.260 + USE_PRECOMPILED_HEADER=0 1.261 + AC_MSG_RESULT([no]) 1.262 + else 1.263 + AC_MSG_RESULT([yes]) 1.264 + fi 1.265 + rm -f conftest.h conftest.hpp.gch 1.266 + fi 1.267 + fi 1.268 + 1.269 + AC_SUBST(USE_PRECOMPILED_HEADER) 1.270 +]) 1.271 + 1.272 + 1.273 +AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC], 1.274 +[ 1.275 + AC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java], 1.276 + [use this java binary for running the sjavac background server @<:@Boot JDK java@:>@])]) 1.277 + 1.278 + if test "x$with_sjavac_server_java" != x; then 1.279 + SJAVAC_SERVER_JAVA="$with_sjavac_server_java" 1.280 + FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""` 1.281 + if test "x$FOUND_VERSION" = x; then 1.282 + AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA]) 1.283 + fi 1.284 + else 1.285 + SJAVAC_SERVER_JAVA="" 1.286 + # Hotspot specific options. 1.287 + ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA]) 1.288 + # JRockit specific options. 1.289 + ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA]) 1.290 + SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA" 1.291 + fi 1.292 + AC_SUBST(SJAVAC_SERVER_JAVA) 1.293 + 1.294 + if test "$MEMORY_SIZE" -gt "2500"; then 1.295 + ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 1.296 + if test "$JVM_ARG_OK" = true; then 1.297 + JVM_64BIT=true 1.298 + JVM_ARG_OK=false 1.299 + fi 1.300 + fi 1.301 + 1.302 + if test "$JVM_64BIT" = true; then 1.303 + if test "$MEMORY_SIZE" -gt "17000"; then 1.304 + ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 1.305 + fi 1.306 + if test "$MEMORY_SIZE" -gt "10000" && test "$JVM_ARG_OK" = false; then 1.307 + ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 1.308 + fi 1.309 + if test "$MEMORY_SIZE" -gt "5000" && test "$JVM_ARG_OK" = false; then 1.310 + ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 1.311 + fi 1.312 + if test "$MEMORY_SIZE" -gt "3800" && test "$JVM_ARG_OK" = false; then 1.313 + ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 1.314 + fi 1.315 + fi 1.316 + if test "$MEMORY_SIZE" -gt "2500" && test "$JVM_ARG_OK" = false; then 1.317 + ADD_JVM_ARG_IF_OK([-Xms1000M -Xmx1500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 1.318 + fi 1.319 + if test "$MEMORY_SIZE" -gt "1000" && test "$JVM_ARG_OK" = false; then 1.320 + ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 1.321 + fi 1.322 + if test "$JVM_ARG_OK" = false; then 1.323 + ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 1.324 + fi 1.325 + 1.326 + AC_MSG_CHECKING([whether to use sjavac]) 1.327 + AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac], 1.328 + [use sjavac to do fast incremental compiles @<:@disabled@:>@])], 1.329 + [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no']) 1.330 + AC_MSG_RESULT([$ENABLE_SJAVAC]) 1.331 + AC_SUBST(ENABLE_SJAVAC) 1.332 + 1.333 + if test "x$ENABLE_SJAVAC" = xyes; then 1.334 + SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers" 1.335 + else 1.336 + SJAVAC_SERVER_DIR= 1.337 + fi 1.338 + AC_SUBST(SJAVAC_SERVER_DIR) 1.339 +])