Gentoo Linux offers Modest Performance Gain

Most Linux distributions are provided as binary packages that you install directly on your computer. These binaries are designed to run on anything from the decrepit 80386 to the latest Pentium IV. These programs, therefore, cannot take advantage of the features of modern processors.

A novel feature of Gentoo Linux is that typically it is distributed as source packages, which are then compiled to binaries on the target computer. The binaries are tailored for the architecture and desired functions of the local system. This results in an installation that is optimized, and thus should perform significantly better than a one-size-fits-all binary distribution.

The drawback is that a Gentoo installation can be inordinately time consuming. I spent over a day getting Gentoo installed and running on my local system--and I haven't even begun building the X11 graphic system or Java support. By contrast, I can install a binary distribution of Linux in about half an hour.

The time and effort to install Gentoo from source is extremely high. The question is, does the performance gain from the optimized system make it worthwhile. My results suggest maybe not. Performance is just one of the considerations when selecting a Linux distribution, but it's one that often is mentioned as a primary advantage of Gentoo.

My test platform was a Pentium II 400MHz system with 256MB memory and a 4GB UDMA hard disk. My test was to build a stock Linux 2.4.24 kernel from scratch (make dep and bzImage).

I installed two different Linux distributions on the system, set up in a dual-boot configuration. First, I installed Gentoo Linux version 1.4. Then, I installed Mandrake Linux version 9.2. The swap partition and home filesystem were shared between the two distributions. I used ReiserFS for all filesystems, except for a small ext2 filesystem mounted as /boot.

The table below shows the results of the test:


Kernel Build Time (seconds)
  Mandrake Gentoo change %delta
user time 1357.63 1109.24 -248.39 -18%
system time 76.84 52.10 -24.74 -32%
idle time 62.50 102.71 +40.21 +64%
elapsed time 1496.97 1264.05 -232.92 -15%

The elapsed time is the time it took, as if you measured with a stopwatch. This time can be broken into three components. The system time is the time spent inside the Linux kernel, doing system tasks on behalf of the process. The user time is the time in the program code itself: the C compiler and libraries and other tools.

The idle time represents a measure of inefficiency. Some of it is time servicing other tasks on the computer. However, the computer wasn't doing anything else during the test, so there was little of that. (The measurements recorded that the Mandrake build got 95% CPU and the Gentoo build got 91% CPU.) The rest of that idle time represents time wasted doing nothing. If, for instance, the compile briefly stalls waiting for data to be read off the disk, it would result in idle time.

As the elapsed time row shows, the kernel build took about 20-25 minutes on this computer. The build on Gentoo with the optimized install was only about 15% faster than on the vanilla binary Mandrake system. Moving to Gentoo would be like boosting your 1.0GHz computer to 1.15GHz. That's certainly nice, but nothing to dance around the room over.

Notice the Gentoo build lowered the system and user times, but raised the idle time. This makes sense: as you make the processor more efficient other inefficiencies in the system, such as disk performance, will be more pronounced. The awful conundrum is that slower systems will probably benefit more from the Gentoo install, which are the ones most painful to install. The faster the system, the more other weak links in the chain become pronounced.

One question is, is there some easy way to get a significant portion of that 15% speedup? Rather than building the entire system from source, might it be possible to do that for just a few key components? If, for instance, I built an optimized kernel for Mandrake, I should expect to see the corresponding 24.74 second decrease in system time. How much of the 248.39 seconds of user time could I reclaim if, for example, I built an optimized glibc library?

My test does not take into account CPU architecture, which may alter the results. If there are better optimizations available for, say, a Pentium IV than for the Pentium II I used for testing, the performance improvements may be more pronounced.

A build-from-source distribution such as Gentoo should result in an optimized system and better performance. My tests confirm that is true. They also show the improvement is modest. When evaluating Linux distributions, I'd consider the performance improvement offered by Gentoo Linux as only a minor advantage.

Rating

What do you think of this article? Please click the stars below to let me know.

Your rating: None

Trackbacks

Trackback URL for this post: http://www.unicom.com/trackback/189