about summary refs log tree commit diff
path: root/src/ci
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2022-10-02 09:44:04 +0200
committerJakub Beránek <berykubik@gmail.com>2022-10-09 11:31:09 +0200
commitcc475f5ef2988e9db2e3ce07bd4abd4d4975f3e7 (patch)
tree2df853cb704529a98049f911118c3d0a3219e6d6 /src/ci
parent72f4923979979abb5d6b975353e9b3053d257e60 (diff)
downloadrust-cc475f5ef2988e9db2e3ce07bd4abd4d4975f3e7.tar.gz
rust-cc475f5ef2988e9db2e3ce07bd4abd4d4975f3e7.zip
Use BOLT in x64 dist CI to optimize LLVM
Diffstat (limited to 'src/ci')
-rwxr-xr-xsrc/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh4
-rwxr-xr-xsrc/ci/pgo.sh39
2 files changed, 36 insertions, 7 deletions
diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh
index fa780e1e45e..9abfd4e9731 100755
--- a/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh
+++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh
@@ -22,7 +22,7 @@ INC="/rustroot/include:/usr/include"
 
 # We need compiler-rt for the profile runtime (used later to PGO the LLVM build)
 # but sanitizers aren't currently building. Since we don't need those, just
-# disable them.
+# disable them. BOLT is used for optimizing LLVM.
 hide_output \
     cmake ../llvm \
       -DCMAKE_C_COMPILER=/rustroot/bin/gcc \
@@ -36,7 +36,7 @@ hide_output \
       -DLLVM_INCLUDE_BENCHMARKS=OFF \
       -DLLVM_INCLUDE_TESTS=OFF \
       -DLLVM_INCLUDE_EXAMPLES=OFF \
-      -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" \
+      -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;bolt" \
       -DC_INCLUDE_DIRS="$INC"
 
 hide_output make -j$(nproc)
diff --git a/src/ci/pgo.sh b/src/ci/pgo.sh
index b60b7868d06..cbe32920a74 100755
--- a/src/ci/pgo.sh
+++ b/src/ci/pgo.sh
@@ -190,11 +190,40 @@ rm -r $RUSTC_PROFILE_DIRECTORY_ROOT
 # directories ourselves.
 rm -r $BUILD_ARTIFACTS/llvm $BUILD_ARTIFACTS/lld
 
-# This produces the actual final set of artifacts, using both the LLVM and rustc
-# collected profiling data.
-$@ \
-    --rust-profile-use=${RUSTC_PROFILE_MERGED_FILE} \
-    --llvm-profile-use=${LLVM_PROFILE_MERGED_FILE}
+if isLinux; then
+  # Gather BOLT profile (BOLT is currently only available on Linux)
+  python3 ../x.py build --target=$PGO_HOST --host=$PGO_HOST \
+      --stage 2 library/std \
+      --llvm-profile-use=${LLVM_PROFILE_MERGED_FILE} \
+      --llvm-bolt-profile-generate
+
+  BOLT_PROFILE_MERGED_FILE=/tmp/bolt.profdata
+
+  # Here we're profiling Bolt.
+  gather_profiles "Check,Debug,Opt" "Full" \
+  "syn-1.0.89,serde-1.0.136,ripgrep-13.0.0,regex-1.5.5,clap-3.1.6,hyper-0.14.18"
+
+  merge-fdata /tmp/prof.fdata* > ${BOLT_PROFILE_MERGED_FILE}
+
+  echo "BOLT statistics"
+  du -sh /tmp/prof.fdata*
+  du -sh ${BOLT_PROFILE_MERGED_FILE}
+  echo "Profile file count"
+  find /tmp/prof.fdata* -type f | wc -l
+
+  rm -r $BUILD_ARTIFACTS/llvm $BUILD_ARTIFACTS/lld
+
+  # This produces the actual final set of artifacts, using both the LLVM and rustc
+  # collected profiling data.
+  $@ \
+      --rust-profile-use=${RUSTC_PROFILE_MERGED_FILE} \
+      --llvm-profile-use=${LLVM_PROFILE_MERGED_FILE} \
+      --llvm-bolt-profile-use=${BOLT_PROFILE_MERGED_FILE}
+else
+  $@ \
+      --rust-profile-use=${RUSTC_PROFILE_MERGED_FILE} \
+      --llvm-profile-use=${LLVM_PROFILE_MERGED_FILE}
+fi
 
 echo "Rustc binary size"
 ls -la ./build/$PGO_HOST/stage2/bin