Bug 32519 - LLVM BOLT performance package NEW PKG REQUEST
Summary: LLVM BOLT performance package NEW PKG REQUEST
Status: NEW
Alias: None
Product: Mageia
Classification: Unclassified
Component: New RPM package request (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal enhancement
Target Milestone: ---
Assignee: All Packagers
QA Contact:
URL: https://github.com/llvm/llvm-project/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-14 14:30 CET by Alexander Zaitsev
Modified: 2023-11-16 21:16 CET (History)
0 users

See Also:
Source RPM: llvm
CVE:
Status comment:


Attachments

Description Alexander Zaitsev 2023-11-14 14:30:04 CET
LLVM BOLT (https://github.com/llvm/llvm-project/blob/main/bolt/README.md) is a binary optimizer that helps with optimizing binary software.

As far as I see in the LLVM SPEC file (https://svnweb.mageia.org/packages/cauldron/llvm/current/SPECS/llvm.spec?view=markup), right now LLVM BOLT is not provided by Mageia. I guess it can be "simply" enabled by configuring LLVM to build and install it. Other distributions already provide llvm-bolt binary in their repos: https://repology.org/project/llvm-bolt/versions .

More information about LLVM BOLT can be found in the related issue: https://bugs.mageia.org/show_bug.cgi?id=32511
Comment 1 Lewis Smith 2023-11-14 22:42:18 CET
How does this request differ from your other bug 3251 on the same subject?
Is this request valid independently of that related bug?
Can you give a project URL for this specific item?

We have:
Summary     : The Low Level Virtual Machine
Description :
LLVM is a compiler infrastructure designed for compile-time, link-time,
runtime, and idle-time optimization of programs from arbitrary programming
languages.
and a 'bolt' which is not what you are talking about:
Summary     : Thunderbolt device manager

> Other
> distributions already provide llvm-bolt binary in their repos:
> https://repology.org/project/llvm-bolt/versions .
Well, Fedora + a couple of others, minor. Not convincing.

CC: (none) => lewyssmith
See Also: (none) => https://bugs.mageia.org/show_bug.cgi?id=32511

Alexander Zaitsev 2023-11-15 22:58:37 CET

URL: (none) => https://github.com/llvm/llvm-project/tree/main/bolt

Comment 2 Alexander Zaitsev 2023-11-15 23:00:41 CET
> How does this request differ from your other bug 32511 on the same subject?

https://bugs.mageia.org/show_bug.cgi?id=32511 is about using PGO and PLO for other Mageia packages. This issue is just about adding "llvm-bolt" package to the Mageia repositories. Even if it's not used for other packages, Mageia users can use "llvm-bolt" for their use cases.

> Is this request valid independently of that related bug?

Yes, it can be implemented independently. However, probably PLO part from https://bugs.mageia.org/show_bug.cgi?id=32511 would be easier to implement when "llvm-bolt" package will be available in the repositories.

> Can you give a project URL for this specific item?

Sure. The URL is: https://github.com/llvm/llvm-project/tree/main/bolt


> Well, Fedora + a couple of others, minor. Not convincing.

Not just to convince :) Simply we can use their "llvm-bolt" packages as examples (probably will not be required but who knows).
Comment 3 sturmvogel 2023-11-16 00:16:17 CET
https://research.fb.com/publications/bolt-a-practical-binary-optimizer-for-data-centers-and-beyond/

Reading this paper only throws questions:
- this paper states that the main usecase for BOLT is for large-scale applications in datacenters (like the complete Facebook datacenters as in this report)
- what is the usecase for a desktop OS like Mageia then?
- when the performance gain for large-scale application in data centers with server CPU clusters is only between 2% and 7% what is the performance gain on a mainstream user CPU then?

It is absolutely not clear, which advantages the enduser of an desktop operating system has from this...
Comment 4 Alexander Zaitsev 2023-11-16 00:48:25 CET
> this paper states that the main usecase for BOLT is for large-scale applications in datacenters (like the complete Facebook datacenters as in this report) - what is the usecase for a desktop OS like Mageia then?

It depends on the "large-scale application" definition. As far as I remember, in this paper there is no formal definition of such an application, so we can use existing LLVM BOLT benchmarks for some open-source software.

Here I collected some LLVM BOLT benchmarks:

* Rustc:
  - [Rustc itself (GitHub PR)](https://github.com/rust-lang/rust/pull/116352)
  - [LLVM in Rustc (Reddit)](https://www.reddit.com/r/rust/comments/y4w2kr/llvm_used_by_rustc_is_now_optimized_with_bolt_on/)
* CPython: [GitHub PR](https://github.com/python/cpython/pull/95908)
* YDB: [GitHub comment](https://github.com/ydb-platform/ydb/issues/140)
* Clang:
  - [Slides](https://llvm.org/devmtg/2022-11/slides/Lightning15-OptimizingClangWithBOLTUsingCMake.pdf)
  - [Results on building Clang](https://github.com/ptr1337/llvm-bolt-scripts/blob/master/results.md)
  - [Linaro results](https://android-review.linaro.org/plugins/gitiles/toolchain/llvm_android/+/f36c64eeddf531b7b1a144c40f61d6c9a78eee7a)
  - [on AMD 7950X3D](https://github.com/llvm/llvm-project/issues/65010#issuecomment-1701255347)
* LDC: [GitHub comment](https://github.com/ldc-developers/ldc/issues/4228#issuecomment-1334499428)
* NodeJS: [Blog](https://aaupov.github.io/blog/2020/10/08/bolt-nodejs)
* Chromium: [Blog](https://aaupov.github.io/blog/2022/11/12/bolt-chromium)
* MySQL, MongoDB, memcached, Verilator: [Paper](https://people.ucsc.edu/~hlitz/papers/ocolos.pdf)

As you see, LLVM BOLT shows improvements on pretty normal software at least in the benchmark scenarios.

LLVM BOLT is already integrated at least into the following projects in upstream:

* Rustc: [GitHub PR](https://github.com/rust-lang/rust/pull/116352)
* CPython: [GitHub PR](https://github.com/python/cpython/pull/95908)
* Pyston:
  - [README](https://github.com/pyston/pyston#building)
  - [Makefile](https://github.com/pyston/pyston/blob/pyston_main/Makefile#L200)
* Clang: [CMake script](https://github.com/llvm/llvm-project/blob/main/clang/cmake/caches/BOLT.cmake)

At least one distro (Solus) even already integrated LLVM BOLT to their build pipelines in their LLVM package: https://github.com/getsolus/packages/blob/main/packages/l/llvm/package.yml#L116

I guess some examples above can be interesting to Mageia.


> when the performance gain for large-scale application in data centers with server CPU clusters is only between 2% and 7% what is the performance gain on a mainstream user CPU then?

For BOLT there is no difference between server and usual consumer CPU - the performed by BOLT optimizations are equally for both CPU classes.

Regarding the performance numbers - you can check in the "LLVM BOLT benchmarks" above. 

Some quick numbers (without digging a lot into each benchmark detail, all results after already applied Profile-Guided Optimization(PGO)):

* Rustc: ~7% speedup after LLVM + Rustc frontend BOLT'ing
* LDC (a D compiler): +4% speedup
* YDB (a database): +5.5% RPS
* Chromium: ~5.9% improvement in Speedometer2

For some people, even 5% is a huge improvement after PGO. Especially if we are talking about weak machines or Mageia-based CI pipelines (where we running our CI tools like compilers from Mageia-based OS/Docker images).

> It is absolutely not clear, which advantages the enduser of an desktop operating system has from this...

Even if we are not talking about optimizing other Mageia packages with LLVM BOLT (in this case having "llvm-bolt" as a package is a neat thing), people still can use llvm-bolt for their needs. Like me - I develop software on my local Fedora machine, and before I run my performance routine benchmarks, the "default" optimization is to optimize my program with llvm-bolt. In Fedora, where llvm-bolt is already provided by the OS's repos, I simply install it from the repo and use it. Before that, I needed to check out LLVM, compile BOLT, install it properly, and update (read as "recompile") BOLT to get newer versions/fixes. So it can be useful at least for local development cases like a simple developer tool. Like already we have code formatters, debuggers, etc. (however I agree that debuggers and code formatters now have a wider user base).
Comment 5 Lewis Smith 2023-11-16 21:16:17 CET
> This issue is just about adding "llvm-bolt" package to the Mageia
> repositories. Even if it's not used for other packages,
> Mageia users can use "llvm-bolt" for their use cases.
> it can be implemented independently
This does make it a clear independant 'new package' request: for users, not for our own use. The performance gains are trivial compared with all other factors.

There is no tarball or package available.

From the project URL:
---------------------
Installation

Docker Image

You can build and use the docker image containing BOLT using our docker file. Alternatively, you can build BOLT manually using the steps below.
Manual Build

BOLT heavily uses LLVM libraries, and by design, it is built as one of LLVM tools. The build process is not much different from a regular LLVM build. The following instructions are assuming that you are running under Linux.

Start with cloning LLVM repo:

> git clone https://github.com/llvm/llvm-project.git
> mkdir build
> cd build
> cmake -G Ninja ../llvm-project/llvm -DLLVM_TARGETS_TO_BUILD="X86;AArch64" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS="bolt"
> ninja bolt

llvm-bolt will be available under bin/

License
BOLT is licensed under the Apache License v2.0 with LLVM Exceptions.
--------------------------------------------------------------------

Our packagers are overloaded, so I would be surprised if anyone takes this up.

Assigning this package request to all packagers collectively. On a voluntary basis, one of them might, if there are no license or other legal issues, want to integrate it to the distribution and maintain it for bug and security fixes.

You Alexander might also want to join the packager team to maintain this piece of software: see https://wiki.mageia.org/en/Becoming_a_Mageia_Packager

Summary: Add LLVM BOLT package => LLVM BOLT performance package NEW PKG REQUEST
CC: lewyssmith => (none)
Assignee: bugsquad => pkg-bugs


Note You need to log in before you can comment on or make changes to this bug.