Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Oct 2013 14:45:37 +0100
From:      RW <rwmaillists@googlemail.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: mmap() question
Message-ID:  <20131009144537.4b1a5eb7@gumby.homeunix.com>
In-Reply-To: <95E0B821-BF9B-4EBF-A1E5-1DDCBB1C3D1B@gmail.com>
References:  <95E0B821-BF9B-4EBF-A1E5-1DDCBB1C3D1B@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 9 Oct 2013 15:42:27 +0400
Dmitry Sivachenko wrote:

> Hello!
> 
> I have a program which mmap()s a lot of large files (total size more
> that RAM and I have no swap), but it needs only small parts of that
> files at a time.
> 
> My understanding is that when using mmap when I access some memory
> region OS reads the relevant portion of that file from disk and
> caches the result in memory.  If there is no free memory, OS will
> purge previously read part of mmap'ed file to free memory for the new
> chunk.
> 
>...
>
> It seems I incorrectly understand how mmap() works, can you please
> clarify what's going wrong?
> 
> I expect that program to run indefinitely, purging some regions out
> of RAM and reading the relevant parts of files.

I think your problem is that you are accessing the memory so rapidly
that the pages can't even get out of the active queue. The VM system
isn't optimized for this kind of abnormal access. 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20131009144537.4b1a5eb7>