common/autoconf/build-performance.m4

Mon, 29 Jun 2020 21:30:12 +0100

author
andrew
date
Mon, 29 Jun 2020 21:30:12 +0100
changeset 2537
a8da94d779b3
parent 2451
2cd484c5b7f8
child 2458
daa47f8cf745
permissions
-rw-r--r--

Merge

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

mercurial