-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8365053: Refresh hotspot precompiled.hpp with headers based on current frequency #26681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 32 commits
9e0cb7e
a75494f
d6cd068
5672a1b
310694d
5c8179d
5bdafcf
6c9351a
93e4190
edb73e3
dba3a6a
3546dd1
3d78b32
71950ae
3116b39
fbdb011
be25d34
9cae4f5
c0b8c27
fb260ab
892ecb5
733df91
df0a71d
9d7c7ba
aea7c79
ba6f372
2f97d57
4a2ff56
32e7d31
e5029bf
64c6db9
cad1239
b674928
6693cef
ead2c77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
#!/bin/sh | ||
# Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. | ||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
# | ||
# This code is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU General Public License version 2 only, as | ||
# published by the Free Software Foundation. | ||
# | ||
# This code is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# version 2 for more details (a copy is included in the LICENSE file that | ||
# accompanied this code). | ||
# | ||
# You should have received a copy of the GNU General Public License version | ||
# 2 along with this work; if not, write to the Free Software Foundation, | ||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
# or visit www.oracle.com if you need additional information or have any | ||
# questions. | ||
|
||
# The output of this script may require some degree of human curation: | ||
# - Redundant headers, e.g. both x.hpp, x.inline.hpp are included; | ||
# - Headers relative to a non-default feature should be protected by an | ||
# appropriate 'if' clause to make sure all variants can build without | ||
# errors. | ||
|
||
# Time threshold for header compilation, if the time exceeds the | ||
# threshold the header will be precompiled. | ||
if [ -z "$MIN_MS" ]; then | ||
MIN_MS=100000 | ||
fi | ||
|
||
if [ -z "$CLEAN" ]; then | ||
CLEAN=true | ||
elif [ "$CLEAN" != "true" ] && [ "$CLEAN" != "false" ]; then | ||
echo "Expected either 'true' or 'false' for CLEAN" | ||
fi | ||
|
||
# CBA_PATH should point to a valid ClangBuildAnalyzer executable. | ||
# Build steps: | ||
# git clone --depth 1 [email protected]:aras-p/ClangBuildAnalyzer.git | ||
# cd ClangBuildAnalyzer | ||
# make -f projects/make/Makefile | ||
if [ -z "$CBA_PATH" ]; then | ||
CBA_PATH="./ClangBuildAnalyzer/build/ClangBuildAnalyzer" | ||
fi | ||
|
||
set -eux | ||
|
||
PRECOMPILED_HPP="src/hotspot/share/precompiled/precompiled.hpp" | ||
CBA_CONFIG="ClangBuildAnalyzer.ini" | ||
TIMESTAMP="$(date +%Y%m%d-%H%M)" | ||
RUN_NAME="pch_update_$TIMESTAMP" | ||
CBA_OUTPUT="cba_out_$TIMESTAMP" | ||
|
||
if [ "$CLEAN" = "true" ]; then | ||
trap 'rm -rf "build/'"$RUN_NAME"'" "$CBA_OUTPUT" "$CBA_CONFIG"' EXIT | ||
fi | ||
|
||
sh configure --with-toolchain-type=clang \ | ||
--with-conf-name="$RUN_NAME" \ | ||
--disable-precompiled-headers \ | ||
--with-extra-cxxflags="-ftime-trace" \ | ||
--with-extra-cflags="-ftime-trace" | ||
|
||
make clean CONF_NAME="$RUN_NAME" | ||
make -j hotspot CONF_NAME="$RUN_NAME" | ||
"$CBA_PATH" --all "./build/$RUN_NAME/hotspot/variant-server/libjvm/objs" \ | ||
"$CBA_OUTPUT" | ||
|
||
# Preserve license and comments on top | ||
cat "$PRECOMPILED_HPP" | awk '/^#include/ {exit} {print}' > "$PRECOMPILED_HPP.tmp" | ||
|
||
if [ ! -f "$CBA_CONFIG" ]; then | ||
cat <<EOF > "$CBA_CONFIG" | ||
[counts] | ||
header=100 | ||
headerChain=0 | ||
template=0 | ||
function=0 | ||
fileCodegen=0 | ||
fileParse=0 | ||
|
||
[misc] | ||
onlyRootHeaders=true | ||
EOF | ||
fi | ||
|
||
"$CBA_PATH" --analyze "$CBA_OUTPUT" | \ | ||
grep " ms: " | \ | ||
# Keep the headers more expensive than ${1}ms | ||
awk -v x="$MIN_MS" '$1 < x { exit } { print $3 }' | \ | ||
# Filter away non-hotspot headers | ||
grep hotspot/share | \ | ||
sort | \ | ||
awk -F "hotspot/share/" '{ printf "#include \"%s\"\n", $2 }' \ | ||
>> "$PRECOMPILED_HPP.tmp" | ||
mv "$PRECOMPILED_HPP.tmp" "$PRECOMPILED_HPP" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,53 +25,27 @@ | |
// Precompiled headers are turned off if the user passes | ||
// --disable-precompiled-headers to configure. | ||
|
||
// These header files are included in at least 130 C++ files, as of | ||
// measurements made in November 2018. This list excludes files named | ||
fandreuz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// *.inline.hpp, since including them decreased build performance. | ||
// These header files are selected using the output of Clang | ||
// '-ftime-trace' as a measure of how much time we spend | ||
// compiling them. | ||
|
||
#include "classfile/classLoaderData.hpp" | ||
#include "classfile/javaClasses.hpp" | ||
#include "classfile/systemDictionary.hpp" | ||
#include "gc/shared/collectedHeap.hpp" | ||
#include "gc/shared/gcCause.hpp" | ||
#include "logging/log.hpp" | ||
#include "classfile/javaClasses.inline.hpp" | ||
#include "memory/allocation.hpp" | ||
#include "memory/iterator.hpp" | ||
#include "memory/memRegion.hpp" | ||
#include "memory/resourceArea.hpp" | ||
#include "memory/universe.hpp" | ||
#include "nmt/memTracker.hpp" | ||
#include "oops/instanceKlass.hpp" | ||
#include "oops/klass.hpp" | ||
#include "oops/method.hpp" | ||
#include "oops/objArrayKlass.hpp" | ||
#include "oops/objArrayOop.hpp" | ||
#include "oops/oop.hpp" | ||
#include "oops/oopsHierarchy.hpp" | ||
#include "runtime/atomic.hpp" | ||
#include "runtime/globals.hpp" | ||
#include "runtime/handles.hpp" | ||
#include "runtime/javaThread.hpp" | ||
#include "runtime/mutex.hpp" | ||
#include "runtime/orderAccess.hpp" | ||
#include "runtime/os.hpp" | ||
#include "runtime/timer.hpp" | ||
#include "utilities/align.hpp" | ||
#include "utilities/bitMap.hpp" | ||
#include "utilities/copy.hpp" | ||
#include "utilities/debug.hpp" | ||
#include "utilities/exceptions.hpp" | ||
#include "utilities/globalDefinitions.hpp" | ||
#include "utilities/growableArray.hpp" | ||
#include "utilities/macros.hpp" | ||
#include "utilities/ostream.hpp" | ||
#include "utilities/ticks.hpp" | ||
|
||
#ifdef TARGET_COMPILER_visCPP | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the reported testing was on Linux. These were included specifically because measurements There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed, Visual Studio is the place where PCH is most needed. I see Erik says he tested on Windows with no difference. While he concluded that this means no regression, I see it as a missed opportunity. Giving the Windows platform a bit of extra love can probably increase compilation speed where it is needed the most. |
||
// For Visual Studio, including the *.inline.hpp files actually | ||
// increased performance. | ||
#include "memory/allocation.inline.hpp" | ||
#include "memory/iterator.inline.hpp" | ||
#include "oops/access.inline.hpp" | ||
#include "oops/instanceStackChunkKlass.inline.hpp" | ||
#include "oops/objArrayOop.inline.hpp" | ||
#include "oops/oopHandle.inline.hpp" | ||
#include "oops/oop.inline.hpp" | ||
#include "runtime/handles.inline.hpp" | ||
#endif // TARGET_COMPILER_visCPP | ||
#include "runtime/frame.inline.hpp" | ||
#include "runtime/javaThread.inline.hpp" | ||
#include "utilities/globalDefinitions.hpp" | ||
#if INCLUDE_SHENANDOAHGC | ||
#include "gc/shenandoah/shenandoahBarrierSet.inline.hpp" | ||
#include "gc/shenandoah/shenandoahHeap.inline.hpp" | ||
#endif | ||
#if INCLUDE_ZGC | ||
#include "gc/z/zBarrier.inline.hpp" | ||
#include "gc/z/zGeneration.inline.hpp" | ||
#include "gc/z/zHeap.inline.hpp" | ||
#endif |
Uh oh!
There was an error while loading. Please reload this page.