Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Mar 2006 17:17:33 -0500
From:      Mikhail Teterin <mi+mx@aldan.algebra.com>
To:        Matthew Dillon <dillon@apollo.backplane.com>
Cc:        alc@freebsd.org, stable@freebsd.org
Subject:   Re: weird bugs with mmap-ing via NFS
Message-ID:  <200603211717.34348.mi%2Bmx@aldan.algebra.com>
In-Reply-To: <200603212123.k2LLNMhO006344@apollo.backplane.com>
References:  <200603211607.30372.mi%2Bmx@aldan.algebra.com> <200603212123.k2LLNMhO006344@apollo.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
	[Moved from -current to -stable]

ืฆืิฯาฯห 21 ยลาลฺลฮุ 2006 16:23, Matthew Dillon ๗ษ ฮมะษำมฬษ:
> š š You might be doing just writes to the mmap()'d memory, but the system
> š š doesn't know that.

Actually, it does. The program tells it, that I don't care to read, what's 
currently there, by specifying the PROT_READ flag only.

> š š The moment you touch any mmap()'d page, reading or writing, the system
> š š has to fault it in, which means it has to read it and load valid data
> š š into the page.

Sounds like a missed optimization opportunity :-(

> :When I mount with large read and write sizes:
> :
> :šššššššmount_nfs -r 65536 -w 65536 -U -ointr pandora:/backup /backup
> :
> :it changes -- for the worse. Short time into it -- the file stops growing
> :according to the `ls -sl' run on the NFS server (pandora) at exactly 3200
> : FS blocks (the FS was created with `-b 65536 -f 8129').
> :
> :At the same time, according to `systat -if' on both client and server, the
> : š client continues to send (and the server continues to receive) about
> : 30Mb of some (?) data per second.

> š š It kinda sounds like the buffer cache is getting blown out, but not
> š š having seen the program I can't really analyze it.

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

> š š It will always be more efficient to write to a file using write() then
> š š using mmap()

I understand, that write() is much better optimized at the moment, but the 
mmap interface carries some advantages, which may allow future OSes to 
optimize their ways. The application can hint at its planned usage of the 
data via madvise, for example.

Unfortunately, my problem, so far, is with it not writing _at all_...

> š š and it will always be far, far more efficient to write to an NFS file in
> š š nfs block-sized chunks rather then in smaller chunks 
> š š due to the way the buffer cache works.

Yes, this is an example of how a good implemented mmap can be better than 
write. Without explicit writes by the application and without doubling the 
memory requirements, the data can be written in the most optimal way.

Thanks for your help. Yours,

	-mi



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603211717.34348.mi%2Bmx>