build-performance.m4 revision 715:e247ee3924d5
1185089Sraj# 2209131Sraj# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. 3209131Sraj# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4294430Szbb# 5185089Sraj# This code is free software; you can redistribute it and/or modify it 6185089Sraj# under the terms of the GNU General Public License version 2 only, as 7185089Sraj# published by the Free Software Foundation. Oracle designates this 8185089Sraj# particular file as subject to the "Classpath" exception as provided 9209131Sraj# by Oracle in the LICENSE file that accompanied this code. 10209131Sraj# 11209131Sraj# This code is distributed in the hope that it will be useful, but WITHOUT 12185089Sraj# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13185089Sraj# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14185089Sraj# version 2 for more details (a copy is included in the LICENSE file that 15185089Sraj# accompanied this code). 16185089Sraj# 17185089Sraj# You should have received a copy of the GNU General Public License version 18185089Sraj# 2 along with this work; if not, write to the Free Software Foundation, 19185089Sraj# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20185089Sraj# 21185089Sraj# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22185089Sraj# or visit www.oracle.com if you need additional information or have any 23185089Sraj# questions. 24185089Sraj# 25185089Sraj 26185089SrajAC_DEFUN([BPERF_CHECK_CORES], 27185089Sraj[ 28185089Sraj AC_MSG_CHECKING([for number of cores]) 29185089Sraj NUM_CORES=1 30185089Sraj FOUND_CORES=no 31185089Sraj 32185089Sraj if test -f /proc/cpuinfo; then 33185089Sraj # Looks like a Linux (or cygwin) system 34185089Sraj NUM_CORES=`cat /proc/cpuinfo | grep -c processor` 35185089Sraj FOUND_CORES=yes 36185089Sraj elif test -x /usr/sbin/psrinfo; then 37185089Sraj # Looks like a Solaris system 38185089Sraj NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line` 39185089Sraj FOUND_CORES=yes 40185089Sraj elif test -x /usr/sbin/system_profiler; then 41185089Sraj # Looks like a MacOSX system 42185089Sraj NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk '{print [$]5}'` 43185089Sraj FOUND_CORES=yes 44185089Sraj elif test -n "$NUMBER_OF_PROCESSORS"; then 45185089Sraj # On windows, look in the env 46185089Sraj NUM_CORES=$NUMBER_OF_PROCESSORS 47185089Sraj FOUND_CORES=yes 48185089Sraj fi 49185089Sraj 50185089Sraj if test "x$FOUND_CORES" = xyes; then 51185089Sraj AC_MSG_RESULT([$NUM_CORES]) 52185089Sraj else 53185089Sraj AC_MSG_RESULT([could not detect number of cores, defaulting to 1]) 54185089Sraj AC_MSG_WARN([This will disable all parallelism from build!]) 55185089Sraj fi 56260327Snwhitehorn 57240493Sgber]) 58240493Sgber 59185089SrajAC_DEFUN([BPERF_CHECK_MEMORY_SIZE], 60185089Sraj[ 61185089Sraj AC_MSG_CHECKING([for memory size]) 62209131Sraj # Default to 1024 MB 63209131Sraj MEMORY_SIZE=1024 64295807Sandrew FOUND_MEM=no 65259484Snwhitehorn 66185089Sraj if test -f /proc/meminfo; then 67185089Sraj # Looks like a Linux (or cygwin) system 68185089Sraj MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'` 69185089Sraj MEMORY_SIZE=`expr $MEMORY_SIZE / 1024` 70209131Sraj FOUND_MEM=yes 71185089Sraj elif test -x /usr/sbin/prtconf; then 72185089Sraj # Looks like a Solaris system 73260340Sian MEMORY_SIZE=`/usr/sbin/prtconf | grep "Memory size" | awk '{ print [$]3 }'` 74185089Sraj FOUND_MEM=yes 75185089Sraj elif test -x /usr/sbin/system_profiler; then 76185089Sraj # Looks like a MacOSX system 77185089Sraj MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk '{print [$]2}'` 78185089Sraj MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024` 79209131Sraj FOUND_MEM=yes 80185089Sraj elif test "x$OPENJDK_BUILD_OS" = xwindows; then 81240493Sgber # Windows, but without cygwin 82240493Sgber MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-` 83240493Sgber MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024` 84240493Sgber FOUND_MEM=yes 85240493Sgber fi 86240493Sgber 87260340Sian if test "x$FOUND_MEM" = xyes; then 88260340Sian AC_MSG_RESULT([$MEMORY_SIZE MB]) 89260340Sian else 90260340Sian AC_MSG_RESULT([could not detect memory size, defaulting to 1024 MB]) 91260340Sian AC_MSG_WARN([This might seriously impact build performance!]) 92260340Sian fi 93260340Sian]) 94260340Sian 95260340SianAC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES], 96260340Sian[ 97260340Sian # How many cores do we have on this build system? 98260340Sian AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores], 99260340Sian [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])]) 100260340Sian if test "x$with_num_cores" = x; then 101260340Sian # The number of cores were not specified, try to probe them. 102260340Sian BPERF_CHECK_CORES 103260340Sian else 104260340Sian NUM_CORES=$with_num_cores 105260340Sian fi 106260340Sian AC_SUBST(NUM_CORES) 107260340Sian]) 108260340Sian 109260340SianAC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY], 110260340Sian[ 111260340Sian # How much memory do we have on this build system? 112260340Sian AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size], 113260340Sian [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])]) 114260340Sian if test "x$with_memory_size" = x; then 115260340Sian # The memory size was not specified, try to probe it. 116260340Sian BPERF_CHECK_MEMORY_SIZE 117260340Sian else 118260340Sian MEMORY_SIZE=$with_memory_size 119260340Sian fi 120260340Sian AC_SUBST(MEMORY_SIZE) 121260340Sian]) 122260340Sian 123260340SianAC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS], 124260340Sian[ 125260340Sian # Provide a decent default number of parallel jobs for make depending on 126260340Sian # number of cores, amount of memory and machine architecture. 127260340Sian AC_ARG_WITH(jobs, [AS_HELP_STRING([--with-jobs], 128260340Sian [number of parallel jobs to let make run @<:@calculated based on cores and memory@:>@])]) 129260340Sian if test "x$with_jobs" = x; then 130260340Sian # Number of jobs was not specified, calculate. 131260340Sian AC_MSG_CHECKING([for appropriate number of jobs to run in parallel]) 132260340Sian # Approximate memory in GB, rounding up a bit. 133260340Sian memory_gb=`expr $MEMORY_SIZE / 1100` 134260340Sian # Pick the lowest of memory in gb and number of cores. 135260340Sian if test "$memory_gb" -lt "$NUM_CORES"; then 136260340Sian JOBS="$memory_gb" 137260340Sian else 138260340Sian JOBS="$NUM_CORES" 139260340Sian # On bigger machines, leave some room for other processes to run 140260340Sian if test "$JOBS" -gt "4"; then 141260340Sian JOBS=`expr $JOBS '*' 90 / 100` 142260340Sian fi 143260340Sian fi 144260340Sian # Cap number of jobs to 16 145260340Sian if test "$JOBS" -gt "16"; then 146260340Sian JOBS=16 147260340Sian fi 148260340Sian AC_MSG_RESULT([$JOBS]) 149260340Sian else 150260340Sian JOBS=$with_jobs 151260340Sian fi 152260340Sian AC_SUBST(JOBS) 153260340Sian]) 154260340Sian 155260340SianAC_DEFUN([BPERF_SETUP_CCACHE], 156260340Sian[ 157260340Sian AC_ARG_ENABLE([ccache], 158260340Sian [AS_HELP_STRING([--disable-ccache], 159260340Sian [disable using ccache to speed up recompilations @<:@enabled@:>@])], 160260340Sian [ENABLE_CCACHE=${enable_ccache}], [ENABLE_CCACHE=yes]) 161260340Sian if test "x$ENABLE_CCACHE" = xyes; then 162260340Sian AC_PATH_PROG(CCACHE, ccache) 163260340Sian else 164260340Sian AC_MSG_CHECKING([for ccache]) 165260340Sian AC_MSG_RESULT([explicitly disabled]) 166260340Sian CCACHE= 167260340Sian fi 168260340Sian AC_SUBST(CCACHE) 169260340Sian 170260340Sian AC_ARG_WITH([ccache-dir], 171260340Sian [AS_HELP_STRING([--with-ccache-dir], 172260340Sian [where to store ccache files @<:@~/.ccache@:>@])]) 173260340Sian 174260340Sian if test "x$with_ccache_dir" != x; then 175260340Sian # When using a non home ccache directory, assume the use is to share ccache files 176260340Sian # with other users. Thus change the umask. 177260340Sian SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002" 178260340Sian fi 179260340Sian CCACHE_FOUND="" 180260340Sian if test "x$CCACHE" != x; then 181260340Sian BPERF_SETUP_CCACHE_USAGE 182260340Sian fi 183275799Sbr]) 184260340Sian 185260340SianAC_DEFUN([BPERF_SETUP_CCACHE_USAGE], 186260340Sian[ 187260340Sian if test "x$CCACHE" != x; then 188260340Sian CCACHE_FOUND="true" 189260340Sian # Only use ccache if it is 3.1.4 or later, which supports 190260340Sian # precompiled headers. 191275802Sbr AC_MSG_CHECKING([if ccache supports precompiled headers]) 192260340Sian HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null` 193260340Sian if test "x$HAS_GOOD_CCACHE" = x; then 194260340Sian AC_MSG_RESULT([no, disabling ccache]) 195260340Sian CCACHE= 196260340Sian else 197260340Sian AC_MSG_RESULT([yes]) 198260340Sian AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers]) 199260340Sian PUSHED_FLAGS="$CXXFLAGS" 200260340Sian CXXFLAGS="-fpch-preprocess $CXXFLAGS" 201260340Sian AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no]) 202260340Sian CXXFLAGS="$PUSHED_FLAGS" 203260340Sian if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then 204260340Sian AC_MSG_RESULT([yes]) 205260340Sian else 206260340Sian AC_MSG_RESULT([no, disabling ccaching of precompiled headers]) 207260340Sian CCACHE= 208260340Sian fi 209260340Sian fi 210260340Sian fi 211260340Sian 212260340Sian if test "x$CCACHE" != x; then 213260340Sian CCACHE_SLOPPINESS=time_macros 214260340Sian CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE" 215260340Sian CCACHE_FLAGS=-fpch-preprocess 216260340Sian 217260340Sian if test "x$SET_CCACHE_DIR" != x; then 218260340Sian mkdir -p $CCACHE_DIR > /dev/null 2>&1 219260340Sian chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1 220260340Sian fi 221260340Sian fi 222260340Sian]) 223260340Sian 224260340SianAC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS], 225260340Sian[ 226260340Sian 227260340Sian############################################################################### 228260340Sian# 229260340Sian# Can the C/C++ compiler use precompiled headers? 230260340Sian# 231260340SianAC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers], 232260340Sian [disable using precompiled headers when compiling C++ @<:@enabled@:>@])], 233260340Sian [ENABLE_PRECOMPH=${enable_precompiled_headers}], [ENABLE_PRECOMPH=yes]) 234260340Sian 235260340SianUSE_PRECOMPILED_HEADER=1 236260340Sianif test "x$ENABLE_PRECOMPH" = xno; then 237260340Sian USE_PRECOMPILED_HEADER=0 238260340Sianfi 239260340Sian 240260340Sianif test "x$ENABLE_PRECOMPH" = xyes; then 241260340Sian # Check that the compiler actually supports precomp headers. 242260340Sian if test "x$GCC" = xyes; then 243260340Sian AC_MSG_CHECKING([that precompiled headers work]) 244260340Sian echo "int alfa();" > conftest.h 245260340Sian $CXX -x c++-header conftest.h -o conftest.hpp.gch 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD 246260340Sian if test ! -f conftest.hpp.gch; then 247260340Sian USE_PRECOMPILED_HEADER=0 248258780Seadler AC_MSG_RESULT([no]) 249185089Sraj else 250185089Sraj AC_MSG_RESULT([yes]) 251185089Sraj fi 252185089Sraj rm -f conftest.h conftest.hpp.gch 253185089Sraj fi 254185089Srajfi 255185089Sraj 256185089SrajAC_SUBST(USE_PRECOMPILED_HEADER) 257185089Sraj]) 258185089Sraj 259185089Sraj 260185089SrajAC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC], 261185089Sraj[ 262185089SrajAC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java], 263185089Sraj [use this java binary for running the sjavac background server @<:@Boot JDK java@:>@])]) 264240489Sgber 265240489Sgberif test "x$with_sjavac_server_java" != x; then 266185089Sraj SJAVAC_SERVER_JAVA="$with_sjavac_server_java" 267240489Sgber FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""` 268185089Sraj if test "x$FOUND_VERSION" = x; then 269240489Sgber AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA]) 270240489Sgber fi 271185089Srajelse 272240489Sgber SJAVAC_SERVER_JAVA="" 273240489Sgber # Hotspot specific options. 274240489Sgber ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA]) 275240489Sgber # JRockit specific options. 276240489Sgber ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA]) 277240489Sgber SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA" 278209131Srajfi 279185089SrajAC_SUBST(SJAVAC_SERVER_JAVA) 280185089Sraj 281209131Srajif test "$MEMORY_SIZE" -gt "2500"; then 282209131Sraj ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 283209131Sraj if test "$JVM_ARG_OK" = true; then 284240489Sgber JVM_64BIT=true 285240489Sgber JVM_ARG_OK=false 286240489Sgber fi 287209131Sraj fi 288185089Sraj 289209131Srajif test "$JVM_64BIT" = true; then 290209131Sraj if test "$MEMORY_SIZE" -gt "17000"; then 291209131Sraj ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 292240489Sgber fi 293240489Sgber if test "$MEMORY_SIZE" -gt "10000" && test "$JVM_ARG_OK" = false; then 294209131Sraj ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 295185089Sraj fi 296185089Sraj if test "$MEMORY_SIZE" -gt "5000" && test "$JVM_ARG_OK" = false; then 297185089Sraj ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 298185089Sraj fi 299185089Sraj if test "$MEMORY_SIZE" -gt "3800" && test "$JVM_ARG_OK" = false; then 300185089Sraj ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 301240493Sgber fi 302240493Sgberfi 303240493Sgberif test "$MEMORY_SIZE" -gt "2500" && test "$JVM_ARG_OK" = false; then 304185089Sraj ADD_JVM_ARG_IF_OK([-Xms1000M -Xmx1500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 305185089Srajfi 306209131Srajif test "$MEMORY_SIZE" -gt "1000" && test "$JVM_ARG_OK" = false; then 307240489Sgber ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 308185089Srajfi 309259484Snwhitehornif test "$JVM_ARG_OK" = false; then 310185089Sraj ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA]) 311185089Srajfi 312209131Sraj 313209131SrajAC_MSG_CHECKING([whether to use sjavac]) 314209131SrajAC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac], 315209131Sraj [use sjavac to do fast incremental compiles @<:@disabled@:>@])], 316209131Sraj [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no']) 317209131SrajAC_MSG_RESULT([$ENABLE_SJAVAC]) 318209131SrajAC_SUBST(ENABLE_SJAVAC) 319209131Sraj 320209131Srajif test "x$ENABLE_SJAVAC" = xyes; then 321209131Sraj SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers" 322209131Srajelse 323240489Sgber SJAVAC_SERVER_DIR= 324240489Sgberfi 325185089SrajAC_SUBST(SJAVAC_SERVER_DIR) 326209131Sraj 327209131Sraj]) 328209131Sraj