Subject: | sensibleness of mmapping |
Date: | Sat, 11 Dec 2010 10:28:46 +1100 |
To: | bug-File-Map [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
As a final idea coming out of what I've tinkered with mmapping,
File::Map might offer a way for an application to check how sensible it
is to mmap a given file, or demand that it only be done when sensible.
So far my idea of "sensible" is
* If a filehandle already has an :mmap layer then it's not sensible to
mmap again, plain read should be just about as good.
(Or unless in the distant future that existing mapped memory could be
accessed directly.)
* If the mmap would use up too much address space then it's not a good
idea.
This depends of course on what flavour of address space an mmap uses,
but my idea was to look at the total current mmaps plus the
prospective new map, and consider it not sensible to go past 1/5 of
the available address space, with that space being guessed as 1/4 of
the C pointer size. The net effect a modest 200Mb on a 32-bit system.
The total mmapped would be across all threads, presuming all take from
the same address space, and File::Map may know this if it's thread-away.
The 1/5 and 1/4 fractions are rather conservative. I imagine data space
is generally at least 1/2 a C pointer, and could even be almost all of
it.
At any rate the point would be that File::Map could provide some info or
checks, better at least than what an application would know.