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

Gary Palmer gpalmer at
Thu Mar 23 23:32:06 UTC 2006

On Thu, Mar 23, 2006 at 03:16:11PM -0800, Matthew Dillon wrote:
>     In anycase, this sort of test is not really a good poster child for how
>     to use mmap().  Nobody in their right mind uses mmap() on datasets that
>     they expect to be uncacheable and which are accessed sequentially.  It's
>     just plain silly to use mmap() in that sort of circumstance.  This is
>     a trueism on ANY operating system, not just FreeBSD.  The uncached
>     data set test (using unmount/mount and a dataset which fits into memory)
>     is a far more realistic test because it simulates the most common case
>     encountered by a system under load... the accessing of a reasonably sized
>     data set which happens to not be in the cache.

I thought one serious advantage to this situation for sequential read
mmap() is to madvise(MADV_DONTNEED) so that the pages don't have to
wait for the clock hands to reap them.  On a large Solaris box I used
to have the non-pleasure of running the VM page scan rate was high, and
I suggested to the app vendor that proper use of mmap might reduce that
overhead.  Admitedly the files in question were much smaller than the
available memory, but they were also not likely to be referenced again
before the memory had to be reclaimed forcibly by the VM system.

Is that not the case?  Is it better to let the VM system reclaim pages
as needed?



More information about the freebsd-stable mailing list