Gentoo is a source based distribution which lets the user decide how to optimize their system in many ways and includes building for a specific CPU architecture. Linux Magazine benchmarks four such options; i486, i686, pentium3, core2, and throws in Ubuntu for good measure.
Gentoo is still the most popular source based distribution, famous for its ports like package management system, portage. It has the ability to build custom binaries from source, based on features specified through USE flags. Linux Magazine recently provided an overview of the distribution in celebration of its tenth anniversary.
The ability to build from source introduces other possibilities, like optimizing binaries built with GCC. Previously, Linux Magazine benchmarked three of the most popular GCC optimization levels, namely -Os, -O2 and -O3. The results showed that -Os was often the slowest and that -O2 performed the most consistently.
Now, it’s time to see what can be gained by building an operating system for a specific CPU architecture. Most Linux distributions are built for the lowest common denominator, somewhere between i386 and i686. This helps to ensure that it will run on as many computers as possible. Code which has been built for a specific CPU (such as Intel’s Core 2 Duo) may not run on different systems (when built with GCC’s -march option). Does building a system from scratch for a specific CPU provide any sizeable gains in system performance? Let’s take a look!
The computer system used in these tests has a 3GHz Intel Core2 Duo E8400 CPU, running on an Intel P35 ICH-9 chip-set. In order to accurately compare various CPU compiler options, these tests were all done in a 32-bit environment. Four different CPU optimizations were chosen, namely i486, i686, pentium3 (with mmx and sse support) and core2 (with mmx, sse, sse2, sse3 and sse41 support). The Core2 system was in fact built using GCC’s -march=”native” compiler option, which detects the CPU and applies supported optimizations automatically. The GCC optimization level used for each system was -O2, as this seems to represent the best overall performance, in accordance with our previous findings.
Ubuntu is included for interest’s sake and for basic comparison purposes only. This is not an apples-to-apples comparison. Karmic Koala 9.10 was chosen because it is the current stable version. Each installed system is just the base with any required dependencies for testing, plus X.Org and Xfce4.
Processor: Intel Core 2 Duo CPU E8400 @ 3.00GHz (total cores: 2)
Motherboard: Gigabyte EP35-DS3P
Chipset: Intel 82G33/G31/P35/P31 + ICH9R
System Memory: 3965MB
Disk: 500GB Western Digital WD5001AALS-0
Graphics: GeForce 8800 GT
Monitor: Samsung SyncMaster
The Gentoo system was built from the testing branch using the same USE flags and packages for each system. For each of the different GCC CPU optimization levels, the systemâ€™s tool chain was re-built twice, then the entire system was rebuilt twice and then finally, world. All systems used the same kernel configuration and packages, but were build with the specified GCC optimizations.
Kernel: 2.6.32-gentoo-r5 (i686)
Compiler: GCC 4.4.3
Desktop: Xfce 4.7.0
Display Server: X.Org Server 1.7.5
OpenGL: 3.2.0, NVIDIA driver 190.53
Screen Resolution: 1280×1024
The make profile used was x86/10.0 with the following additional USE flags set:
custom-cflags custom-optimizations opengl qt3support sse sse2 threads X
In addition, the pentium3 and core2 system had both the mmx and sse USE flags enabled, with core2 also having sse2 and ssse3.
The Ubuntu system ran the following software.
Kernel: 2.6.31-19-generic (i686)
Compiler: GCC 4.4.1
Desktop: Xfce 4.6.1
Display Server: X.Org Server 1.6.4
OpenGL: 3.0.0, NVIDIA driver 185.18.36
Screen Resolution: 1280×1024
Next: Testing method