Benchmarking The Linux Kernel With An "-O3" Optimized Build

Written by Michael Larabel in Software on 29 June 2022 at 09:00 AM EDT. Page 9 of 9. 101 Comments.

In total I ran 230 different tests on the -O2 and -O3 kernel builds. Again, the same overall Kconfig and kernel version used for testing, the only change was switching -O2 to -O3 for the KCFLAGS. The benchmark flags for the user-space software were all the same during these tests. Those wanting to check out all 230 metrics in full can do so via this OpenBenchmarking.org result page.

When taking the geometric mean of all 230 benchmark results, the -O3 kernel build came out ahead only by 1.3%... Barely a blip overall. Or if simply doing a side-by-side look at the workloads with a 2%+ difference:

Showing the most significant difference was Stress-NG's context switching benchmark but the context switching performance measured by ctx-clock for example was unchanged. Aside from that outlier, in all the other tests the -O3 kernel was 11% faster or less, but most often 5% or less.... If ignoring the very synthetic benchmarks, the gains on the -O3 kernel were found in some database systems like PostgreSQL and RocksDB/LevelDB. There were also some gains seen with the Apache HTTPD web server. In networking tests like Ethr there were some improvements to report as well but at least for the tests conducted are synthetic benchmarks.

Where the -O3 optimized kernel build was of some advantage was within server workloads. However, that's likely least where server administrators would be comfortable with the -O3 optimizations given the possibility -- at least historically -- of the optimizations generating incorrect/faulty code especially where in the context of the kernel could be subtle, hard to debug run-time issues.

When it came to the -O3 kernel build for other workloads like gaming/graphics, web browsing performance, and various creator workloads there was no measurable benefit from the -O3 kernel.

If you enjoyed this article consider joining Phoronix Premium to view this site ad-free, multi-page articles on a single page, and other benefits. PayPal or Stripe tips are also graciously accepted. Thanks for your support.


Related Articles
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.