[darcs-users] darcs patch: Handle empty files in mmapFilePS. Also cater for FD sh...
kowey at darcs.net
Wed Feb 4 20:37:35 UTC 2009
On Wed, Feb 04, 2009 at 20:02:52 +0100, Petr Rockai wrote:
> Well, I did have a look before sending and I believe it's safe.
> It's in the catch handler. This code trips only if unsafeMMapFile fails for
> reason other than empty file (which *usually* is the open fd limit). The size
> check is fairly expensive to do as well, that's why I only do it when
> unsafeMMapFile fails (which is rather cheaper than the file size check, due to
> (IMHO) stupid System.Posix.File implementation involving unsafePerformIO).
And thanks for pointing that out. Also, sorry for being dense, but
could you explain to me explicitly the relationship between file
descriptors and garbage collection? I'm not really making the leap
I'm guessing that it's something to do with this remark in the
Memory mapped files will behave as if they were read lazily -- pages
from the file will be loaded into memory on demand.
And I only guess this because when I use readFile on a whole lot of
files, I run out of file descriptors. I just dumbly use a strict
version of readFile, which makes the problem go away. But otherwise,
the whole mmap fd thing is a bit fuzzy for me :-(
Also, how did our old mmap code deal with this situation?
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 197 bytes
Desc: Digital signature
More information about the darcs-users