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.


Comments have been closed for this entry.

re: Gentoo Linux offers Modest Performance Gain

Real increases in speed are seen when you are using a P4 or AMD processor. Most distros are built to be able to run on a 386 and are not optimized for the enhancements in the newer processors. I have seen over 35% increase on a AMD 2.4 ghz system over redhat 8.0

re: Gentoo Linux offers Modest Performance Gain

I've never used Mandrake nor Gentoo but I've just ordered a new P4 computer ( :-) ) and I'm thinking to pass to Gentoo while I'm waiting for a Pentium IV version of Fedora Core.
There are just 2 things that you maybe weren't thinking of when you made this test.
First: what patches and settings have been applied to both kernels?
Second: you wrote:
> as you make the processor more efficient other
> inefficiencies in the system, such as disk
> performance, will be more pronounced.
Why? If the kernel is executing a write-like syscall then the time elapsed to do so is added to system time. Same thing if the kernel is copying the cache data onto the disk with sync-like syscall. However those operations are always controlled by the processor, even if DMA is enabled, so the elapsed time is always "system time".
Am I wrong?
This makes me suppose that Mandrake's kernel sources have been optimized better than Gentoo's ones.

re: Gentoo Linux offers Modest Performance Gain

Enso - when a process is blocked for I/O, it gives up control for another process to run. If no other processes are runnable, then the kernel sits idle, and idle time is accrued.

re: Gentoo Linux offers Modest Performance Gain

I have been using linux since 1994, and have watched it mature very rapidly into the system that it is today. With this rapid maturation comes frequent upgrades. Generally, twice a year, users are expected to upgrade their distribution in order to keep current with the latest security and bug fixes. From my experience as a senior systems administrator, these "upgrades" rarely go as well as expected (with windows or linux or any other OS for that matter).

On my home machines, I have used Mandrake for a few years when trying to uproot my wife from her windows attachment. Mandrake was indeed the best distro for this job... More recently, I have used RedHat 8 and 9. Although I didn't see anything wrong with RH8, other than the fact that it uses the horrible RPM package management system, RH9 was enough to turn me off from the whole RH distribution. I got tired of having to patch source code with errno.h and pthread patches and the like. And RPM still managed to corrupt it's database once a week. My system was starting to get a little bit outdated, and I didn't like the feeling of installing Fedora RPMs onto a RH9 box for fear of screwing the whole machine up and having to spend a weekend to get it back in shape.

I decided to change distros. The things that I looked for in my new linux distro:

- base distribution actively maintained
- frequent updates to available packages
- does not use RPM in any way, shape, or form
- easy to keep updated

Debian almost fit the description, with the exception of frequent updates to available packages. Packages can stay tagged as unstable in Debian for what seems like forever, forcing you to choose "unstable" if you want to use almost any new software. I had used Debian for one of my webservers a few years ago, and I was familiar with this frustration.

Then I took a second look at Gentoo. I had looked at it a few years ago, but it was not yet mature enough for me. After spending an evening reading the user documentation on the website, I was convinced to switch. Gentoo has a very "FreeBSD" feel to it, and I have been a big fan and longtime user of FreeBSD. In fact, the only reason why I use linux at all is because java support basically sucks on FreeBSD and I need at least one machine which can run java apps well.

As many people have mentioned, getting Gentoo set up is not a trivial task. I have a P4 2.4GHz box with 512MB memory, and it still took me an entire weekend to get to the point where I could start Gnome and KDE. This is the only negative thing I can say about Gentoo. And it's only negative if you 1) don't have time to do it, and 2) don't have any interest in learning how your machine is configured.

The modest performance gains don't really matter to me. My box is already fast enough. Keeping the system up to date is where Gentoo really stands out above all others. With an included tool, I discovered the name of a nearby Gentoo rsync mirror and entered it into my /etc/make.conf file. I update my list of available packages once a day or so with a command `emerge sync'. It takes 2-3 minutes to synchronize the disk with the local mirror. Then I run a command to see what would happen if I ran a system update `emerge -up world'. I have paid attention to the results for the few weeks that this box has been installed, and the list of new packages per day has been zero on several days, and between 1-4 on other days. I always decided to allow the update to run, with the `emerge -u world' command. I might postpone the update if I see something like a new version of KDE, until I'm sure that I don't need to use the machine for a few hours, but that hasn't happened yet. Of course, I could and will put the synching and update listing tasks on a cron job that sends me a mail, but I chose to do it manually now so that I don't forget how this system is maintained and so that I can really see how long it takes each day. The updates that I have done have taken usually 0-3 minutes each day. Today, there was a new version of gcc, which took an hour or so to update.

Gentoo does not have the concept of a version number for the distribution. There is a binary reference iso available, which is a snapshot of what was currently stable at some point in time. Installing that and then running the `emerge -u world' command will trigger a rebuild of your entire system, so I advise just building it from scratch to begin with and not wasting your time with the reference platform. You either keep the system updated with the currently available stable packages, or you don't. There are no entire upgrades. Thank god.

I am so happy that I will never have to upgrade my major distribution version again. That is a nightmare that I can certainly live without. I spent two days to build this system up how I like it, and I'll never have to do that again. From now on, it's a matter of a few minutes per day of maintenance, which can be automated as soon as I lose interest in actually watching it :-)

Newbies will probably be happiest with either Mandrake or Fedora. Linux hobbyists, systems administrators, developers, or students aspiring to be such, will find Gentoo a very suitable distribution for them. And your non-technical spouse won't notice much difference from anything else, because KDE and Gnome look just the same.


re: Gentoo Linux offers Modest Performance Gain

I liked gentoo from the first day that I installed it. It was the first linux distro that taught me what everything is doing and gave me the oportunity to fine-tune the entire system.

But there are few pitfalls in gentoo that even Podz will encounter (if not already :-). There are some packages that you shouldn't upgrade, unless you can afford an entire recompilation of your system. The one that I came across was gcc. Emerge doesn't force you to recompile the entire system but from that point on compiling packages starts to fail ocasionally.

I guess that it has to do with the fact that the libraries of the old version of gcc are still needed to to (re)build some packages and maybe run some programs.

The way that gentoo is set, has minimized the "core" of the operating system down to the compiler. This is the common denomenator of all packages. Upgrading that means to recompile the entire system.

Even has a guide on how to do it correctly.

I think the best way to manage a gentoo installation is:
(a) pin down some packages like gcc and maybe others that will take forever to compile like xfree.
(b) keep the same portage tree (no emerge sync) and whenever you don't need your machine for a couple of days do a full system upgrade like this:
emerge sync (keep in mind that this could override your "pins")
emerge -u portage
emerge -Du world
emerge -Du system
(c) when you really want to update gcc (and your entire system) follow the steps in the guide that I wrote above.