Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Mar 2006 18:14:28 -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:  <200603211814.32457.mi%2Bmx@aldan.algebra.com>
In-Reply-To: <200603212248.k2LMmTMj006791@apollo.backplane.com>
References:  <200603211607.30372.mi%2Bmx@aldan.algebra.com> <200603211717.34348.mi%2Bmx@aldan.algebra.com> <200603212248.k2LMmTMj006791@apollo.backplane.com>

next in thread | previous in thread | raw e-mail | index | archive | help
צ×ÔÏÒÏË 21 ÂÅÒÅÚÅÎØ 2006 17:48, Matthew Dillon ÷É ÎÁÐÉÓÁÌÉ:
> :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.
>
> š š That's an architectural flag. šVery few architectures actually support
> š š write-only memory maps.

Why does the flag being architectural matter? The application tells the OS, 
that it only plans to write...

> š š It does not change the fact that the operating system must validate the
> š š memory underlying the page, nor does it imply that the system shouldn't.

> :Sounds like a missed optimization opportunity :-(

>    Even on architectures that did support write-only memory maps, the
>    system would still have to fault in the rest of the data on the page,
>    because the system would have no way of knowing which bytes in the 
>    page you wrote to (that is, whether you wrote to all the bytes in the
>    page or whether you left gaps).

Indeed, but in my case there is no data in the target file to begin with -- it 
is "created" by ftruncate() prior to mmap-ing.

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

>    I can't access this URL, it says 'not found'.

Uh, sorry, the newest Apache is quite restrictive. I just tweaked it, please, 
try again.

> :The application can hint at its planned usage of the 
> :data via madvise, for example.

>    Yes, but those advantages are limited by the way memory mapping hardware
>    works.  There are some things that simply cannot be optimized through
>    lack of sufficient information.

There is no need for additional information from hardware, when, deciding -- 
based on the information supplied by madvise -- which parts of the file (if 
any) to keep in cache.

>    I don't think mmap()-based writing will EVER be more efficient then
>    write() except in the case where the entire data set fits into memory
>    and has been entirely cached by the system.

My custom compressor is intended to operate on the database and filesystem 
dumps, as they arrive (uncompressed) from the computers being backed up via 
NFS. It is intended to pick most of the input data, while it is still in the 
RAM cache.

It was more convenient for me to implement outputting via mmap as well. The 
bulk of the time is spent reading and compressing anyway -- the output is 
many time smaller than the input. So the write performance never bothered me, 
until I tried to do it via NFS and encountered all of these bugs :-( ...

	-mi



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