[all-commits] [llvm/llvm-project] 9a9af0: [BOLT] Match blocks with pseudo probes (#99891)

Shaw Young via All-commits all-commits at lists.llvm.org
Tue Nov 12 07:21:26 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9a9af0a23fc910694b6a806b7ce9cb2e7e4240ef
      https://github.com/llvm/llvm-project/commit/9a9af0a23fc910694b6a806b7ce9cb2e7e4240ef
  Author: Shaw Young <58664393+shawbyoung at users.noreply.github.com>
  Date:   2024-11-12 (Tue, 12 Nov 2024)

  Changed paths:
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Profile/ProfileYAMLMapping.h
    M bolt/include/bolt/Profile/YAMLProfileReader.h
    M bolt/lib/Passes/BinaryPasses.cpp
    M bolt/lib/Profile/StaleProfileMatching.cpp
    M bolt/lib/Profile/YAMLProfileReader.cpp
    M bolt/lib/Rewrite/PseudoProbeRewriter.cpp
    A bolt/test/X86/match-blocks-with-pseudo-probes-inline.test
    A bolt/test/X86/match-blocks-with-pseudo-probes.test
    M bolt/test/X86/match-functions-with-calls-as-anchors.test
    M bolt/test/X86/reader-stale-yaml.test

  Log Message:
  -----------
  [BOLT] Match blocks with pseudo probes (#99891)

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 <aaupov at fb.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list