Linux Performance Benchmark - System
I decided to start by enduring a simple and generalist benchmark to all distributions, using hdparm, gzip, gunzip, lame, oggenc and heavier one where I mixed all I mentioned before plus a standard PHP compilation.
There were many surprises and a few details I couldn’t really understand but we’ll get to that.
Configuration
As you know, I’ve tested Ubuntu Server, Debian, CentOS and Gentoo. I’ve used the default configuration for all of them, except for Gentoo where I’ve changed the default kernel configuration (since it’s Desktop-oriented) tweaking a few options to be similar to those found on Ubuntu Server’s kernel configuration.
I also didn’t enforce the usage of similar package versions: My goal was to benchmark all distributions in a given time (which were updated at the same time I submitted my previous post). So, let’s see what we have in each of them:
- Ubuntu Server
- kernel version: linux-headers-2.6.31-14-server
- filesystem: ext4
- hdparm version: 9.15-1ubuntu4
- gzip version: 1.3.12-8ubuntu1
- lame version: 3.98.2+debian-0ubuntu2
- vorbis-tools version: 1.2.0-6
- gcc version: 4.4.1-1ubuntu2
- Debian
- kernel version: linux-headers-2.6.26-2-amd64
- filesystem: ext3
- hdparm version: 8.9-3
- gzip version: 1.3.12-6
- lame version: 3.97-0.0
- vorbis-tools version: 1.2.0-5
- gcc version: 4.3.2-2
- CentOS
- kernel version: kernel-2.6.18-164.9.1.el5
- filesystem: ext3
- hdparm version: 6.6
- gzip version: 1.3.5
- lame version: 3.96.1
- vorbis-tools version: 1.0.2
- gcc version: 3.4.6-3
- Gentoo
- kernel version: linux-2.6.31-gentoo-r6
- filesystem: ext4
- hdparm version: 9.20
- gzip version: 1.3.12-r1
- lame version: 3.98.2-r1
- vorbis-tools version: 1.2.0-r2
- gcc version: 4.3.4
Benchmark
I’ve used a small script for testing purposes, which runs 3 rounds of each of these tests:
- hdparm on the root partition
- gzip on a 2.5GB file
- gunzip on the resulting file
- lame to convert a 214MB WAV file to MP3
- oggenc (part of vorbis-tools) to convert the same 214MB WAV file to OGG
- Execution of all the tests above plus extracting, compiling and removing PHP 5.2.12 - ran one only once on each system.
The multiple runs had the goal of canceling circumstantial issues, except for the last one which is pretty long and does that by itself. To make all measurements (except for the hdparm test), I used GNU time.
Results
Results amazed me a bit. First of all, the default installation of CentOS must have some kind of problem on my system - despite it winning one of the tests, it lost by a huge margin on the ones involving gzip (including the heaviest one). A second consideration point regards Gentoo: It needs to be properly configured and I barely touched it. Gentoo’s power rests in it’s configurability because without proper configuration, it’s somewhat a standard Linux installation. Since my purpose was not to benchmark a fully configured environment, it was OK not to have Gentoo at full power - actually, none of the distros were. Bottom line: no tweakings were made, just pure performance out of each distro’s standard installation.
If you check my benchmarking script you can see that it creates a result file for each one of the tested distributions - Ubuntu, Debian, CentOS and Gentoo.
A summary of all results and relevant output will follow:

All results represent averages of all 3 runs (except for the last one which was only ran once, as I mentioned). Let’s go one by one and possibly do some result analysis.
hdparm
The performance achieved by all 4 was quite similar. Anyway, Gentoo wins this round.
This test measured the speed of cached reads so the higher the better.

gzip
Gentoo wins this round as well, followed closely by Debian. It’s the first benchmark where the CentOS problems I mentioned start being serious. CPU is stressed and there are many IO operations (keep in mind that the file is huge).
This test measures the time needed to compress a 2.5GB file so the lower the better.

