On Saturday 25 March 2006 05:39 am, Peter Jeremy wrote:
= On Fri, 2006-Mar-24 15:18:00 -0500, Mikhail Teterin wrote:
= >which there is not with the read. Read also requires fairly large
= >buffers in the user space to be efficient -- *in addition* to the
= >buffers in the kernel. 
= 
= I disagree.  With a filesystem read, the kernel is solely responsible
= for handling physical I/O with an efficient buffer size. The userland
= buffers simply amortise the cost of the system call and copyout
= overheads.

I don't see a disagreement in the above :-) Mmap API can be slightly faster 
than read -- kernel is still "responsible for handling physical I/O with an 
efficient buffer size". But instead of copying the data out after reading, it 
can read it directly into the process' memory.

= >I'm also quite certain, that fulfulling my "demands" would add quite a
= >bit of complexity to the mmap support in kernel, but hey, that's what the
= > kernel is there for :-)
= 
= Unfortunately, your patches to implement this seem to have become detached
= from your e-mail. :-)

If I manage to *convince* someone, that there is a problem to solve, I'll 
consider it a good contribution to the project...

= mmap can lend itself to cleaner implementatione because there's no
= need to have a nested loop to read buffers and then process them.  You
= can mmap then entire file and process it.  The downside is that on a
= 32-bit architecture, this limits you to processing files that are
= somewhat less than 2GB.

First, only one of our architectures is 32-bit :-) On 64-bit systems, the 
addressable memory (kind of) matches the maximum file size. Second even with 
the loop reading/processing chunks at a time, the implementation is cleaner, 
because it does not need to allocate any memory nor try to guess, which 
buffer size to pick for optimal performance, nor align the buffers on pages 
(which grep is doing, for example, rather hairily).

= The downside is that touching an uncached page triggers a trap which may
= not be as efficient as reading a block of data through the filesystem
= interface, and I/O errors are delivered via signals (which may not be as
= easy to handle).

My point exactly. It does seem to be less efficient *at the moment* and I
am trying to have the kernel support for this cleaner method of reading 
*improved*. By convincing someone with a clue to do it, that is... :-)

= >Would you care to look at my program instead? Thanks:
= >
= >     http://aldan.algebra.com/mzip.c

I'm sorry, that should be  http://aldan.algebra.com/~mi/mzip.c -- I checked 
this time :-(

= I tried writing a program that just mmap'd my entire (2GB) test file
= and summed all the longwords in it.

The files I'm dealing with are database dumps -- 10-80Gb :-) Maybe, that's,
what triggers some pessimal case?..

Thanks! Yours,

        -mi
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to