The Performance Cost To A Proposed Fedora 37 CFLAGS/CXXFLAGS Change
Coming about last week was a Fedora 37 change proposal to improve the profiling and debugging of Fedora packages but with possible performance costs. That suggested change is about adding "-fno-omit-frame-pointer" to the default CFLAGS/CXXFLAGS when building packages so the frame pointer is always available for improving the debugging/profiling of the stock Fedora packages. Unfortunately, it can come with significant performance costs as these benchmarks show.
The proposed system-wide F37 change is to include "-fno-omit-frame-pointer" as part of the default compilation flags when building Fedora packages. The frame pointer would always be available for being of benefit while performance profiling and debugging. By omitting it as is currently the case with the standard compiler optimization levels, it can save three instructions per function and treat the RBP frame / base pointer register as a general purpose register for other use.
This Fedora 37 change proposal was submitted by Meta/Facebook engineers to which they said this option didn't impact two of their most sensitive applications. SUSE a few years ago though found this option to hurt their performance by 5~10% in some benchmarks. The change proposal suggests overriding the compiler flag for select packages that may find their performance hit to be too significant. Curiosity got the best of me so I ran some benchmarks looking at the performance cost to having "-fno-omit-frame-pointer" set.
I used the TUXEDO Aura 15 Gen2 with an AMD Ryzen 5 5500U as a mid-range notebook as the basis for this round of testing. Fedora 36 was running on the device with all available system updates. For the purposes of this testing and simplicity I looked at the performance of building various open-source C/C++ user-space benchmarks with "-O2" (given that -O2 is common among distro packages) and then again with "-O2 -fno-omit-frame-pointer" so the sole difference in this comparison being the addition of the -fno-omit-frame-pointer to the CFLAGS/CXXFLAGS being used for building the software under test. Of course, the Fedora 37 change proposal is about building the entire operating system packages with this flag.