mmap performance and memory use
alan.l.cox at gmail.com
Fri Oct 7 17:39:14 UTC 2011
On Thu, Oct 6, 2011 at 11:01 AM, Kostik Belousov <kostikbel at gmail.com>wrote:
> On Thu, Oct 06, 2011 at 04:41:45PM +0200, Wojciech Puchar wrote:
> > i have few questions.
> > 1) suppose i map 1TB of address space as anonymous and touch just one
> > page. how much memory is used to manage this?
> I am not sure how deep the enumeration you want to know, but the first
> approximation will be:
> one struct vm_map_entry
> one struct vm_object
> one pv_entry
> Page table structures need four pages for directories and page table
> > 2) suppose we have 1TB file on disk without holes and 100000 processes
> > mmaps this file to it's address space. are just pages shared or can
> > pagetables be shared too? how much memory is used to manage such
> > situation?
> Only pages are shared. Pagetables are not.
> For one thing, this indeed causes more memory use for the OS. This is
> somewhat mitigated by automatic use of superpages. Superpage promotion
> still keeps the 4KB page table around, so most savings from the
> superpages are due to more efficient use of TLB.
You are correct about the page table page. However, a superpage mapping
consumes a single PV entry, in place of 512 or 1024 PV entries. This winds
up saving about three physical pages worth of memory for every superpage
More information about the freebsd-hackers