On 25/09/2009 16:52, Duncan Coutts wrote:
On Fri, 2009-09-25 at 14:58 +0100, Simon Marlow wrote:
The underlying problem in your example may be fragmentation, due to the
way that ByteStrings are pinned and hence hold on to the whole 4KB block
in which they were allocated until they die. Duncan has been thinking
about how to improve the situation, but I'm not sure of the current
status - Duncan?
It's a medium term project. There is no short term fix. The problem is
using pinned heap arrays. Switching to unpinned would entail an almost
complete rewrite of the bytestring implementation. That is something I
would like to do however it's not quick, and it would have to pass the
"dons" test, that the results are absolutely definitely as good as the
current version. Don is understandably nervous about upsetting the
existing mature implementation. That would also include the ability to
mmap, which would be lost under a straightforward re-implementation to
use unpinned arrays. Handling mmap'ed ByteArray# is another
mini-project.
As a workaround, would it be possible to provide an unsafePack that
gives you an unpinned ByteString, with the onus on the caller to ensure
they never pass it to C? Perhaps it would even be possible to check
that it was never passed to C? And it's only "safe" foreign imports
that are dangerous, it's fine to pass an unpinned ByteArray to an unsafe
foreign import (though that's probably not something we should rely too
heavily on, in case we want to change it in the future).
Cheers,
Simon
_______________________________________________
darcs-users mailing list
darcs-users@darcs.net
http://lists.osuosl.org/mailman/listinfo/darcs-users