build-performance.m4 revision 476:2ba6f4da4bf3
1167857Simp# 2167857Simp# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 3167857Simp# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4167857Simp# 5167857Simp# This code is free software; you can redistribute it and/or modify it 6167857Simp# under the terms of the GNU General Public License version 2 only, as 7167857Simp# published by the Free Software Foundation. Oracle designates this 8167857Simp# particular file as subject to the "Classpath" exception as provided 9167857Simp# by Oracle in the LICENSE file that accompanied this code. 10167857Simp# 11167857Simp# This code is distributed in the hope that it will be useful, but WITHOUT 12167857Simp# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13167857Simp# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14167857Simp# version 2 for more details (a copy is included in the LICENSE file that 15167857Simp# accompanied this code). 16167857Simp# 17167857Simp# You should have received a copy of the GNU General Public License version 18167857Simp# 2 along with this work; if not, write to the Free Software Foundation, 19167857Simp# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20167857Simp# 21167857Simp# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22167857Simp# or visit www.oracle.com if you need additional information or have any 23167857Simp# questions. 24167857Simp# 25167857Simp 26167857SimpAC_DEFUN([BPERF_CHECK_CORES], 27167857Simp[ 28167857Simp AC_MSG_CHECKING([for number of cores]) 29167857Simp NUM_CORES=1 30289727Sian FOUND_CORES=no 31289727Sian 32289727Sian if test -f /proc/cpuinfo; then 33167857Simp # Looks like a Linux (or cygwin) system 34167857Simp NUM_CORES=`cat /proc/cpuinfo | grep -c processor` 35167857Simp FOUND_CORES=yes 36167857Simp elif test -x /usr/sbin/psrinfo; then 37167857Simp # Looks like a Solaris system 38167857Simp NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line` 39167857Simp FOUND_CORES=yes 40181305Sjhb elif test -x /usr/sbin/system_profiler; then 41346548Sian # Looks like a MacOSX system 42167857Simp NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk '{print [$]5}'` 43167857Simp FOUND_CORES=yes 44289727Sian fi 45289727Sian 46289727Sian # For c/c++ code we run twice as many concurrent build 47289727Sian # jobs than we have cores, otherwise we will stall on io. 48289727Sian CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` 49289727Sian 50167857Simp if test "x$FOUND_CORES" = xyes; then 51167857Simp AC_MSG_RESULT([$NUM_CORES]) 52167857Simp else 53167857Simp AC_MSG_RESULT([could not detect number of cores, defaulting to 1!]) 54167857Simp fi 55289727Sian 56289727Sian]) 57289727Sian 58289727SianAC_DEFUN([BPERF_CHECK_MEMORY_SIZE], 59289727Sian[ 60289727Sian AC_MSG_CHECKING([for memory size]) 61167857Simp # Default to 1024 MB 62289727Sian MEMORY_SIZE=1024 63167857Simp FOUND_MEM=no 64167857Simp 65289727Sian if test -f /proc/meminfo; then 66167857Simp # Looks like a Linux (or cygwin) system 67289727Sian MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'` 68167857Simp MEMORY_SIZE=`expr $MEMORY_SIZE / 1024` 69289727Sian FOUND_MEM=yes 70167857Simp elif test -x /usr/sbin/prtconf; then 71167857Simp # Looks like a Solaris system 72167857Simp MEMORY_SIZE=`/usr/sbin/prtconf | grep "Memory size" | awk '{ print [$]3 }'` 73289727Sian FOUND_MEM=yes 74289727Sian elif test -x /usr/sbin/system_profiler; then 75289727Sian # Looks like a MacOSX system 76289727Sian MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk '{print [$]2}'` 77289727Sian MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024` 78289727Sian FOUND_MEM=yes 79289727Sian elif test "x$build_os" = xwindows; then 80289727Sian # Windows, but without cygwin 81289727Sian MEMORY_SIZE=`systeminfo | grep 'Total Physical Memory:' | awk '{ print [$]4 }' | sed 's/,//'` 82289727Sian FOUND_MEM=yes 83289727Sian fi 84289727Sian 85289727Sian if test "x$FOUND_MEM" = xyes; then 86289727Sian AC_MSG_RESULT([$MEMORY_SIZE MB]) 87289727Sian else 88289727Sian AC_MSG_RESULT([could not detect memory size defaulting to 1024 MB!]) 89289727Sian fi 90289727Sian]) 91289727Sian 92289727SianAC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES], 93289727Sian[ 94289727Sian# How many cores do we have on this build system? 95289727SianAC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores], 96289727Sian [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])]) 97289727Sianif test "x$with_num_cores" = x; then 98289727Sian # The number of cores were not specified, try to probe them. 99289727Sian BPERF_CHECK_CORES 100289727Sianelse 101289727Sian NUM_CORES=$with_num_cores 102289727Sian CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` 103289727Sianfi 104289727SianAC_SUBST(NUM_CORES) 105289727SianAC_SUBST(CONCURRENT_BUILD_JOBS) 106289727Sian]) 107289727Sian 108289727SianAC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY], 109289727Sian[ 110289727Sian# How much memory do we have on this build system? 111167857SimpAC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size], 112167857Simp [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])]) 113167857Simpif test "x$with_memory_size" = x; then 114167857Simp # The memory size was not specified, try to probe it. 115167857Simp BPERF_CHECK_MEMORY_SIZE 116167857Simpelse 117167857Simp MEMORY_SIZE=$with_memory_size 118167857Simpfi 119167857SimpAC_SUBST(MEMORY_SIZE) 120167857Simp]) 121167857Simp 122181305SjhbAC_DEFUN([BPERF_SETUP_CCACHE], 123167857Simp[ 124167857Simp AC_ARG_ENABLE([ccache], 125167857Simp [AS_HELP_STRING([--disable-ccache], 126167857Simp [use ccache to speed up recompilations @<:@enabled@:>@])], 127167857Simp [ENABLE_CCACHE=${enable_ccache}], [ENABLE_CCACHE=yes]) 128167857Simp if test "x$ENABLE_CCACHE" = xyes; then 129289727Sian AC_PATH_PROG(CCACHE, ccache) 130167857Simp else 131167857Simp AC_MSG_CHECKING([for ccache]) 132167857Simp AC_MSG_RESULT([explicitly disabled]) 133289727Sian CCACHE= 134289083Sian fi 135289727Sian AC_SUBST(CCACHE) 136289727Sian 137289727Sian AC_ARG_WITH([ccache-dir], 138289727Sian [AS_HELP_STRING([--with-ccache-dir], 139289727Sian [where to store ccache files @<:@~/.ccache@:>@])]) 140289727Sian 141289727Sian if test "x$with_ccache_dir" != x; then 142289727Sian # When using a non home ccache directory, assume the use is to share ccache files 143289727Sian # with other users. Thus change the umask. 144289727Sian SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002" 145289727Sian fi 146289727Sian CCACHE_FOUND="" 147289727Sian if test "x$CCACHE" != x; then 148289727Sian BPERF_SETUP_CCACHE_USAGE 149289727Sian fi 150289727Sian]) 151289727Sian 152289727SianAC_DEFUN([BPERF_SETUP_CCACHE_USAGE], 153289727Sian[ 154289727Sian if test "x$CCACHE" != x; then 155289727Sian CCACHE_FOUND="true" 156289727Sian # Only use ccache if it is 3.1.4 or later, which supports 157289727Sian # precompiled headers. 158289727Sian AC_MSG_CHECKING([if ccache supports precompiled headers]) 159289727Sian HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null` 160289727Sian if test "x$HAS_GOOD_CCACHE" = x; then 161289727Sian AC_MSG_RESULT([no, disabling ccache]) 162289727Sian CCACHE= 163289727Sian else 164289727Sian AC_MSG_RESULT([yes]) 165289727Sian AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers]) 166167857Simp PUSHED_FLAGS="$CXXFLAGS" 167186833Snwhitehorn CXXFLAGS="-fpch-preprocess $CXXFLAGS" 168167857Simp AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no]) 169167857Simp CXXFLAGS="$PUSHED_FLAGS" 170289727Sian if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then 171289727Sian AC_MSG_RESULT([yes]) 172289727Sian else 173289727Sian AC_MSG_RESULT([no, disabling ccaching of precompiled headers]) 174289727Sian CCACHE= 175289727Sian fi 176289727Sian fi 177289727Sian fi 178289727Sian 179289727Sian if test "x$CCACHE" != x; then 180289727Sian CCACHE_SLOPPINESS=time_macros 181289727Sian CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE" 182289727Sian CCACHE_FLAGS=-fpch-preprocess 183289727Sian 184167857Simp if test "x$SET_CCACHE_DIR" != x; then 185167857Simp mkdir -p $CCACHE_DIR > /dev/null 2>&1 186167857Simp chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1 187167857Simp fi 188346548Sian fi 189346548Sian]) 190167857Simp 191289727SianAC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS], 192181325Sstas[ 193289727Sian 194289727Sian############################################################################### 195289727Sian# 196289727Sian# Can the C/C++ compiler use precompiled headers? 197289727Sian# 198289727SianAC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers], 199289727Sian [use precompiled headers when compiling C++ @<:@enabled@:>@])], 200167857Simp [ENABLE_PRECOMPH=${enable_precompiled-headers}], [ENABLE_PRECOMPH=yes]) 201289727Sian 202167857SimpUSE_PRECOMPILED_HEADER=1 203167857Simpif test "x$ENABLE_PRECOMPH" = xno; then 204167857Simp USE_PRECOMPILED_HEADER=0 205167857Simpfi 206289727Sian 207167857Simpif test "x$ENABLE_PRECOMPH" = xyes; then 208167857Simp # Check that the compiler actually supports precomp headers. 209346548Sian if test "x$GCC" = xyes; then 210346548Sian AC_MSG_CHECKING([that precompiled headers work]) 211346548Sian echo "int alfa();" > conftest.h 212346548Sian $CXX -x c++-header conftest.h -o conftest.hpp.gch 213346548Sian if test ! -f conftest.hpp.gch; then 214346548Sian echo Precompiled header is not working! 215346548Sian USE_PRECOMPILED_HEADER=0 216346548Sian AC_MSG_RESULT([no]) 217346548Sian else 218346548Sian AC_MSG_RESULT([yes]) 219289727Sian fi 220167857Simp rm -f conftest.h 221167857Simp fi 222323931Sianfi 223323931Sian 224323931SianAC_SUBST(USE_PRECOMPILED_HEADER) 225323931Sian]) 226323931Sian 227323931Sian 228323931SianAC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC], 229323931Sian[ 230323931SianAC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java], 231167857Simp [use this java binary for running the sjavac background server and other long running java tasks in the build process, 232167857Simp e.g. ---with-sjavac-server-java="/opt/jrockit/bin/java -server"])]) 233167857Simp 234323931Sianif test "x$with_sjavac_server_java" != x; then 235167857Simp SJAVAC_SERVER_JAVA="$with_sjavac_server_java" 236323931Sian FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""` 237323931Sian if test "x$FOUND_VERSION" = x; then 238323931Sian AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA]) 239323931Sian fi 240289083Sianelse 241167857Simp SJAVAC_SERVER_JAVA="" 242167857Simp # Hotspot specific options. 243167857Simp ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA]) 244167857Simp # JRockit specific options. 245167857Simp ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA]) 246323931Sian SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA" 247167857Simpfi 248323931SianAC_SUBST(SJAVAC_SERVER_JAVA) 249323931Sian 250167857SimpAC_ARG_WITH(sjavac-server-cores, [AS_HELP_STRING([--with-sjavac-server-cores], 251167857Simp [use at most this number of concurrent threads on the sjavac server @<:@probed@:>@])]) 252167857Simpif test "x$with_sjavac_server_cores" != x; then 253167857Simp SJAVAC_SERVER_CORES="$with_sjavac_server_cores" 254167857Simpelse 255167857Simp if test "$NUM_CORES" -gt 16; then 256167857Simp # We set this arbitrary limit because we want to limit the heap 257167857Simp # size of the javac server. 258167857Simp # In the future we will make the javac compilers in the server 259167857Simp # share more and more state, thus enabling us to use more and 260167857Simp # more concurrent threads in the server. 261167857Simp SJAVAC_SERVER_CORES="16" 262167857Simp else 263167857Simp SJAVAC_SERVER_CORES="$NUM_CORES" 264167857Simp fi 265167857Simp 266167857Simp if test "$MEMORY_SIZE" -gt "17000"; then 267167857Simp MAX_HEAP_MEM=10000 268167857Simp ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 269167857Simp ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 270167857Simp elif test "$MEMORY_SIZE" -gt "10000"; then 271167857Simp MAX_HEAP_MEM=6000 272167857Simp ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 273167857Simp ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 274167857Simp elif test "$MEMORY_SIZE" -gt "5000"; then 275167857Simp MAX_HEAP_MEM=3000 276289727Sian ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 277167857Simp ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 278167857Simp elif test "$MEMORY_SIZE" -gt "3800"; then 279167857Simp MAX_HEAP_MEM=2500 280167857Simp ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 281167857Simp elif test "$MEMORY_SIZE" -gt "1900"; then 282167857Simp MAX_HEAP_MEM=1200 283167857Simp ADD_JVM_ARG_IF_OK([-Xms700M -Xmx1400M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 284167857Simp elif test "$MEMORY_SIZE" -gt "1000"; then 285167857Simp MAX_HEAP_MEM=900 286167857Simp ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 287167857Simp else 288167857Simp MAX_HEAP_MEM=512 289167857Simp ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 290167857Simp fi 291167857Simp 292167857Simp ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 293167857Simp ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 294167857Simp ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 295289727Sian 296289105Sian MAX_COMPILERS_IN_HEAP=`expr $MAX_HEAP_MEM / 501` 297289105Sian if test "$SJAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then 298167857Simp AC_MSG_CHECKING([if number of server cores must be reduced]) 299289105Sian SJAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP" 300167857Simp AC_MSG_RESULT([yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB]) 301167857Simp fi 302167857Simpfi 303167857SimpAC_SUBST(SJAVAC_SERVER_CORES) 304167857Simp 305167857SimpAC_MSG_CHECKING([whether to use sjavac]) 306167857SimpAC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac], 307167857Simp [use sjavac to do fast incremental compiles @<:@disabled@:>@])], 308167857Simp [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no']) 309167857SimpAC_MSG_RESULT([$ENABLE_SJAVAC]) 310167857SimpAC_SUBST(ENABLE_SJAVAC) 311167857Simp 312167857Simpif test "x$ENABLE_SJAVAC" = xyes; then 313167857Simp SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers" 314167857Simpelse 315167857Simp SJAVAC_SERVER_DIR= 316167857Simpfi 317167857SimpAC_SUBST(SJAVAC_SERVER_DIR) 318167857Simp 319167857Simp]) 320167857Simp