gunzip
Gentoo wins again and this time it is by a fair margin. CentOS’s problems keep getting noticed. Similarly to the gzip benchmark, the CPU is also stressed but in a smaller scale while the IO operations increase since we’re extracting a fairly big archive which will result in a larger file.
This test measures the time needed to extract the previously compressed file so the lower the better.

lame
This one was an absolute surprise. After seeing CentOS falling to it’s knees on previous tests it actually won this round by a great margin - more than 9% comparing to the second best, which was Debian. Noticeably, the most up-to-date distributions - Ubuntu and Gentoo - were the ones to perform worse. Could there be a slight performance degradation from lame 3.96/3.97 to 3.98? This benchmark uses a lot of CPU and that was the main target.
This test measures the time needed to convert a 214MB file so the lower the better.

oggenc
Ubuntu won this one, closely followed by Debian and then Gentoo. CentOS stayed behind but this is probably related to the outdated version of vorbis-tools which were used. Similarly to the lame benchmark, this one also uses a lot of CPU and that was also the main target.
This test also measures the time needed to convert a 214MB file so the lower the better.

workload
Many strange things happened. First of all, CentOS showed a huge performance hit, probably related with the possible misconfiguration I mentioned previously. Another thing I’ve noticed is that sys+user time is higher than real time, which I find extremely awkward. Besides, Gentoo did a lot of voluntary context switching (>100000), 17 times more than Debian and around 6 times more than Ubuntu/CentOS. I can’t understand why this happened - hasn’t the source been correctly patched by Gentoo’s developers? Is the kernel badly configured? Is gcc behaving incorrectly? I couldn’t figure this out, even though the impact wasn’t really deep. If you have any ideas regarding this issues, please leave a comment.
On the same subject, I really think something went wrong with this benchmark - time measurements didn’t seem accurate. The only conclusion I can make out of this is the excellent Debian performance when comparing it to Ubuntu and Gentoo. Huge win!
This test measures the time needed to parallely run all tests mentioned before plus PHP 5.2.12 compilation so the lower the better.

Conclusions
First of all, let’s give some medals:
- hdparm - Gentoo
- gzip - Gentoo
- gunzip - Gentoo
- lame - CentOS
- oggenc - Ubuntu
- workload - Debian
I can safely assume that Gentoo wins when it comes to CPU usage + IO operations on a single instance. After all, it won the hdparm, gzip and gunzip benchmarks. When it comes to almost pure CPU processing power CentOS and Ubuntu get the glory since they won the track conversion benchmarks. At last but not least, Debian did an excellent job in the workload benchmark, leaving it’s opponents behind by a safe margin.
Now to some considerations:
- CentOS has some default configuration problem on this hardware, which can be seen in some of the tests;
- Gentoo’s performance in CPU usage+IO operations could somewhat be associated with the usage of the more recent ext4 filesystem but it must be unrelated since Ubuntu fell greatly behind in those benchmarks;
- The results of the lame benchmark seem to be related to the version in use: the older, the better;
- Ubuntu did a killer job on the oggenc benchmark. I wonder if this has something to do with distro-related package patches;
- The results of the workload benchmark were strange (because of the time issue I mentioned before) and I still can’t understand why Gentoo did so many voluntary context switches (knowing they come with an associated overhead). The result is obvious - Debian smashed it’s competitors!
What now?
CentOS has been ruled out of future benchmarking. It came with an obvious configuration defect and I don’t want to spend precious benchmarking time in hunting it down.
Now that we’re down to 3 distribution: Ubuntu, Debian and Gentoo, I’ll make a few rounds of new web-oriented benchmarks since that’s my main purpose - I’ll start with apache/nginx and then move forward to many webservers such as Passenger and Thin.
If you have any questions left about the procedure I’ve used or you think you have an answer to any of the problems/doubts I’ve encountered, feel free to comment bellow.