about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-05-18 09:53:01 +0000
committerbors <bors@rust-lang.org>2022-05-18 09:53:01 +0000
commite5732a21711e7cefa6eb22e1790406b269d6197a (patch)
treecccaec23c5800064b0927d212a5e7013d6fd69ec
parenta084b7ad35adb508bd2e053fc2a1b9a53df9536c (diff)
parent19a35588156debc0e3ac8e8ccd412c0bb2983b4e (diff)
downloadrust-e5732a21711e7cefa6eb22e1790406b269d6197a.tar.gz
rust-e5732a21711e7cefa6eb22e1790406b269d6197a.zip
Auto merge of #97110 - Kobzol:pgo-pid-in-profile, r=lqd
Add PID to PGO profile data filename

After experimenting with PGO, it looks like the generated profile data files can be sometimes overwritten if there is a race condition, because multiple `rustc` processes are usually invoked in parallel by `cargo`. Adding the PID to the resulting profile filename pattern makes sure that the profiles will be stored in separate files.

This generates ~20 GiB more space on disk on the CI run, but that seems harmless (?). Merging the profiles is not a bottleneck, the perf. run took the same amount of time as usually (~1h 24m).

r? `@lqd`
-rwxr-xr-xsrc/ci/pgo.sh6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ci/pgo.sh b/src/ci/pgo.sh
index 691d1282cf4..aedfe98bdea 100755
--- a/src/ci/pgo.sh
+++ b/src/ci/pgo.sh
@@ -82,7 +82,11 @@ python3 ../x.py build --target=$PGO_HOST --host=$PGO_HOST \
 
 # Here we're profiling the `rustc` frontend, so we also include `Check`.
 # The benchmark set includes various stress tests that put the frontend under pressure.
-gather_profiles "Check,Debug,Opt" "All" \
+# The profile data is written into a single filepath that is being repeatedly merged when each
+# rustc invocation ends. Empirically, this can result in some profiling data being lost.
+# That's why we override the profile path to include the PID. This will produce many more profiling
+# files, but the resulting profile will produce a slightly faster rustc binary.
+LLVM_PROFILE_FILE=/tmp/rustc-pgo/default_%m_%p.profraw gather_profiles "Check,Debug,Opt" "All" \
   "externs,ctfe-stress-4,cargo-0.60.0,token-stream-stress,match-stress,tuple-stress"
 
 # Merge the profile data we gathered