- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15k
[BOLT] Match functions with pseudo probes #100446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            shawbyoung
  wants to merge
  13
  commits into
  users/shawbyoung/spr/main.bolt-match-functions-with-pseudo-probes
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
users/shawbyoung/spr/bolt-match-functions-with-pseudo-probes
  
      
      
   
  
    
  
  
  
 
  
      
    base: users/shawbyoung/spr/main.bolt-match-functions-with-pseudo-probes
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
                
     Open
            
            [BOLT] Match functions with pseudo probes #100446
                    shawbyoung
  wants to merge
  13
  commits into
  users/shawbyoung/spr/main.bolt-match-functions-with-pseudo-probes
from
users/shawbyoung/spr/bolt-match-functions-with-pseudo-probes
  
      
      
   
              
            Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    Created using spr 1.3.4
Created using spr 1.3.4
Created using spr 1.3.4
Created using spr 1.3.4
…BF, determine best matching binary inline subtrees, find corresponding binary functions, attach the profile to binary function without a profile and most probes Created using spr 1.3.4
Created using spr 1.3.4
Created using spr 1.3.4
| ✅ With the latest revision this PR passed the C/C++ code formatter. | 
Created using spr 1.3.4
    
  aaupov 
      added a commit
      that referenced
      this pull request
    
      Nov 12, 2024 
    
    
      
  
    
      
    
  
Match inline trees first between profile and the binary: by GUID,
checksum, parent, and inline site for inlined functions. Map profile
probes to binary probes via matched inline tree nodes. Each binary probe
has an associated binary basic block. If all probes from one profile
basic block map to the same binary basic block, it’s an exact match,
otherwise the block is determined by majority vote and reported as loose
match.
Pseudo probe matching happens between exact hash matching and call/loose
matching.
Introduce ProbeMatchSpec - a mechanism to match probes belonging to
another binary function. For example, given functions foo and bar:
```
void foo() {
  bar();
}
```
profiled binary: bar is not inlined => have top-level function bar
new binary where the profile is applied to: bar is inlined into foo.
Currently, BOLT does 1:1 matching between profile functions and binary
functions based on the name. #100446 will extend this to N:M where
multiple profiles can be matched to one binary function (as in the
example above where binary function foo would use profiles for foo and
bar), and one profile can be matched to multiple binary functions (e.g.
if bar was inlined into multiple functions).
In this diff, ProbeMatchSpecs would only have one BinaryFunctionProfile
(existing name-based matching). 
Test Plan: Added match-blocks-with-pseudo-probes.test
Performance test:
- Setup:
  - Baseline no-BOLT: Clang with pseudo probes, ThinLTO + CSSPGO
  (#79942)
  - BOLT fresh: BOLTed Clang using fresh profile,
  - BOLT stale (hash): BOLTed Clang using stale profile (collected on
    Clang 10K commits back), `-infer-stale-profile` (hash+call block
    matching)
  - BOLT stale (+probe): BOLTed Clang using stale profile,
    `-infer-stale-profile` with `-stale-matching-with-pseudo-probes`
    (hash+call+pseudo probe block matching)
  - 2S Intel SKX Xeon 6138 with 40C/80T and 256GB RAM, using 20C/40T for
    build,
  - BOLT profiles are collected on Clang compiling large preprocessed
    C++ file.
- Benchmark: building Clang (average of 5 runs), see driver in
  aaupov/llvm-devmtg-2022
- Results, wall time, lower is better:
  - Baseline no-BOLT: 429.52 +- 2.61s,
  - BOLT stale (hash): 413.21 +- 2.19s,
  - BOLT stale (+probe): 409.69 +- 1.41s,
  - BOLT fresh: 384.50 +- 1.80s.
---------
Co-authored-by: Amir Ayupov <[email protected]>
    Created using spr 1.3.4
  This was referenced Oct 28, 2025 
      
Created using spr 1.3.4
Created using spr 1.3.4
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Extended function and block pseudo probe stale matching
This change brings flexible profile recovery using pseudo probes:
function inlines profile functions,
the profile has more aggressive inlining compared to the input binary.
Prerequisites
--profile-write-pseudo-probesperf2bolt flag.
--stale-matching-with-pseudo-probeswhich augments hash-basedmatching + profile inference enabled with
--infer-stale-profile(required).
-fpseudo-probe-for-profilingClang option.Performance testing
with different profiles causing different inlining decisions,
build,
Depends on:
Co-authored-by: [email protected]