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

[question] Expand usage Profile-Guided Optimization (PGO) and Post Link Optimization (PLO) for Conan packages #21245

Open
zamazan4ik opened this issue Nov 19, 2023 · 2 comments
Labels
question Further information is requested

Comments

@zamazan4ik
Copy link
Contributor

What is your question?

Hi!

I investigate PGO and PLO effects on different kinds of software - all my current results are available at https://github.com/zamazan4ik/awesome-pgo. According to the results, enabling PGO and PLO can help with achieving better overall performance in many cases. I think expanding PGO and PLO usage for the Conan packages would be a good idea since it could help to achieve better software performance for Conan users.

Profile-Guided Optimization (PGO)

PGO is already a well-known technique. All currently known PGO effects on performance can be found at https://github.com/zamazan4ik/awesome-pgo#pgo-showcases . Several OS distros and package manager already enabled PGO for packages like GCC, Clang, Rustc, and many others (it depends on each package manager, of course). For some projects PGO is already enabled in Conan recipes - like CPython.

I think we can start by enabling PGO at least for the following projects (these packages are already PGO-optimized in many OS distros):

  • Compilers like GCC, glslang, etc.
  • Static analysis like CppCheck
  • Databases like SQLite (PGO bench results)

Probably there are more PGO-suitable packages in the Conan repository. All found right now PGO results (with performance numbers) can be checked here - https://github.com/zamazan4ik/awesome-pgo#pgo-showcases

Post Link Optimization (PLO)

Regarding Post Link Optimization (PLO), right now there are two main tools - LLVM BOLT and Google Propeller.

According to the Facebook Research Paper (https://research.facebook.com/publications/bolt-a-practical-binary-optimizer-for-data-centers-and-beyond/), LLVM BOLT (https://github.com/llvm/llvm-project/blob/main/bolt/README.md) helps with achieving better performance for various packages like compilers and interpreters. I think it would be a good idea to enable LLVM BOLT for some packages to deliver faster binaries for users (since Propeller is less stable right now in my opinion).

Here I got some examples of how LLVM BOLT is already integrated into other projects:

So at least for the projects above LLVM BOLT effects are tested and some preparations are already done in the upstream projects. In this case, it should be easier to enable BOLT for these packages.

For some projects right now there is ongoing work on integrating LLVM BOLT into the build scripts:

More about LLVM BOLT performance results for other projects can be found in:

Some OS already using LLVM BOLT in their build scripts - check Clang recipe in Solus.

Usually, PGO and PLO are mostly used for executable packages, not for libraries. However, PGO and PLO can be used for distributed libraries too - e.g. check pydantic-core case. We can think about PGO and PLO integration approaches into Conan as well. Imagine the case when a user uses libraries from Conan and wants to optimize them all according to their profile with PGO. How can we implement this case right now with Conan? Do we need an additional integration in Conan like it's done in Bazel?

First, I want to discuss these optimization approaches with Conan maintainers. What do you think about the ideas? If these ideas would be valuable for Conan, then we can think about what to do next: create per-package corresponding PGO/PLO issues, create meta-tracking issues, etc.

Thank you for your attention.

@zamazan4ik zamazan4ik added the question Further information is requested label Nov 19, 2023
@SpaceIm
Copy link
Contributor

SpaceIm commented Nov 19, 2023

It doesn't seem to be directly related to conancenter, but conan client. https://github.com/conan-io/conan/issues would be more appropriate.

But regarding LTO or PGO and conancenter, this idea is to build portable binaries by default (binaries built with LTO are not portable for example, at least for msvc) in a consistent way in the all dependency graph, and allow user to build binaries with LTO (no idea how it would work with PGO, is there even a standard way to enable externally this thing in CMake for example without modifying build files?) if they want by providing appropriate flags in their profile.

@zamazan4ik
Copy link
Contributor Author

It doesn't seem to be directly related to conancenter, but conan client. https://github.com/conan-io/conan/issues would be more appropriate.

It depends on how we interpret the issue. Because I am talking about enabling PGO for Conan packages. Since PGO cannot be enabled easily for all of them - it probably needs to be done in a per-package way, so some package recipe changes are required.

and allow user to build binaries with LTO (no idea how it would work with PGO, is there even a standard way to enable externally this thing in CMake for example without modifying build files?) if they want by providing appropriate flags in their profile.

If we are talking about enabling PGO via a semi-standard build option, as far as I know only Bazel and Meson have such options. For CMake, there is only a request.

As an example of how PGO is enabled right now in various projects:

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

No branches or pull requests

2 participants