Skip to content

Commit 15f0149

Browse files
committed
feat(docs): add cargo-pgo to PGO documentation 📝
1 parent 484cb4e commit 15f0149

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/doc/rustc/src/profile-guided-optimization.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,25 @@ in Clang's documentation is therefore an interesting read for anyone who wants
145145
to use PGO with Rust.
146146

147147
[clang-pgo]: https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization
148+
149+
## Community Maintained Tools
150+
151+
As an alternative to directly using the compiler for Profile-Guided Optimization,
152+
you may choose to go with `cargo-pgo`, which has an intuitive command-line API
153+
and saves you the trouble of doing all the manual work. You can read more about
154+
it in their repository accessible from this link: https://github.com/Kobzol/cargo-pgo
155+
156+
For the sake of completeness, here are the corresponding steps using `cargo-pgo`:
157+
158+
```bash
159+
# Install the binary as usual: cargo install cargo-pgo
160+
cargo pgo build
161+
LLVM_PROFILE_FILE=./target/pgo-profiles/rustc-pgo_%m_%p.profraw ./target/x86_64-unknown-linux-gnu/release/myprogram
162+
cargo pgo optimize
163+
```
164+
165+
These steps will do the following just as before:
166+
167+
1. Build an instrumented binary from the source code.
168+
2. Use the instrumentation in the binary when running it for the first time.
169+
3. Use the instrumentation results from the last step to create an optimized binary.

0 commit comments

Comments
 (0)