mmap() is slower than read() on SCSI/IDE on 2.0 and 2.1

Simon Kirby (sim@netnation.com)
Mon, 14 Dec 1998 00:39:42 -0800 (PST)


Here's something odd...

Testing originally done on 2.1.131ac8 but I tried 2.0.33 and 2.0.35 later
and got pretty much the same numbers.

I noticed that grep on a large file on a SCSI system was going at
~500kb/sec, and so I decided to try to figure out what was wrong.

At my machine at home, I created a 128MB file of nulls (head -c128m
/dev/zero > foo). I have 128MB ram, so it cleared out the beginning of it
from cache by the time it got to the end. I did a normal grep (v2.2) for
"foo" on it, and "vmstat 1" in another console showed that there was about
3,700 Kb/sec inbound and about 7% CPU utilization.

I recompiled grep without mmap support (disabled HAVE_MMAP in config.h),
and tried over again. The same "vmstat 1" in another console now showed
that there was about 10,500 Kb/sec inbound and about 55% CPU utilization.
Hmm.

Apart from the fact that grep eventually died from running out of memory
because it's using some weird exponential buffer read and eventually ends
up trying to use a buffer bigger than the amount of vm I have, this seems
to be a valid test -- at least to show that there's something weird
happening.

I copied my mmap()-less grep to the SCSI machine and tried the exact same
test on there. Without mmap(), vmstat reported ~13 Mb/sec and 70% CPU
utilization. With mmap(), vmstat reported ~495 Kb/sec (!!!) and about 2%
CPU utilization.

What on earth is wrong here? I know that SCSI takes a bit longer to set
up and issue a command to the drive, so my gut feeling is that there's
something with readahead that isn't happening properly (if at all).

Sct, Rik,...anybody? :)

Simon-

| Simon Kirby | Systems Administration |
| mailto:sim@netnation.com | NetNation Communications |
| http://www.netnation.com/ | Tech: (604) 684-6892 |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/