Can Linux Do it?
Dark Fiber
writes "The AGE newspaper has a
big article (great big
3 page spread) on Linux that is very interesting. Lotta questions,
Lotta answers." One of the better mainstream articles-
it gets distributions right, covers the GNU/Linux connection,
and more.
For a bit of fun, the other day, I wrote a simple little Perl script to do some simple benchmarking:
:$!";
:$!";
#!/usr/bin/perl
use strict;
use Time::HiRes qw(gettimeofday);
my $test_dir = "t/";
my @tests = (\&create_files,\&delete_files);
foreach my $no_files (10, 30, 100, 300, 1000, 3000, 10000) {
foreach my $test (@tests) {
my $start_time = gettimeofday();
my $name = &$test($no_files);
my $end_time = gettimeofday();
printf("%6d %10s: %s\n", $no_files, $name, 1000*($end_time-$start_time) / $no_files);
}
}
exit(0);
sub delete_files {
my ($max) = @_;
my $num;
foreach $num (1..$max) {
my $file = $test_dir.$num;
unlink($file) || die "Failed to delete '$file'
}
return "Delete files";
}
sub create_files {
my ($max) = @_;
my $num;
foreach $num (1..$max) {
my $file = $test_dir.$num;
open(DA_FILE, "> $file") || die "failed to open '$file'
close(DA_FILE);
}
return "Create files";
}
# Results - the values are average time per file in mili-seconds.
#
# SPARC Solaris 2.6
# 10 Create files: 17.3946022987366
# 10 Delete files: 8.25690031051636
# 30 Create files: 16.6551351547241
# 30 Delete files: 8.31733147303263
# 100 Create files: 16.6641497612
# 100 Delete files: 8.32810044288635
# 300 Create files: 17.0558432737986
# 300 Delete files: 8.49879026412964
# 1000 Create files: 19.0030739307404
# 1000 Delete files: 8.36658298969269
#
# Linux 2.2 x86
# 10 Create files: 0.0998973846435547
# 10 Delete files: 0.678598880767822
# 30 Create files: 0.0572681427001953
# 30 Delete files: 0.0586668650309245
# 100 Create files: 0.0708794593811035
# 100 Delete files: 0.0524997711181641
# 300 Create files: 0.0964502493540446
# 300 Delete files: 0.0535901387532552
# 1000 Create files: 0.223060011863708
# 1000 Delete files: 0.0744880437850952
# 3000 Create files: 0.529780666033427
# 3000 Delete files: 0.0793236494064331
# 10000 Create files: 1.90500370264053
# 10000 Delete files: 0.145310199260712
The Solaris 2.6 system above is a 270Mhz Ultra 5, with a simple SCSI setup. The Linux 2.2 system is a 400Mhz PII system with striped SCSI - ie it had the better discs as well as processor. I did also benchmark a 3 year old Ultra2 (it had a 200Mhz UltraSparc-II - I didn't even know they went that slow!) but that had Solaris 7, and I put file-journaling on (file-jounaling is a standard option on Solaris 7, even free Solaris 7 for x86) - but I don't have the exact numbers for that. But it was pretty steady at around 2ms per file for create/delete, even up to 10000 files. I've also benchmarked on a Solaris 7 x86 (300 Mhz K6-2) with an IDE drive, which was a bit faster than the Ultra2 system - for file creation, it was faster than the Linux system above, for the 10000 files value. Sorry I don't have the exact numbers - the two Solaris 7 boxes aren't available to me at the moment. (this looks dodgy I know, but I wasn't expecting to be quoting these figures right now)
Incidentaly, on FreeBSD (2.2.8 anyway) it was a bit slower than Solaris 2.6 on a similarly spec'ed machine.
I criticise lmbench above. The same criticism can be equally applied to my program - it's pretty rare you get cases like this.
I certainly don't have much problem accepting that the standard Linux FS is faster than the standard Solaris FS. However, I do know that the Linux FS does cache very agresively. Some would say too much - problems with file-system integrity are much more common on Linux than Solaris or FreeBSD. This also means that if memory useage is heavy, the Linux file-system will slow down much more compared for FreeBSD and Solaris. Basically, with the Linux fs even though the operation has completed, what is on the hard disc is another matter. Because they cache much less for writes, on FreeBSD and Solaris when the tests finish, the hard disk is up to date, ignoring the hard disc's own cache. (I'm only mentioning FreeBSD and Solaris because that's what I've used. It would be pretty similar on other Unix systems)
So, for the file-system, Linux has sacrificed some stability and reliability for performance. For desktop users this probably isn't too bad, but I (most sysadmin I know agree) wouldn't find it acceptable for anything 'mission critical'. Indeed, I have had a Linux installation die on me, and have had to bounce Linux servers, which always makes me kinda nervous. I've also seen Linux run fsck on bootup, even when I did a 'clean' reboot. However, on Solaris 7 (with file journaling on) fsck doesn't even need to be run on bootup because of the way file jounaling works. (incidentally, you can even turn file journalaing on/off under Solaris 7 while the system is running)
On another note, Linux does have a file jounaling file system in the works (I don't know if it is a full log file system) which would make things even faster, and also, more reliable. However, Solaris does have full log file systems available now (there's one from Sun, another from Veritas, and maybe even others), and they have been available for some time. (you just gotta pay for them). Most other commercial Unixes have file logging/journaling.
I have also seen cases where for servers under heavy load, Solaris could cope, but Linux couldn't - this was on indentical x86 hardware. This does reflect that fact that Solaris scales better than Linux. You can actually see this on the values I quote above - as the number of files in increased, the speed under Solaris was pretty constant, but with Linux it started to slow down - basicaly as the limits of Linux's cachine was started to being pushed.
However, this all proves very little because nothing I have shown here is even close to being a proper test. I'm not an expert on these things either... but maybe it'll give you some things to think about.