Profile-guided optimization (PGO) is a common optimization technique for ahead-of-time compilers. It works by collecting data about a programs typical execution (e.g. probability of branches taken, typical runtime values of variables, etc) and then uses this information during program optimization for things like inlining decisions, machine code layout, or indirect call promotion.
LLVM supports different forms of PGO, the most effective of which relies on generating instrumented binaries that collect the profiling information. The Rust compiler has had experimental support for this via the -Z pgo-gen and -Z pgo-use flags for a while. This issue tracks the progress of making this functionality available in stable Rust.
Steps:
Non-Goals:
Further Information:
cc @rust-lang/core @rust-lang/compiler
Profile-guided optimization (PGO) is a common optimization technique for ahead-of-time compilers. It works by collecting data about a programs typical execution (e.g. probability of branches taken, typical runtime values of variables, etc) and then uses this information during program optimization for things like inlining decisions, machine code layout, or indirect call promotion.
LLVM supports different forms of PGO, the most effective of which relies on generating instrumented binaries that collect the profiling information. The Rust compiler has had experimental support for this via the
-Z pgo-genand-Z pgo-useflags for a while. This issue tracks the progress of making this functionality available in stable Rust.Steps:
run-maketest that makes sure thatinlineandcoldattributes are added to LLVM IR by LLVM's PGO passes. ( PGO: Add a run-make test that makes sure that PGO profiling data is used by the compiler during optimizations. #60262)codegentest making sure that instrumentation is generated as expected. (Add codegen test for PGO instrumentation. #60038)run-maketest that makes sure PGO works in a mixed Rust/C++ codebase using ThinLTO done vialld. (PGO - Add a smoketest for combining PGO with cross-language LTO. #61036)rustcalready behaves like Clang here: Pre-inlining is enabled except for-Copt-level=sand-Copt-level=z.-Z pgo-gencommandline option. #59874)-C profile-generateand-C profile-useflags (mirroring the corresponding Clang flags).Non-Goals:
Further Information:
cc @rust-lang/core @rust-lang/compiler