Subject: | share mappings between variables |
Date: | Sun, 28 Mar 2010 10:16:10 +1100 |
To: | bug-File-Map [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
As an idea for a feature, if File::Map is asked to map the same file
twice it could just point the second variable at the space already
mmapped for the first, releasing when both have finished.
I jigged up a bit of re-use like this in my iterator thingie. The
saving is address space, since each new mmap() takes a new bite out of
your 2Gb or whatever allowance, which might go rather quickly with a big
file used in multiple objects.
The simplest case would be what I do, mapping a whole file readonly. If
the inode and dev numbers are the same then re-use the map already made.
Grabbing a sub-region of an existing map oughtn't be too hard.
I suppose attention would have to be paid to some of the MAP_SHARED or
whatever flags. A starting point could be to re-use only if the flags
are the same.