Skip to content

Commit 5d13b69

Browse files
committed
[clang][perf-training] Fix profiling with -DCLANG_BOLT=perf
This fixes the llvm-support build that generates the profile data. However, I'm wondering if maybe we should disable llvm-suppot and only run hello-world with -DCLANG_BOLT=perf. The bolt optimizations with perf only give about a 3% performance increase (although maybe with hw counters this would be better) and it takes a very long time to convert all the perf profiles to the fdata format.
1 parent cb61a5e commit 5d13b69

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

clang/utils/perf-training/bolt.lit.cfg

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,32 @@ import subprocess
88

99
clang_bolt_mode = config.clang_bolt_mode.lower()
1010
clang_binary = "clang"
11-
perf_wrapper = f"{config.python_exe} {config.perf_helper_dir}/perf-helper.py perf "
11+
perf_wrapper = f"{config.python_exe} {config.perf_helper_dir}/perf-helper.py perf"
1212

1313
if clang_bolt_mode == "instrument":
1414
perf_wrapper = ""
1515
clang_binary = config.clang_bolt_name
1616
elif clang_bolt_mode == "lbr":
17-
perf_wrapper += " --lbr -- "
17+
perf_wrapper += " --lbr --"
1818
elif clang_bolt_mode == "perf":
19-
perf_wrapper += " -- "
19+
perf_wrapper += " --"
2020
else:
2121
assert 0, "Unsupported CLANG_BOLT_MODE variable"
2222

23-
config.clang = perf_wrapper + os.path.realpath(
23+
clang_nowrapper = os.path.realpath(
2424
lit.util.which(clang_binary, config.clang_tools_dir)
2525
).replace("\\", "/")
26+
config.clang = f'{perf_wrapper} {clang_nowrapper}'
27+
28+
# We need to limit the number of build jobs with perf in order to avoid this
29+
# error:
30+
#
31+
# | Permission error mapping pages.
32+
# | Consider increasing /proc/sys/kernel/perf_event_mlock_kb,
33+
# | or try again with a smaller value of -m/--mmap_pages.
34+
ninja_args = ""
35+
if clang_bolt_mode != "instrument":
36+
ninja_args = "-j1"
2637

2738
config.name = "Clang Perf Training"
2839
config.suffixes = [
@@ -52,3 +63,6 @@ config.substitutions.append(("%test_root", config.test_exec_root))
5263
config.substitutions.append(('%cmake_generator', config.cmake_generator))
5364
config.substitutions.append(('%cmake', config.cmake_exe))
5465
config.substitutions.append(('%llvm_src_dir', config.llvm_src_dir))
66+
config.substitutions.append(('%perf_cmake_compiler_launcher', perf_wrapper.replace(' ', ';')))
67+
config.substitutions.append(('%nowrapper_clang', clang_nowrapper))
68+
config.substitutions.append(('%ninja_args', ninja_args))
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
RUN: %cmake -G %cmake_generator -B %t -S %llvm_src_dir -DCMAKE_C_COMPILER=%clang -DCMAKE_CXX_COMPILER=%clang -DCMAKE_CXX_FLAGS="--driver-mode=g++" -DCMAKE_BUILD_TYPE=Release
2-
RUN: %cmake --build %t -v --target LLVMSupport
1+
RUN: %cmake -G %cmake_generator -B %t -S %llvm_src_dir -DCMAKE_CXX_COMPILER_LAUNCHER="%perf_cmake_compiler_launcher" -DCMAKE_C_COMPILER="%nowrapper_clang" -DCMAKE_CXX_COMPILER="%nowrapper_clang" -DCMAKE_CXX_FLAGS="--driver-mode=g++" -DCMAKE_BUILD_TYPE=Release
2+
RUN: %cmake --build %t %ninja_args -v --target LLVMSupport

0 commit comments

Comments
 (0)