Looking At Building The Linux Kernel With -O3 Optimizations

Written by Michael Larabel in Linux Kernel on 8 April 2015 at 09:15 AM EDT. 24 Comments
LINUX KERNEL
A Linux user has started an LKML discussion over compiling the kernel with -O3 for driving performance improvements out of a more-optimized kernel binary.

Currently the Linux kernel defaults to the -O2 optimization level but the one starting this discussion, Pengfei Yuan, is claiming around a 15% improvement in performance for Redis, about 4% speed-up for the Nginx web-server, and about 2% speed-up for Apache when the kernel was compiled with the higher-level of optimizations by GCC. Of course, these performance improvements would mostly come down to workloads that spend a lot of time in the kernel.

Kernel developers responded by saying interested users just need to adjust the Linux kernel's Make file but there doesn't appear to be any momentum to change the default optimization level. The -O3 level causes some concerns about producing incorrect code for certain architectures, problems building the kernel at that level with older versions of GCC, etc.

In general though, most applications do fine these days when building with this higher-level of optimizations. I haven't ran any kernel compiler optimization comparisons (if you're interested in seeing some tests done for this, let me know!), but you can see some of my past compiler optimization benchmarks in user-space comparing various compiler optimization levels for popular benchmarks.
Related News
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.

Popular News This Week