Re: Thread implementations...

Linus Torvalds (torvalds@transmeta.com)
Sat, 27 Jun 1998 11:33:42 -0700 (PDT)


On Sat, 27 Jun 1998, David S. Miller wrote:
>
> It was just read-write vs sendfile vs map-write-munmap (vs the
> "perfect" numbers of a just write). All the cases require the same
> open-close code, so I didn't think that was worth testing because
> it shouldn't change relative timings, just add constant overhead.
>
> Strange... I am curious what the sendfile vs mmap (ie. don't do the
> map/unmap parts around each iteration) case is. A lot of boneheads on
> 64-bit machines get killer specweb by mmaping readonly the entire
> working set of the benchmark file set during the warmup run, and just
> keep them mapped like this.

Well, mmap() has a few problems performancewise:
- page fault overhead from demand-loading. We could force mmap() to bring
everything in, and I think Irix and others have flags for that (or
"madvice(NOW)" or similar). That's usually a good idea if you have lots
of memory and know that you can bring it all in and that it will be
used.
- the mmap test I did was "mmap-write-munmap". I don't consider the case
where we just map it once and write it multiple times to be a realistic
case. I gave that test as the "pure write()" performance, and that was
indeed the fastest.

The point about sendfile() is that you should be able to get equally
killer specweb numbers using it, but without doing a ton of crap in order
to get those numbers. My tests show that yes, if you mmap once and then
write from the same map ten thousand times, then that is indeed the
fastest way to pump data through the system. No surprise there. But
sendfile() was not much slower, and actually works under real load too
(including the kind of load that means that you can't keep the whole
working set in memory all the time).

sendfile() will also actually do much better read-ahead than mmap(), and
will more naturally read ahead the next pages while it's still writing the
previous ones. So once you actually have to hit the disk, sendfile()
should again be better than mmap (even with madvice).

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu