[darcs-users] darcs patch: Handle empty files in mmapFilePS. Also cater for FD sh...

Eric Kow 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.

Thanks! 

> 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
here.

I'm guessing that it's something to do with this remark in the
bytestring-mmap haddock:

  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
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090204/c0a887e9/attachment.pgp>


More information about the darcs-users mailing list