1- # Profile Guided Optimization
1+ # Profile-guided optimization
22
33<!-- toc -->
44
55` rustc ` supports doing profile-guided optimization (PGO).
66This chapter describes what PGO is and how the support for it is
77implemented in ` rustc ` .
88
9- ## What Is Profiled-Guided Optimization ?
9+ ## What is profiled-guided optimization ?
1010
1111The basic concept of PGO is to collect data about the typical execution of
1212a program (e.g. which branches it is likely to take) and then use this data
@@ -52,7 +52,7 @@ instrumentation, via the experimental option
5252[ ` -C instrument-coverage ` ] ( ./llvm-coverage-instrumentation.md ) , but using these
5353coverage results for PGO has not been attempted at this time.
5454
55- ### Overall Workflow
55+ ### Overall workflow
5656
5757Generating a PGO-optimized program involves the following four steps:
5858
@@ -62,12 +62,12 @@ Generating a PGO-optimized program involves the following four steps:
62624 . Compile the program again, this time making use of the profiling data
6363 (e.g. ` rustc -C profile-use=merged.profdata main.rs ` )
6464
65- ### Compile-Time Aspects
65+ ### Compile-time aspects
6666
6767Depending on which step in the above workflow we are in, two different things
6868can happen at compile time:
6969
70- #### Create Binaries with Instrumentation
70+ #### Create binaries with instrumentation
7171
7272As mentioned above, the profiling instrumentation is added by LLVM.
7373` rustc ` instructs LLVM to do so [ by setting the appropriate] [ pgo-gen-passmanager ]
@@ -88,7 +88,7 @@ runtime are not removed [by marking the with the right export level][pgo-gen-sym
8888[pgo-gen-symbols]:https://github.com/rust-lang/rust/blob/1.34.1/src/librustc_codegen_ssa/back/symbol_export.rs#L212-L225
8989
9090
91- #### Compile Binaries Where Optimizations Make Use Of Profiling Data
91+ #### Compile binaries where optimizations make use of profiling data
9292
9393In the final step of the workflow described above, the program is compiled
9494again, with the compiler using the gathered profiling data in order to drive
@@ -106,7 +106,7 @@ LLVM does the rest (e.g. setting branch weights, marking functions with
106106` cold ` or ` inlinehint ` , etc).
107107
108108
109- ### Runtime Aspects
109+ ### Runtime aspects
110110
111111Instrumentation-based approaches always also have a runtime component, i.e.
112112once we have an instrumented program, that program needs to be run in order
@@ -134,7 +134,7 @@ instrumentation artifacts show up in LLVM IR.
134134[ rmake-tests ] : https://github.com/rust-lang/rust/tree/master/tests/run-make
135135[ codegen-test ] : https://github.com/rust-lang/rust/blob/master/tests/codegen/pgo-instrumentation.rs
136136
137- ## Additional Information
137+ ## Additional information
138138
139139Clang's documentation contains a good overview on [ PGO in LLVM] [ llvm-pgo ] .
140140
0 commit comments