Optimize java JVM with AutoFDO for OpenJDK 21
Enable AutoFDO for OpenJDK 21. We also try to optimize with FSautofdo
but AutoFDO performs better. The followup is to investigate why
FSautofdo performs worse.
Bug: b/228432840
Test: 1.add some flags and use perf record to get perf.data 2.use this tool https://github.com/google/autofdo to convert perf.data to .prof file 3.and then update prebuilt in android internal and
test build time
Change-Id: I5093ffaad2097cdebe7fa542a28de7001843db1c
diff --git a/build-openjdk21-linux.sh b/build-openjdk21-linux.sh
index e41afa6..9d39f14 100755
--- a/build-openjdk21-linux.sh
+++ b/build-openjdk21-linux.sh
@@ -45,6 +45,7 @@
declare -r build_dir="$out_path/build"
declare -r top=$(realpath "$(dirname "$0")/../../..")
declare -r clang_bin="$top/prebuilts/clang/host/linux-x86/clang-r522817/bin"
+declare -r profdata="$top/toolchain/jdk/build/openjdk21.prof"
# "Installs" given Debian packages into specified directory.
function unpack_dependencies() {
@@ -52,7 +53,7 @@
local -r ar="$clang_bin/llvm-ar"
shift
mkdir -p "$target_dir"
-
+
for deb in "$@"; do
# Debian package is actually 'ar' archive. The package files are in data.tar.<type>
# member. Extract and untar it.
@@ -117,9 +118,9 @@
--with-zlib=bundled \
--x-libraries="$sysroot/usr/lib/x86_64-linux-gnu" \
--x-includes="$sysroot/usr/include" \
- --with-extra-cflags="--sysroot=$sysroot -fno-delete-null-pointer-checks -flto=full" \
- --with-extra-cxxflags="--sysroot=$sysroot -fno-delete-null-pointer-checks -flto=full" \
- --with-extra-ldflags="--sysroot=$sysroot -fuse-ld=lld -flto=full" \
+ --with-extra-cflags="--sysroot=$sysroot -fno-delete-null-pointer-checks -flto=full -gline-tables-only -fdebug-info-for-profiling -funique-internal-linkage-names -fprofile-sample-use=$profdata" \
+ --with-extra-cxxflags="--sysroot=$sysroot -fno-delete-null-pointer-checks -flto=full -gline-tables-only -fdebug-info-for-profiling -funique-internal-linkage-names -fprofile-sample-use=$profdata" \
+ --with-extra-ldflags="--sysroot=$sysroot -fuse-ld=lld -flto=full -gline-tables-only -fdebug-info-for-profiling -funique-internal-linkage-names -fprofile-sample-use=$profdata" \
AR=llvm-ar NM=llvm-nm OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump STRIP=llvm-strip
)
diff --git a/openjdk21.prof b/openjdk21.prof
new file mode 100644
index 0000000..f5d14fd
--- /dev/null
+++ b/openjdk21.prof
Binary files differ