6 March 2008

I benchmarked both Linux and FreeBSD running MySQL with sysbench. The system used was a 2 socket, quad core Opteron system.

FreeBSD 7.0 was used with all settings default except a custom kernel was used, with SCHED_ULE. Linux kernel 2.6.25-rc4 was the Linux version tested, with glibc 2.7. All non-essential services and processes were stopped before running the tests.

MySQL 5.0.45 was used for the test, installed from ports on FreeBSD, and compiled from the upstream source with the same options on Linux. The cnf file was a custom one with just minor differences in path settings. The set up is derived from the one described here.
linux cnf
bsd cnf

sysbench 0.4.8 was used on both systems, compiled from upstream. The OLTP test in read-only mode was run, the exact command line is:

sysbench --test=oltp --mysql-socket=/tmp/mysql.sock --mysql-user=root --max-requests=0 --max-time=60 --oltp-read-only=on --num-threads=$1 run
Between every run, sysbench cleanup was invoked to delete all test tables.

The test was run with a varying number of threads: 1-16, 24, 32, 48, and 64 with the throughput in transactions per second was measured. The results are graphed as follows, x-axis is number of threads:


raw linux results
raw bsd results

The results were pretty close and followed a similar pattern. On both OSes, scalability from single process throughput to peak throughput (at 8 threads on each) was around 6.5. Linux did beat FreeBSD at every point, and also edged it out in terms of scalability, despite starting with higher single threaded performance.

Disclaimer: I'm not an expert with FreeBSD or MySQL. The Linux kernel used is not a "stable release" whereas FreeBSD is (although I'm not aware of any significant performance improvements over the 2.6.24 kernel -- 2.6.25-rc4 is simply what I have installed on the machine). Compilers were different versions of gcc-4.2, MySQL code base and compile options were slightly different due to being compiled from ports on FreeBSD. In other words, I can't say definitively that Linux is faster than FreeBSD. My primary interest is to see that Linux's performance problems on this workload are under control. Questions or suggestions are welcome.

Update 7 March 2008:
Somebody asked I benchmark with 2.6.22 kernel, the last non-CFS scheduler kernel. Results are as follows:


From 1-16 threads, 2.6.22 tended slightly slower than 2.6.25-rc4, but slightly faster than FreeBSD. At 24 threads and above, it degraded more gracefully than 2.6.25-rc4.

Nick Piggin