From 15f0149c3ea7338b829663ec76c2160ea5730087 Mon Sep 17 00:00:00 2001 From: Meysam Azad Date: Sun, 20 Aug 2023 14:54:16 +0700 Subject: [PATCH 1/4] =?UTF-8?q?feat(docs):=20add=20cargo-pgo=20to=20PGO=20?= =?UTF-8?q?documentation=20=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rustc/src/profile-guided-optimization.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/doc/rustc/src/profile-guided-optimization.md b/src/doc/rustc/src/profile-guided-optimization.md index d9cf7ce30f936..465a26a1301be 100644 --- a/src/doc/rustc/src/profile-guided-optimization.md +++ b/src/doc/rustc/src/profile-guided-optimization.md @@ -145,3 +145,25 @@ in Clang's documentation is therefore an interesting read for anyone who wants to use PGO with Rust. [clang-pgo]: https://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization + +## Community Maintained Tools + +As an alternative to directly using the compiler for Profile-Guided Optimization, +you may choose to go with `cargo-pgo`, which has an intuitive command-line API +and saves you the trouble of doing all the manual work. You can read more about +it in their repository accessible from this link: https://github.com/Kobzol/cargo-pgo + +For the sake of completeness, here are the corresponding steps using `cargo-pgo`: + +```bash +# Install the binary as usual: cargo install cargo-pgo +cargo pgo build +LLVM_PROFILE_FILE=./target/pgo-profiles/rustc-pgo_%m_%p.profraw ./target/x86_64-unknown-linux-gnu/release/myprogram +cargo pgo optimize +``` + +These steps will do the following just as before: + +1. Build an instrumented binary from the source code. +2. Use the instrumentation in the binary when running it for the first time. +3. Use the instrumentation results from the last step to create an optimized binary. From 29ec0ec4a6fb72dcb61e1cd1b1b4bb7aa0da9351 Mon Sep 17 00:00:00 2001 From: Meysam Date: Wed, 25 Oct 2023 08:43:06 +0700 Subject: [PATCH 2/4] Update src/doc/rustc/src/profile-guided-optimization.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jakub Beránek --- src/doc/rustc/src/profile-guided-optimization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/profile-guided-optimization.md b/src/doc/rustc/src/profile-guided-optimization.md index 465a26a1301be..951dda03e80de 100644 --- a/src/doc/rustc/src/profile-guided-optimization.md +++ b/src/doc/rustc/src/profile-guided-optimization.md @@ -165,5 +165,5 @@ cargo pgo optimize These steps will do the following just as before: 1. Build an instrumented binary from the source code. -2. Use the instrumentation in the binary when running it for the first time. +2. Run the instrumented binary to gather PGO profiles. 3. Use the instrumentation results from the last step to create an optimized binary. From 3ecc8c37d428979206b302e3b7e0a15a8a62c638 Mon Sep 17 00:00:00 2001 From: Meysam Date: Wed, 25 Oct 2023 08:43:21 +0700 Subject: [PATCH 3/4] Update src/doc/rustc/src/profile-guided-optimization.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jakub Beránek --- src/doc/rustc/src/profile-guided-optimization.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/profile-guided-optimization.md b/src/doc/rustc/src/profile-guided-optimization.md index 951dda03e80de..781b89d715385 100644 --- a/src/doc/rustc/src/profile-guided-optimization.md +++ b/src/doc/rustc/src/profile-guided-optimization.md @@ -166,4 +166,4 @@ These steps will do the following just as before: 1. Build an instrumented binary from the source code. 2. Run the instrumented binary to gather PGO profiles. -3. Use the instrumentation results from the last step to create an optimized binary. +3. Use the gathered PGO profiles from the last step to build an optimized binary. From 515535a657b823491b6f8b2c79788988c8b7306f Mon Sep 17 00:00:00 2001 From: Meysam Date: Wed, 25 Oct 2023 08:44:50 +0700 Subject: [PATCH 4/4] Update profile-guided-optimization.md --- src/doc/rustc/src/profile-guided-optimization.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc/src/profile-guided-optimization.md b/src/doc/rustc/src/profile-guided-optimization.md index 781b89d715385..38b655b75422b 100644 --- a/src/doc/rustc/src/profile-guided-optimization.md +++ b/src/doc/rustc/src/profile-guided-optimization.md @@ -156,9 +156,10 @@ it in their repository accessible from this link: https://github.com/Kobzol/carg For the sake of completeness, here are the corresponding steps using `cargo-pgo`: ```bash -# Install the binary as usual: cargo install cargo-pgo +# Install if you haven't already +cargo install cargo-pgo + cargo pgo build -LLVM_PROFILE_FILE=./target/pgo-profiles/rustc-pgo_%m_%p.profraw ./target/x86_64-unknown-linux-gnu/release/myprogram cargo pgo optimize ```