build-performance.m4 revision 492:e64f2cb57d05
172878Skris# 272878Skris# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 3100772Sjhb# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4100772Sjhb# 5100772Sjhb# This code is free software; you can redistribute it and/or modify it 672878Skris# under the terms of the GNU General Public License version 2 only, as 7100772Sjhb# published by the Free Software Foundation. Oracle designates this 872878Skris# particular file as subject to the "Classpath" exception as provided 9100772Sjhb# by Oracle in the LICENSE file that accompanied this code. 10100772Sjhb# 1172878Skris# This code is distributed in the hope that it will be useful, but WITHOUT 12100772Sjhb# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13100772Sjhb# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1472878Skris# version 2 for more details (a copy is included in the LICENSE file that 15100772Sjhb# accompanied this code). 16100772Sjhb# 1796312Sobrien# You should have received a copy of the GNU General Public License version 18100772Sjhb# 2 along with this work; if not, write to the Free Software Foundation, 19100772Sjhb# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2072878Skris# 21100772Sjhb# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2272878Skris# or visit www.oracle.com if you need additional information or have any 2372878Skris# questions. 2472878Skris# 2572878Skris 2672878SkrisAC_DEFUN([BPERF_CHECK_CORES], 2772878Skris[ 2872878Skris AC_MSG_CHECKING([for number of cores]) 2972878Skris NUM_CORES=1 3072878Skris FOUND_CORES=no 3172878Skris 3296421Sobrien if test -f /proc/cpuinfo; then 3372878Skris # Looks like a Linux (or cygwin) system 3472878Skris NUM_CORES=`cat /proc/cpuinfo | grep -c processor` 3572878Skris FOUND_CORES=yes 3696421Sobrien elif test -x /usr/sbin/psrinfo; then 3772878Skris # Looks like a Solaris system 3896421Sobrien NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line` 3996421Sobrien FOUND_CORES=yes 4096421Sobrien elif test -x /usr/sbin/system_profiler; then 4196421Sobrien # Looks like a MacOSX system 4296421Sobrien NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk '{print [$]5}'` 4372878Skris FOUND_CORES=yes 4474146Skris elif test -n "$NUMBER_OF_PROCESSORS"; then 4572878Skris # On windows, look in the env 4696421Sobrien NUM_CORES=$NUMBER_OF_PROCESSORS 4797661Sru FOUND_CORES=yes 4897661Sru fi 4997661Sru 5096419Sobrien # For c/c++ code we run twice as many concurrent build 5197661Sru # jobs than we have cores, otherwise we will stall on io. 5273145Skris CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` 5374146Skris 5472878Skris if test "x$FOUND_CORES" = xyes; then 5574146Skris AC_MSG_RESULT([$NUM_CORES]) 5672878Skris else 5774146Skris AC_MSG_RESULT([could not detect number of cores, defaulting to 1]) 5873145Skris AC_MSG_WARN([This will disable all parallelism from build!]) 5974146Skris fi 6073145Skris 6174146Skris]) 6273145Skris 6374146SkrisAC_DEFUN([BPERF_CHECK_MEMORY_SIZE], 6472878Skris[ 6574146Skris AC_MSG_CHECKING([for memory size]) 6673145Skris # Default to 1024 MB 6798159Ssobomax MEMORY_SIZE=1024 6872878Skris FOUND_MEM=no 6974146Skris 7072878Skris if test -f /proc/meminfo; then 7194987Sru # Looks like a Linux (or cygwin) system 7272878Skris MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'` 7372878Skris MEMORY_SIZE=`expr $MEMORY_SIZE / 1024` 7472878Skris FOUND_MEM=yes 7574146Skris elif test -x /usr/sbin/prtconf; then 7672878Skris # Looks like a Solaris system 7774146Skris MEMORY_SIZE=`/usr/sbin/prtconf | grep "Memory size" | awk '{ print [$]3 }'` 7872878Skris FOUND_MEM=yes 7974146Skris elif test -x /usr/sbin/system_profiler; then 8072878Skris # Looks like a MacOSX system 8174146Skris MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk '{print [$]2}'` 8272878Skris MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024` 8374146Skris FOUND_MEM=yes 8472878Skris elif test "x$OPENJDK_BUILD_OS" = xwindows; then 8574146Skris # Windows, but without cygwin 8672878Skris MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-` 8772878Skris MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024` 8872878Skris FOUND_MEM=yes 89100772Sjhb fi 9072878Skris 9174146Skris if test "x$FOUND_MEM" = xyes; then 9274146Skris AC_MSG_RESULT([$MEMORY_SIZE MB]) 9374146Skris else 9474146Skris AC_MSG_RESULT([could not detect memory size, defaulting to 1024 MB]) 9574146Skris AC_MSG_WARN([This might seriously impact build performance!]) 9674146Skris fi 9772878Skris]) 9872878Skris 9972878SkrisAC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES], 10072878Skris[ 10172878Skris# How many cores do we have on this build system? 10296421SobrienAC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores], 10396421Sobrien [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])]) 10473145Skrisif test "x$with_num_cores" = x; then 10574069Ssobomax # The number of cores were not specified, try to probe them. 10672878Skris BPERF_CHECK_CORES 10774069Ssobomaxelse 10872878Skris NUM_CORES=$with_num_cores 10972878Skris CONCURRENT_BUILD_JOBS=`expr $NUM_CORES \* 2` 11073145Skrisfi 11173145SkrisAC_SUBST(NUM_CORES) 11273145SkrisAC_SUBST(CONCURRENT_BUILD_JOBS) 11373145Skris]) 11473145Skris 11574553SkrisAC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY], 11672878Skris[ 11772878Skris# How much memory do we have on this build system? 11873145SkrisAC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size], 11973145Skris [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])]) 12072878Skrisif test "x$with_memory_size" = x; then 12172878Skris # The memory size was not specified, try to probe it. 12272878Skris BPERF_CHECK_MEMORY_SIZE 12372878Skriselse 12472878Skris MEMORY_SIZE=$with_memory_size 12572878Skrisfi 12672878SkrisAC_SUBST(MEMORY_SIZE) 12772878Skris]) 12872878Skris 12972878SkrisAC_DEFUN([BPERF_SETUP_CCACHE], 13072878Skris[ 13172878Skris AC_ARG_ENABLE([ccache], 13272878Skris [AS_HELP_STRING([--disable-ccache], 13372878Skris [disable using ccache to speed up recompilations @<:@enabled@:>@])], 13472878Skris [ENABLE_CCACHE=${enable_ccache}], [ENABLE_CCACHE=yes]) 13572878Skris if test "x$ENABLE_CCACHE" = xyes; then 13672878Skris AC_PATH_PROG(CCACHE, ccache) 13772878Skris else 13872878Skris AC_MSG_CHECKING([for ccache]) 13972878Skris AC_MSG_RESULT([explicitly disabled]) 14072878Skris CCACHE= 14172878Skris fi 14272878Skris AC_SUBST(CCACHE) 14372878Skris 14472878Skris AC_ARG_WITH([ccache-dir], 14572878Skris [AS_HELP_STRING([--with-ccache-dir], 146 [where to store ccache files @<:@~/.ccache@:>@])]) 147 148 if test "x$with_ccache_dir" != x; then 149 # When using a non home ccache directory, assume the use is to share ccache files 150 # with other users. Thus change the umask. 151 SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002" 152 fi 153 CCACHE_FOUND="" 154 if test "x$CCACHE" != x; then 155 BPERF_SETUP_CCACHE_USAGE 156 fi 157]) 158 159AC_DEFUN([BPERF_SETUP_CCACHE_USAGE], 160[ 161 if test "x$CCACHE" != x; then 162 CCACHE_FOUND="true" 163 # Only use ccache if it is 3.1.4 or later, which supports 164 # precompiled headers. 165 AC_MSG_CHECKING([if ccache supports precompiled headers]) 166 HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null` 167 if test "x$HAS_GOOD_CCACHE" = x; then 168 AC_MSG_RESULT([no, disabling ccache]) 169 CCACHE= 170 else 171 AC_MSG_RESULT([yes]) 172 AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers]) 173 PUSHED_FLAGS="$CXXFLAGS" 174 CXXFLAGS="-fpch-preprocess $CXXFLAGS" 175 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no]) 176 CXXFLAGS="$PUSHED_FLAGS" 177 if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then 178 AC_MSG_RESULT([yes]) 179 else 180 AC_MSG_RESULT([no, disabling ccaching of precompiled headers]) 181 CCACHE= 182 fi 183 fi 184 fi 185 186 if test "x$CCACHE" != x; then 187 CCACHE_SLOPPINESS=time_macros 188 CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE" 189 CCACHE_FLAGS=-fpch-preprocess 190 191 if test "x$SET_CCACHE_DIR" != x; then 192 mkdir -p $CCACHE_DIR > /dev/null 2>&1 193 chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1 194 fi 195 fi 196]) 197 198AC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS], 199[ 200 201############################################################################### 202# 203# Can the C/C++ compiler use precompiled headers? 204# 205AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers], 206 [disable using precompiled headers when compiling C++ @<:@enabled@:>@])], 207 [ENABLE_PRECOMPH=${enable_precompiled-headers}], [ENABLE_PRECOMPH=yes]) 208 209USE_PRECOMPILED_HEADER=1 210if test "x$ENABLE_PRECOMPH" = xno; then 211 USE_PRECOMPILED_HEADER=0 212fi 213 214if test "x$ENABLE_PRECOMPH" = xyes; then 215 # Check that the compiler actually supports precomp headers. 216 if test "x$GCC" = xyes; then 217 AC_MSG_CHECKING([that precompiled headers work]) 218 echo "int alfa();" > conftest.h 219 $CXX -x c++-header conftest.h -o conftest.hpp.gch 220 if test ! -f conftest.hpp.gch; then 221 echo Precompiled header is not working! 222 USE_PRECOMPILED_HEADER=0 223 AC_MSG_RESULT([no]) 224 else 225 AC_MSG_RESULT([yes]) 226 fi 227 rm -f conftest.h 228 fi 229fi 230 231AC_SUBST(USE_PRECOMPILED_HEADER) 232]) 233 234 235AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC], 236[ 237AC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java], 238 [use this java binary for running the sjavac background server @<:@Boot JDK java@:>@])]) 239 240if test "x$with_sjavac_server_java" != x; then 241 SJAVAC_SERVER_JAVA="$with_sjavac_server_java" 242 FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""` 243 if test "x$FOUND_VERSION" = x; then 244 AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA]) 245 fi 246else 247 SJAVAC_SERVER_JAVA="" 248 # Hotspot specific options. 249 ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA]) 250 # JRockit specific options. 251 ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA]) 252 SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA" 253fi 254AC_SUBST(SJAVAC_SERVER_JAVA) 255 256AC_ARG_WITH(sjavac-server-cores, [AS_HELP_STRING([--with-sjavac-server-cores], 257 [use at most this number of concurrent threads on the sjavac server @<:@probed@:>@])]) 258if test "x$with_sjavac_server_cores" != x; then 259 SJAVAC_SERVER_CORES="$with_sjavac_server_cores" 260else 261 if test "$NUM_CORES" -gt 16; then 262 # We set this arbitrary limit because we want to limit the heap 263 # size of the javac server. 264 # In the future we will make the javac compilers in the server 265 # share more and more state, thus enabling us to use more and 266 # more concurrent threads in the server. 267 SJAVAC_SERVER_CORES="16" 268 else 269 SJAVAC_SERVER_CORES="$NUM_CORES" 270 fi 271 272 if test "$MEMORY_SIZE" -gt "17000"; then 273 MAX_HEAP_MEM=10000 274 ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 275 ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 276 elif test "$MEMORY_SIZE" -gt "10000"; then 277 MAX_HEAP_MEM=6000 278 ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 279 ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 280 elif test "$MEMORY_SIZE" -gt "5000"; then 281 MAX_HEAP_MEM=3000 282 ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 283 ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 284 elif test "$MEMORY_SIZE" -gt "3800"; then 285 MAX_HEAP_MEM=2500 286 ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 287 elif test "$MEMORY_SIZE" -gt "1900"; then 288 MAX_HEAP_MEM=1200 289 ADD_JVM_ARG_IF_OK([-Xms700M -Xmx1400M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 290 elif test "$MEMORY_SIZE" -gt "1000"; then 291 MAX_HEAP_MEM=900 292 ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 293 else 294 MAX_HEAP_MEM=512 295 ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 296 fi 297 298 ADD_JVM_ARG_IF_OK([-XX:PermSize=32m],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 299 ADD_JVM_ARG_IF_OK([-XX:MaxPermSize=160m],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 300 ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 301 302 MAX_COMPILERS_IN_HEAP=`expr $MAX_HEAP_MEM / 501` 303 if test "$SJAVAC_SERVER_CORES" -gt "$MAX_COMPILERS_IN_HEAP"; then 304 AC_MSG_CHECKING([if number of server cores must be reduced]) 305 SJAVAC_SERVER_CORES="$MAX_COMPILERS_IN_HEAP" 306 AC_MSG_RESULT([yes, to $SJAVAC_SERVER_CORES with max heap size $MAX_HEAP_MEM MB]) 307 fi 308fi 309AC_SUBST(SJAVAC_SERVER_CORES) 310 311AC_MSG_CHECKING([whether to use sjavac]) 312AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac], 313 [use sjavac to do fast incremental compiles @<:@disabled@:>@])], 314 [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no']) 315AC_MSG_RESULT([$ENABLE_SJAVAC]) 316AC_SUBST(ENABLE_SJAVAC) 317 318if test "x$ENABLE_SJAVAC" = xyes; then 319 SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers" 320else 321 SJAVAC_SERVER_DIR= 322fi 323AC_SUBST(SJAVAC_SERVER_DIR) 324 325]) 326