Skip to content
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

Evaluate using Profile-Guided Optimization (PGO) and LLVM BOLT #1128

Open
zamazan4ik opened this issue Oct 22, 2023 · 1 comment
Open

Evaluate using Profile-Guided Optimization (PGO) and LLVM BOLT #1128

zamazan4ik opened this issue Oct 22, 2023 · 1 comment

Comments

@zamazan4ik
Copy link

zamazan4ik commented Oct 22, 2023

Hi!

Recently I checked Profile-Guided Optimization (PGO) improvements on multiple projects. The results are here. E.g. PGO results for LLVM-related tooling are here. According to the tests, PGO usually helps with the compiler and compiler-like workloads (like static analysis) - e.g. Clang gets +20% compilation speed with PGO. That's why I think trying to optimize grcov with PGO can be a good idea.

I already did some benchmarks and want to share my results.

Test environment

  • Fedora 38
  • Linux kernel 6.5.6
  • AMD Ryzen 9 5900x
  • 48 Gib RAM
  • SSD Samsung 980 Pro 2 Tib
  • Compiler - Rustc 1.73
  • grcov version: the latest for now from the master branch on commit 322fc39acacd75aca0ff1c0a1ec2a3e91f04011c
  • Disabled Turbo boost

Benchmark

For benchmark purposes, I use grcov benchmarks via cargo +nightly bench. For PGO optimization I use cargo-pgo tool. The same benchmark suite was used for the PGO training phase via cargo +nightly pgo bench. PGO optimized results I got with cargo +nightly pgo optimize bench.

I met a small issue with benchmarks #1127 but quickly fixed it by using precision = 2 (found a similar parameter somewhere in the repository).

Results

I got the following results:

At least according to the provided by grcov project benchmarks, PGO helps with optimizing performance.

Further steps

I can suggest the following action points:

  • Perform more PGO benchmarks on grcov. And if it shows improvements - add a note about possible improvements in grcov's tool performance with PGO.
  • Providing an easier way (e.g. a build option) to build scripts with PGO can be helpful for the end-users and maintainers since they will be able to optimize grcov according to their own workloads.
  • Optimize pre-built binaries

Testing Post-Link Optimization techniques (like LLVM BOLT) would be interesting too (Clang and Rustc already use BOLT as an addition to PGO) but I recommend starting from the usual PGO.

Here are some examples of how PGO optimization is integrated in other projects:

@marco-c
Copy link
Collaborator

marco-c commented Oct 23, 2023

Happy to accept a PR to use PGO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants