Re: mmap

From: Stephen R. van den Berg <srb@dont-contact.us>
Date: Sun, 31 May 1998 11:52:27 +0200

--MimeMultipartBoundary
Content-Type: text/plain; charset=us-ascii

Henrik Nordstrom wrote:
>Stephen R. van den Berg wrote:
>> above worst case is equally likely to occur. I.e. there is no
>> particular reason why mmapping would cause this worst case to
>> happen more often than in the non-mmapping case.

>Well, it depends. If we mmap() more memory than we would normally
>allocate then we increases our active page set, pushing us closer to
>paging.

Only if we actually access the full mmapped regions and the OS is not
clever enough about releasing pages which haven't been used for a while
(which, Linux 2.0 currently isn't all that clever about, I admit; Linux
2.2 does this a whole lot better; I can't speak for other OSes).

>And if the OS does NOT use VM for file I/O (Linux 2.0 file-writes is one
>example, HP-UX another) then using mmap only adds more stress to the VM
>system.

True, probably.

>If the OS uses VM based file I/O then mmap() could save us a few pages.
>The amount is easy to estimate as it is maximum the amount of cache_mem
>+ 8K per open swap-object(file).

It would allow us roughly to double cache_mem, so the hot object cache
could be a lot larger on the same system.

>Keeping large amounts mmap()ed for a long time is NOT an option for
>Squid as this blow any VM system into paging. If we are to use mmap, we
>have to do it in small chunks when needed to limit the active VM
>pageset. By unmap:ing the pages we don't need we tell the OS that we are
>done with these pages. If we don't then the OS pages mmap:ed data and
>swap with equal priority, quickly pushing Squid out on swap.

No argument here. Typical OSes are not clever enough (yet) in this
respect.

>I do expect that many UNIX:es have a lot of trouble handling thousands
>of mmaps. If mmap is part of the basic VM design it should be ok, but
>where it is "added" I would expect a lot of unexpected troubles and
>limitations.

I can see (and influence) the direction Linux is taking, which is good
in this respect, I can only assume that other OS developers are taking the
same direction. If this is not the case, we would end up maintaining
two different systems in Squid (one for mmap()-optimised OSes and one
for read()/write() optimised OSes), which is a lot more work, of course.

-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg (AKA BuGless).
Gravity is running out!  Conserve gravity: walk with a light step, use tape,
magnets or glue instead of paperweights, avoid showers... take baths instead.
--MimeMultipartBoundary--
Received on Tue Jul 29 2003 - 13:15:50 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:48 MST