Profile-guided optimization
source link: https://rigtorp.se/notes/pgo/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Profile-guided optimization
2020-10-16Profile-guided optimization (PGO), also known as profile-directed feedback (PDF), and feedback-directed optimization (FDO) is a compiler optimization technique in computer programming that uses profiling to improve program runtime performance.
GCC PGO example
Build instrumented binary:
gcc foo.c -o foo_instrumented -fprofile-generate
Run instrumented binary with a representative workload:
./foo_instrumented
Then build optimized binary using generated profile:
gcc -O3 foo.c -o foo -fprofile-use=foo.gcda
Clang PGO example
Build instrumented binary:
clang foo.c -o foo_instrumented -fprofile-generate
clang foo.c -o foo_instrumented -fprofile-instr-generate
Run instrumented binary with a representative workload:
./foo_instrumented
Then build optimized binary using generated profile:
llvm-profdata merge -ouput foo.profdata default.profraw
clang -O3 foo.c -o foo -fprofile-use=foo.profdata
Links
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK