common/autoconf/build-performance.m4

Thu, 27 Dec 2018 11:47:57 +0800

author
aoqi
date
Thu, 27 Dec 2018 11:47:57 +0800
changeset 2316
64a3eeabf6e5
parent 2215
7a73b8b4ac8a
parent 1133
50aaf272884f
child 2458
daa47f8cf745
permissions
-rw-r--r--

Merge

aoqi@0 1 #
kevinw@2206 2 # Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 #
aoqi@0 5 # This code is free software; you can redistribute it and/or modify it
aoqi@0 6 # under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 # published by the Free Software Foundation. Oracle designates this
aoqi@0 8 # particular file as subject to the "Classpath" exception as provided
aoqi@0 9 # by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 #
aoqi@0 11 # This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 # version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 # accompanied this code).
aoqi@0 16 #
aoqi@0 17 # You should have received a copy of the GNU General Public License version
aoqi@0 18 # 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 #
aoqi@0 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 # or visit www.oracle.com if you need additional information or have any
aoqi@0 23 # questions.
aoqi@0 24 #
aoqi@0 25
aoqi@0 26 AC_DEFUN([BPERF_CHECK_CORES],
aoqi@0 27 [
aoqi@0 28 AC_MSG_CHECKING([for number of cores])
aoqi@0 29 NUM_CORES=1
aoqi@0 30 FOUND_CORES=no
aoqi@0 31
aoqi@0 32 if test -f /proc/cpuinfo; then
aoqi@0 33 # Looks like a Linux (or cygwin) system
aoqi@0 34 NUM_CORES=`cat /proc/cpuinfo | grep -c processor`
aoqi@0 35 FOUND_CORES=yes
aoqi@0 36 elif test -x /usr/sbin/psrinfo; then
aoqi@0 37 # Looks like a Solaris system
aoqi@0 38 NUM_CORES=`LC_MESSAGES=C /usr/sbin/psrinfo -v | grep -c on-line`
aoqi@0 39 FOUND_CORES=yes
aoqi@0 40 elif test -x /usr/sbin/system_profiler; then
aoqi@0 41 # Looks like a MacOSX system
aoqi@0 42 NUM_CORES=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Cores' | awk '{print [$]5}'`
aoqi@0 43 FOUND_CORES=yes
aoqi@0 44 elif test "x$OPENJDK_BUILD_OS" = xaix ; then
aoqi@0 45 NUM_CORES=`/usr/sbin/prtconf | grep "^Number Of Processors" | awk '{ print [$]4 }'`
aoqi@0 46 FOUND_CORES=yes
aoqi@0 47 elif test -n "$NUMBER_OF_PROCESSORS"; then
aoqi@0 48 # On windows, look in the env
aoqi@0 49 NUM_CORES=$NUMBER_OF_PROCESSORS
aoqi@0 50 FOUND_CORES=yes
aoqi@0 51 fi
aoqi@0 52
aoqi@0 53 if test "x$FOUND_CORES" = xyes; then
aoqi@0 54 AC_MSG_RESULT([$NUM_CORES])
aoqi@0 55 else
aoqi@0 56 AC_MSG_RESULT([could not detect number of cores, defaulting to 1])
aoqi@0 57 AC_MSG_WARN([This will disable all parallelism from build!])
aoqi@0 58 fi
aoqi@0 59 ])
aoqi@0 60
aoqi@0 61 AC_DEFUN([BPERF_CHECK_MEMORY_SIZE],
aoqi@0 62 [
aoqi@0 63 AC_MSG_CHECKING([for memory size])
aoqi@0 64 # Default to 1024 MB
aoqi@0 65 MEMORY_SIZE=1024
aoqi@0 66 FOUND_MEM=no
aoqi@0 67
aoqi@0 68 if test -f /proc/meminfo; then
aoqi@0 69 # Looks like a Linux (or cygwin) system
aoqi@0 70 MEMORY_SIZE=`cat /proc/meminfo | grep MemTotal | awk '{print [$]2}'`
aoqi@0 71 MEMORY_SIZE=`expr $MEMORY_SIZE / 1024`
aoqi@0 72 FOUND_MEM=yes
aoqi@0 73 elif test -x /usr/sbin/prtconf; then
aoqi@0 74 # Looks like a Solaris or AIX system
aoqi@0 75 MEMORY_SIZE=`/usr/sbin/prtconf | grep "^Memory [[Ss]]ize" | awk '{ print [$]3 }'`
aoqi@0 76 FOUND_MEM=yes
aoqi@0 77 elif test -x /usr/sbin/system_profiler; then
aoqi@0 78 # Looks like a MacOSX system
aoqi@0 79 MEMORY_SIZE=`/usr/sbin/system_profiler -detailLevel full SPHardwareDataType | grep 'Memory' | awk '{print [$]2}'`
aoqi@0 80 MEMORY_SIZE=`expr $MEMORY_SIZE \* 1024`
aoqi@0 81 FOUND_MEM=yes
aoqi@0 82 elif test "x$OPENJDK_BUILD_OS" = xwindows; then
aoqi@0 83 # Windows, but without cygwin
aoqi@0 84 MEMORY_SIZE=`wmic computersystem get totalphysicalmemory -value | grep = | cut -d "=" -f 2-`
aoqi@0 85 MEMORY_SIZE=`expr $MEMORY_SIZE / 1024 / 1024`
aoqi@0 86 FOUND_MEM=yes
aoqi@0 87 fi
aoqi@0 88
aoqi@0 89 if test "x$FOUND_MEM" = xyes; then
aoqi@0 90 AC_MSG_RESULT([$MEMORY_SIZE MB])
aoqi@0 91 else
aoqi@0 92 AC_MSG_RESULT([could not detect memory size, defaulting to 1024 MB])
aoqi@0 93 AC_MSG_WARN([This might seriously impact build performance!])
aoqi@0 94 fi
aoqi@0 95 ])
aoqi@0 96
aoqi@0 97 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_CORES],
aoqi@0 98 [
aoqi@0 99 # How many cores do we have on this build system?
aoqi@0 100 AC_ARG_WITH(num-cores, [AS_HELP_STRING([--with-num-cores],
aoqi@0 101 [number of cores in the build system, e.g. --with-num-cores=8 @<:@probed@:>@])])
aoqi@0 102 if test "x$with_num_cores" = x; then
aoqi@0 103 # The number of cores were not specified, try to probe them.
aoqi@0 104 BPERF_CHECK_CORES
aoqi@0 105 else
aoqi@0 106 NUM_CORES=$with_num_cores
aoqi@0 107 fi
aoqi@0 108 AC_SUBST(NUM_CORES)
aoqi@0 109 ])
aoqi@0 110
aoqi@0 111 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_MEMORY],
aoqi@0 112 [
aoqi@0 113 # How much memory do we have on this build system?
aoqi@0 114 AC_ARG_WITH(memory-size, [AS_HELP_STRING([--with-memory-size],
aoqi@0 115 [memory (in MB) available in the build system, e.g. --with-memory-size=1024 @<:@probed@:>@])])
aoqi@0 116 if test "x$with_memory_size" = x; then
aoqi@0 117 # The memory size was not specified, try to probe it.
aoqi@0 118 BPERF_CHECK_MEMORY_SIZE
aoqi@0 119 else
aoqi@0 120 MEMORY_SIZE=$with_memory_size
aoqi@0 121 fi
aoqi@0 122 AC_SUBST(MEMORY_SIZE)
aoqi@0 123 ])
aoqi@0 124
aoqi@0 125 AC_DEFUN_ONCE([BPERF_SETUP_BUILD_JOBS],
aoqi@0 126 [
aoqi@0 127 # Provide a decent default number of parallel jobs for make depending on
aoqi@0 128 # number of cores, amount of memory and machine architecture.
aoqi@0 129 AC_ARG_WITH(jobs, [AS_HELP_STRING([--with-jobs],
aoqi@0 130 [number of parallel jobs to let make run @<:@calculated based on cores and memory@:>@])])
aoqi@0 131 if test "x$with_jobs" = x; then
aoqi@0 132 # Number of jobs was not specified, calculate.
aoqi@0 133 AC_MSG_CHECKING([for appropriate number of jobs to run in parallel])
aoqi@0 134 # Approximate memory in GB, rounding up a bit.
aoqi@0 135 memory_gb=`expr $MEMORY_SIZE / 1100`
aoqi@0 136 # Pick the lowest of memory in gb and number of cores.
aoqi@0 137 if test "$memory_gb" -lt "$NUM_CORES"; then
aoqi@0 138 JOBS="$memory_gb"
aoqi@0 139 else
aoqi@0 140 JOBS="$NUM_CORES"
aoqi@0 141 # On bigger machines, leave some room for other processes to run
aoqi@0 142 if test "$JOBS" -gt "4"; then
aoqi@0 143 JOBS=`expr $JOBS '*' 90 / 100`
aoqi@0 144 fi
aoqi@0 145 fi
aoqi@0 146 # Cap number of jobs to 16
aoqi@0 147 if test "$JOBS" -gt "16"; then
aoqi@0 148 JOBS=16
aoqi@0 149 fi
aoqi@0 150 if test "$JOBS" -eq "0"; then
aoqi@0 151 JOBS=1
aoqi@0 152 fi
aoqi@0 153 AC_MSG_RESULT([$JOBS])
aoqi@0 154 else
aoqi@0 155 JOBS=$with_jobs
aoqi@0 156 fi
aoqi@0 157 AC_SUBST(JOBS)
aoqi@0 158 ])
aoqi@0 159
aoqi@0 160 AC_DEFUN([BPERF_SETUP_CCACHE],
aoqi@0 161 [
aoqi@0 162 AC_ARG_ENABLE([ccache],
kevinw@2203 163 [AS_HELP_STRING([--enable-ccache],
kevinw@2203 164 [enable using ccache to speed up recompilations @<:@disabled@:>@])])
kevinw@2203 165
kevinw@2203 166 CCACHE=
kevinw@2203 167 AC_MSG_CHECKING([is ccache enabled])
kevinw@2203 168 ENABLE_CCACHE=$enable_ccache
kevinw@2203 169 if test "x$enable_ccache" = xyes; then
kevinw@2203 170 AC_MSG_RESULT([yes])
aoqi@0 171 OLD_PATH="$PATH"
kevinw@2215 172 if test "x$TOOLCHAIN_PATH" != x; then
kevinw@2215 173 PATH=$TOOLCHAIN_PATH:$PATH
aoqi@0 174 fi
kevinw@2204 175 BASIC_REQUIRE_PROGS(CCACHE, ccache)
kevinw@2203 176 CCACHE_STATUS="enabled"
aoqi@0 177 PATH="$OLD_PATH"
kevinw@2203 178 elif test "x$enable_ccache" = xno; then
kevinw@2203 179 AC_MSG_RESULT([no, explicitly disabled])
kevinw@2203 180 elif test "x$enable_ccache" = x; then
kevinw@2203 181 AC_MSG_RESULT([no])
aoqi@0 182 else
kevinw@2203 183 AC_MSG_RESULT([unknown])
kevinw@2203 184 AC_MSG_ERROR([--enable-ccache does not accept any parameters])
aoqi@0 185 fi
aoqi@0 186 AC_SUBST(CCACHE)
aoqi@0 187
aoqi@0 188 AC_ARG_WITH([ccache-dir],
aoqi@0 189 [AS_HELP_STRING([--with-ccache-dir],
aoqi@0 190 [where to store ccache files @<:@~/.ccache@:>@])])
aoqi@0 191
aoqi@0 192 if test "x$with_ccache_dir" != x; then
aoqi@0 193 # When using a non home ccache directory, assume the use is to share ccache files
aoqi@0 194 # with other users. Thus change the umask.
aoqi@0 195 SET_CCACHE_DIR="CCACHE_DIR=$with_ccache_dir CCACHE_UMASK=002"
kevinw@2203 196 if test "x$CCACHE" = x; then
kevinw@2203 197 AC_MSG_WARN([--with-ccache-dir has no meaning when ccache is not enabled])
kevinw@2203 198 fi
aoqi@0 199 fi
kevinw@2203 200
aoqi@0 201 if test "x$CCACHE" != x; then
aoqi@0 202 BPERF_SETUP_CCACHE_USAGE
aoqi@0 203 fi
aoqi@0 204 ])
aoqi@0 205
aoqi@0 206 AC_DEFUN([BPERF_SETUP_CCACHE_USAGE],
aoqi@0 207 [
aoqi@0 208 if test "x$CCACHE" != x; then
aoqi@0 209 # Only use ccache if it is 3.1.4 or later, which supports
aoqi@0 210 # precompiled headers.
aoqi@0 211 AC_MSG_CHECKING([if ccache supports precompiled headers])
aoqi@0 212 HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null`
aoqi@0 213 if test "x$HAS_GOOD_CCACHE" = x; then
aoqi@0 214 AC_MSG_RESULT([no, disabling ccache])
aoqi@0 215 CCACHE=
kevinw@2203 216 CCACHE_STATUS="disabled"
aoqi@0 217 else
aoqi@0 218 AC_MSG_RESULT([yes])
aoqi@0 219 AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers])
aoqi@0 220 PUSHED_FLAGS="$CXXFLAGS"
aoqi@0 221 CXXFLAGS="-fpch-preprocess $CXXFLAGS"
aoqi@0 222 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no])
aoqi@0 223 CXXFLAGS="$PUSHED_FLAGS"
aoqi@0 224 if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then
aoqi@0 225 AC_MSG_RESULT([yes])
aoqi@0 226 else
aoqi@0 227 AC_MSG_RESULT([no, disabling ccaching of precompiled headers])
aoqi@0 228 CCACHE=
kevinw@2203 229 CCACHE_STATUS="disabled"
aoqi@0 230 fi
aoqi@0 231 fi
aoqi@0 232 fi
aoqi@0 233
aoqi@0 234 if test "x$CCACHE" != x; then
aoqi@0 235 CCACHE_SLOPPINESS=time_macros
aoqi@0 236 CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE"
aoqi@0 237 CCACHE_FLAGS=-fpch-preprocess
aoqi@0 238
aoqi@0 239 if test "x$SET_CCACHE_DIR" != x; then
aoqi@0 240 mkdir -p $CCACHE_DIR > /dev/null 2>&1
aoqi@0 241 chmod a+rwxs $CCACHE_DIR > /dev/null 2>&1
aoqi@0 242 fi
aoqi@0 243 fi
aoqi@0 244 ])
aoqi@0 245
aoqi@0 246 AC_DEFUN_ONCE([BPERF_SETUP_PRECOMPILED_HEADERS],
aoqi@0 247 [
aoqi@0 248
aoqi@0 249 ###############################################################################
aoqi@0 250 #
aoqi@0 251 # Can the C/C++ compiler use precompiled headers?
aoqi@0 252 #
aoqi@0 253 AC_ARG_ENABLE([precompiled-headers], [AS_HELP_STRING([--disable-precompiled-headers],
aoqi@0 254 [disable using precompiled headers when compiling C++ @<:@enabled@:>@])],
aoqi@0 255 [ENABLE_PRECOMPH=${enable_precompiled_headers}], [ENABLE_PRECOMPH=yes])
aoqi@0 256
aoqi@0 257 USE_PRECOMPILED_HEADER=1
aoqi@0 258 if test "x$ENABLE_PRECOMPH" = xno; then
aoqi@0 259 USE_PRECOMPILED_HEADER=0
aoqi@0 260 fi
aoqi@0 261
aoqi@0 262 if test "x$ENABLE_PRECOMPH" = xyes; then
aoqi@0 263 # Check that the compiler actually supports precomp headers.
kevinw@2206 264 if test "x$TOOLCHAIN_TYPE" = xgcc; then
aoqi@0 265 AC_MSG_CHECKING([that precompiled headers work])
aoqi@0 266 echo "int alfa();" > conftest.h
aoqi@0 267 $CXX -x c++-header conftest.h -o conftest.hpp.gch 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD
aoqi@0 268 if test ! -f conftest.hpp.gch; then
aoqi@0 269 USE_PRECOMPILED_HEADER=0
aoqi@0 270 AC_MSG_RESULT([no])
aoqi@0 271 else
aoqi@0 272 AC_MSG_RESULT([yes])
aoqi@0 273 fi
aoqi@0 274 rm -f conftest.h conftest.hpp.gch
aoqi@0 275 fi
aoqi@0 276 fi
aoqi@0 277
aoqi@0 278 AC_SUBST(USE_PRECOMPILED_HEADER)
aoqi@0 279 ])
aoqi@0 280
aoqi@0 281
aoqi@0 282 AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC],
aoqi@0 283 [
aoqi@0 284 AC_ARG_WITH(sjavac-server-java, [AS_HELP_STRING([--with-sjavac-server-java],
aoqi@0 285 [use this java binary for running the sjavac background server @<:@Boot JDK java@:>@])])
aoqi@0 286
aoqi@0 287 if test "x$with_sjavac_server_java" != x; then
aoqi@0 288 SJAVAC_SERVER_JAVA="$with_sjavac_server_java"
aoqi@0 289 FOUND_VERSION=`$SJAVAC_SERVER_JAVA -version 2>&1 | grep " version \""`
aoqi@0 290 if test "x$FOUND_VERSION" = x; then
aoqi@0 291 AC_MSG_ERROR([Could not execute server java: $SJAVAC_SERVER_JAVA])
aoqi@0 292 fi
aoqi@0 293 else
aoqi@0 294 SJAVAC_SERVER_JAVA=""
aoqi@0 295 # Hotspot specific options.
aoqi@0 296 ADD_JVM_ARG_IF_OK([-verbosegc],SJAVAC_SERVER_JAVA,[$JAVA])
aoqi@0 297 # JRockit specific options.
aoqi@0 298 ADD_JVM_ARG_IF_OK([-Xverbose:gc],SJAVAC_SERVER_JAVA,[$JAVA])
aoqi@0 299 SJAVAC_SERVER_JAVA="$JAVA $SJAVAC_SERVER_JAVA"
aoqi@0 300 fi
aoqi@0 301 AC_SUBST(SJAVAC_SERVER_JAVA)
aoqi@0 302
aoqi@0 303 if test "$MEMORY_SIZE" -gt "2500"; then
aoqi@0 304 ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
aoqi@0 305 if test "$JVM_ARG_OK" = true; then
aoqi@0 306 JVM_64BIT=true
aoqi@0 307 JVM_ARG_OK=false
aoqi@0 308 fi
aoqi@0 309 fi
aoqi@0 310
aoqi@0 311 if test "$JVM_64BIT" = true; then
aoqi@0 312 if test "$MEMORY_SIZE" -gt "17000"; then
aoqi@0 313 ADD_JVM_ARG_IF_OK([-Xms10G -Xmx10G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
aoqi@0 314 fi
aoqi@0 315 if test "$MEMORY_SIZE" -gt "10000" && test "$JVM_ARG_OK" = false; then
aoqi@0 316 ADD_JVM_ARG_IF_OK([-Xms6G -Xmx6G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
aoqi@0 317 fi
aoqi@0 318 if test "$MEMORY_SIZE" -gt "5000" && test "$JVM_ARG_OK" = false; then
aoqi@0 319 ADD_JVM_ARG_IF_OK([-Xms1G -Xmx3G],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
aoqi@0 320 fi
aoqi@0 321 if test "$MEMORY_SIZE" -gt "3800" && test "$JVM_ARG_OK" = false; then
aoqi@0 322 ADD_JVM_ARG_IF_OK([-Xms1G -Xmx2500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
aoqi@0 323 fi
aoqi@0 324 fi
aoqi@0 325 if test "$MEMORY_SIZE" -gt "2500" && test "$JVM_ARG_OK" = false; then
aoqi@0 326 ADD_JVM_ARG_IF_OK([-Xms1000M -Xmx1500M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
aoqi@0 327 fi
aoqi@0 328 if test "$MEMORY_SIZE" -gt "1000" && test "$JVM_ARG_OK" = false; then
aoqi@0 329 ADD_JVM_ARG_IF_OK([-Xms400M -Xmx1100M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
aoqi@0 330 fi
aoqi@0 331 if test "$JVM_ARG_OK" = false; then
aoqi@0 332 ADD_JVM_ARG_IF_OK([-Xms256M -Xmx512M],SJAVAC_SERVER_JAVA,[$SJAVAC_SERVER_JAVA])
aoqi@0 333 fi
aoqi@0 334
aoqi@0 335 AC_MSG_CHECKING([whether to use sjavac])
aoqi@0 336 AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac],
aoqi@0 337 [use sjavac to do fast incremental compiles @<:@disabled@:>@])],
aoqi@0 338 [ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no'])
aoqi@0 339 AC_MSG_RESULT([$ENABLE_SJAVAC])
aoqi@0 340 AC_SUBST(ENABLE_SJAVAC)
aoqi@0 341
aoqi@0 342 if test "x$ENABLE_SJAVAC" = xyes; then
aoqi@0 343 SJAVAC_SERVER_DIR="$OUTPUT_ROOT/javacservers"
aoqi@0 344 else
aoqi@0 345 SJAVAC_SERVER_DIR=
aoqi@0 346 fi
aoqi@0 347 AC_SUBST(SJAVAC_SERVER_DIR)
aoqi@0 348 ])

mercurial