Gentoo is a source based distribution which lets the user decide how to optimize their system in many ways. Linux Magazine benchmarks three of the most common GCC optimizations; -Os, -O2 and -O3, and throws in Ubuntu for good measure.
From GTK to Qt4 with QGears2, which uses various rendering back-ends.
Once again Ubuntu performs quite poorly, especially in the text based tests although it does come out on top in the “Gears” test. In this round, -O2 is the winner, although it is fairly even with -O3. Finally, -Os struggles on various tests.
Finally for graphics is Lightsmark and Nero2D.
Lightsmark, which tests real-time global illumination and penumbra shadows with OpenGL, is fairly even across the board. With Ner02D, Gentoo -O3 comes out on top with Ubuntu in last place.
In the systems area, testing is quite varied including serving up web pages with Apache and files with Dbench, encrypting files with Bork and compressing them with 7-Zip, OpenSSL performance and from SQLite database insertions to solving maths with GMPBench.
When it came to DBench, -O2 was the clear winner, while the rest of the results show little difference between the three.
Finally, the tests are concluded with x11perf and Render Bench.
These results are fairly close right across the board, but the overall winner by a slim margin was -O2.
These tests show that when it comes to optimizing with GCC, there is not a huge amount of difference between them. If there had to be a winner, it would probably be -O2. It was often on par with -O3 while sometimes leading and sometimes trailing by a small margin. The fact that -O2 will also result in lower memory usage probably helps to tip the scales in its favour.
Generally speaking, the -Os level did worse than the others, which were much more evenly matched. It is still the choice for low end systems as it uses less memory and still performs quite well. It did however, even manage to take out several tests in its own right.
Although we are not comparing apples to apples, Gentoo did out-perform Ubuntu in almost every test, and sometimes by a fair margin. It does appear that optimizing for a specific CPU can yield a decent performance increase.
Of course, Gentoo offers benefits in other areas with their USE flags and being able to build a highly customized system. The question is whether the amount of time it takes is worth the benefit, and that’s a personal choice.