Reading via mmap stinks (Re: weird bugs with mmap-ing via NFS)

Mikhail Teterin mi+mx at aldan.algebra.com
Thu Mar 23 19:04:00 UTC 2006


вівторок 21 березень 2006 17:48, Matthew Dillon Ви написали:
>     Reading via mmap() is very well optimized.

Actually, I can not agree here -- quite the opposite seems true. When running 
locally (no NFS involved) my compressor with the `-1' flag (fast, least 
effective compression), the program easily compresses faster, than it can 
read.

The Opteron CPU is about 50% idle, *and so is the disk* producing only 15Mb/s. 
I guess, despite the noise I raised on this subject a year ago, reading via 
mmap continues to ignore the MADV_SEQUENTIONAL and has no other adaptability.

Unlike read, which uses buffering, mmap-reading still does not pre-fault the 
file's pieces in efficiently :-(

Although the program was written to compress files, that are _likely_ still in 
memory, when used with regular files, it exposes the lack of mmap 
optimization.

This should be even more obvious, if you time searching for a string in a 
large file using grep vs. 'grep --mmap'.

Yours,

	-mi

http://aldan.algebra.com/~mi/mzip.c


More information about the freebsd-stable mailing list