[llvm] [IPO] NFC: avoid recalculating FunctionId hashes (PR #109014)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 10:11:55 PDT 2024


itrofimow wrote:

At my workplace we operate over huge binaries, which produce large sampling profiles (hundreds of MB in text format is not uncommon).

Compiling a no-op code
```
itrofimow at itrofimow-nix:~/work/profile_sample_use/clang_test$ cat main.cpp 
#include <iostream>

int main() {
	std::cout << "Hello!\n" << std::endl;

	return 0;
}
```
with such profiles takes
```
itrofimow at itrofimow-nix:~/work/profile_sample_use/clang_test$ time taskset -c 2 /home/itrofimow/work/llvm-project/clang_build/bin/clang++ -o main -O3 -fprofile-sample-use=/home/itrofimow/work/perfs/autofdo/15_09_2024/123MB.pgo.txt main.cpp

real	0m2.216s
user	0m2.084s
sys	0m0.132s
itrofimow at itrofimow-nix:~/work/profile_sample_use/clang_test$ time taskset -c 2 /home/itrofimow/work/llvm-project/clang_build/bin/clang++ -o main -O3 -fprofile-sample-use=/home/itrofimow/work/perfs/autofdo/15_09_2024/189MB.pgo.txt main.cpp

real	0m3.289s
user	0m3.068s
sys	0m0.214s
```
on current llvm main, and most of time time is spent in `ProfiledCallGraph` construction.

With this patch applied I'm seeing following numbers
```
itrofimow at itrofimow-nix:~/work/profile_sample_use/clang_test$ time taskset -c 2 /home/itrofimow/work/llvm-project/clang_build/bin/clang++ -o main -O3 -fprofile-sample-use=/home/itrofimow/work/perfs/autofdo/15_09_2024/123MB.pgo.txt main.cpp

real	0m1.753s
user	0m1.599s
sys	0m0.154s
itrofimow at itrofimow-nix:~/work/profile_sample_use/clang_test$ time taskset -c 2 /home/itrofimow/work/llvm-project/clang_build/bin/clang++ -o main -O3 -fprofile-sample-use=/home/itrofimow/work/perfs/autofdo/15_09_2024/189MB.pgo.txt main.cpp

real	0m2.620s
user	0m2.395s
sys	0m0.222s
```
which is ~20% speed up.

Please see the flamegraphs (warning: huge (15Mb) .svg files): [trunk](https://github.com/itrofimow/random_assets/blob/main/clang_main_123M.svg), [patch](https://github.com/itrofimow/random_assets/blob/main/clang_patch_123M.svg)

https://github.com/llvm/llvm-project/pull/109014


More information about the llvm-commits mailing list