Fedora Linux has already supported making use of glibc HWCAPs for allowing libraries to be built for different x86_64 micro-architecture feature levels for performance-sensitive code where it can pay off when leveraging AVX/AVX2 or other newer Intel/AMD CPU instruction set extensions. For Fedora 42 is now a proposal to extend that further to allow binary executables to also leverage glibc HWCAPs for better performance.
A change proposal has been filed for Fedora 42 to allow shipping optimized binaries for x86_64 microarchitecture feature levels. The intent is on extending the glibc-hwcaps mechanism to complete executables rather than just shared libraries.
“Individual packages can provide already optimized libraries via the glibc-hwcaps mechanism. This approach will be extended to executables. The package provides an optimized variant of a binary in a different directory. A symlink to small program which replaces the binary in /usr/bin. At runtime, this program will find the most appropriate variant and execute it.
Which packages provide the optimized code and at which level will be made by individual package maintainers based on benchmark results. A few programs/packages will be updated by the Change Owners to show how the mechanism works.
…
This Change is about extending the glibc-hwcaps mechanism to executables. A small helper binary is provided. A program in /usr/bin (or another path) is symlinked to this helper. When executed, the helper checks the capabilities of the CPU and searches for the most appropriate variant of the target program in a separate directory hierarchy. If then launches one of the optimized binaries or the “generic” one compiled for the baseline.”
The change proposal goes on to add:
“The developers who are interested in this kind of optimization work can perform it within Fedora, without having to build separate repositories. The users who have the appropriate hardware will gain performance benefits. Faster code is also more energy-efficient. The change will be automatic and transparent to users.
Note that other distributions use higher microarchitecture levels. For example RHEL 9 uses x86-64-v2 as the baseline, RHEL 10 uses x86-64-v3, and other distros provide optimized variants (OpenSUSE, Arch Linux, Ubuntu). We implement the same change in Fedora in a way that is scoped more narrowly, and thus vastly cheaper in the sense of development effort, code compilation time, storage and distribution overhead, but should provide the same performance and energy benefits.”
It will still be up to the Fedora packager/developer to evaluate the performance merits and determine for their package(s) if they want to resort to providing optimized executables for different x86_64 micro-architecture feature levels.
This change proposal still needs to be voted on by the Fedora Engineering and Steering Committee (FESCo) but hopefully it will pass for the Fedora 42 release this spring.