Looking At Building The Linux Kernel With -O3 Optimizations
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.
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.
24 Comments