GNU C Library 2.33 Should Be Out Soon - And It's Very Exciting Due To "HWCAPS"
GNU C Library 2.33 is due for release around 1 February and is expected for Ubuntu 21.04, Fedora 34, and other upcoming distributions. While this C library update has a lot of improvements, exciting us the most is the HWCAPS work. Background on the Glibc HWCAPs work was covered last summer in Glibc-HWCAPS To Help With AMD Zen Optimizations, Other Per-CPU Performance Bits. This HWCAPS work also ties into the work that has since been picked up by GCC 11 and LLVM Clang 12 over x86_64 microarchitecture feature levels.
What this HWCAPS work allows for is the dynamic linker to load optimized versions of libraries within a new "glibc-hwcaps" directory on the library search path. These optimized versions are libraries compiled/optimized for given CPU families or the x86-64 feature levels and for that to be done seamlessly for the user. For say distributions opting to make use of the functionality, support for old x86_64 CPUs can be retained as part of their package builds but if providing multiple library builds under this glibc-hwcaps solution, those running the software on a newer CPU would see a more optimized library seamlessly loaded. Or simply put, loading the best code possible based on the CPU's hardware capabilities (HWCAPS) in a standardized manner.
In the case of the x86_64 feature levels, currently it includes levels above base x86_64 as for Nehalem era CPUs, then AVX/AVX2 and other extensions found on the Intel side since Haswell, and then the highest current level that equates to Intel Xeon Scalable hardware with AVX-512.
Glibc 2.33 lays out x86-64-v2/x86-64-v3/x86-64-v4 sub-directories under the glibc-hwcaps setup for those Intel/AMD feature levels. There are also POWER9/POWER10 options on the POWER side and then z13/z14/z15 for s390x architecture.
So with the imminent Glibc 2.33, there is this loader support in place for being able to load the more optimized shared objects / libraries when present on the system. But now we need Linux distribution vendors to begin distributing such optimized builds... With Red Hat working on the engineering effort for the GNU toolchain changes and the x86-64 feature levels, hopefully for Fedora 35 or so we'll see this functionality made use of out-of-the-box. It's also with Red Hat Enterprise Linux 9 where they are going to raise the entire x86-64 baseline for its build with hopefully more distribution vendors following.
GNU C Library 2.33 will be shipping in the next few days and also has other dynamic linker improvements, a new header file with query macros for x86 CPU features, RISC-V 32-bit hardware support, and other updates.
Glibc-HWCAPS and the x86-64 microarchitecture feature levels coming together in released versions soon, Ubuntu 21.04 joining the LTO bandwagon, and other activities that 2021 will be a good year for seeing improvements in out-of-the-box Linux performance.