rust-lang / rust-lang/rust

Add Context-Sensitive IR PGO (CSIR PGO)

Open
#118,562 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LLVM C-enhancement C-optimization T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Clang has support for an additional PGO mode - Context-Sensitive PGO. This is completely the same way as now used by Rustc but the main difference is when instrumentation is done. In usual (IR PGO) instrumentation is done before the inlining phase, with CSIR PGO - after the inlining phase. This could be important since the inlining decisions can introduce some noise into the profiling information.

In https://github.com/llvm/llvm-project/issues/56274#issuecomment-1407117774 comment, there is a small insight into the actual effects on the performance. According to this, we can treat CSIR PGO as a light replacement for LLVM BOLT optimization. For some people, it could be important since LLVM BOLT does not work on all platforms.

Right now it's not clear, could we implement CSIR PGO by just passing the right LLVM flag, or some frontend changes are required too? I guess some CSIR PGO implementation in Clang is required here. In any way, CSIR PGO information should be added to the Rustc PGO documentation.

CSIR PGO also was mentioned in the initial PGO issue for Rustc: https://github.com/rust-lang/rust/issues/59913#issue-432504990

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Rustc PGO documentation and Clang's UsersManual CS profile-generation section, then review the linked Rust and LLVM issue discussions. Determine whether CSIR PGO needs Rustc frontend changes or only an LLVM flag; done means the mode works in Rustc and its documentation explains how to use it.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.