Introducing Profi into Rustc for better Sample PGO quality
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Hi!
Profi is an algorithm for improving Sample PGO profile quality by clever heuristics (more details read in the Reference in "Profi implementation". This functionality is already implemented in LLVM and integrated into Clang's PGO pipeline. Rust is lacking such of functionality for now.
Clang has -fsample-profile-use-profi flag. Clang already enabled using Profi default for Sample PGO use case 1 year.
At the moment, Profi can still be used with Rust by passing an additional LLVM flag: -Cllvm-args=-sample-profile-use-profi but I haven't tested it with Rustc yet.
Open questions:
- Do we want to introduce an alternative to
-fsample-profile-use-profi/-fno-sample-profile-use-profiinto the Rustc compiler? - Do we want to enable Profi for Sample PGO by default? If yes, do we need to introduce flags to disable this behavior explicitly (see previous point). In this case, we can provide better Sample PGO experience for an average user - they don't need to know about an additional hidden LLVM argument that improves Sample PGO quality. At the moment, I have a draft commit about enabling it by default in my Rust fork: commit. We can partially mitigate it by adding such flags as a part of
cargo-pgobut it's another discussion topic (especially sincecargo-pgodoesn't support Sample PGO flow). - Do we need more evidence about Profi efficiency from practice? It's kinda difficult to find any evidency even for Clang. But in theory, Profi is a good idea.
Some references:
- Profi implementation commits in LLVM: one, two, three
- Adding
-fsample-profile-use-profiflag into Clang: commit - Enabling using Profi by default in Clang: PR
- Adding
-fno-sample-profile-use-profiflag: PR - Some benchmarks about Profi efficiency: ChromeOS results, more results
Kindly pinging @ojeda since that functionality could be interesting for their use case too (even if seems like Google uses another approach internally). Maybe this approach with flow-sensitive discriminators should be pushed instead? Especially since exactly this approach is used in Rust-for-Linux.
Thank you.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing rustc's Sample PGO handling and the existing -Cllvm-args=-sample-profile-use-profi entry point, then compare it with Clang's -fsample-profile-use-profi and the linked LLVM changes. The draft commit and benchmark references provide context; done requires a decided Rust interface or default behavior, evidence requirements, and corresponding implementation and tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100