DiffArray Performance

Simon Marlow simonmar at microsoft.com
Thu Nov 6 15:56:16 EST 2003

> Could you not provide MVar free calls for use inside a 
> withMVar function,
> minimising locking overhead?

Are you suggesting something like

     :: DiffArray ix e
     -> (UnlockedDiffArray ix e -> IO a) -> IO a

and then a bunch of fast operations on UnlockedDiffArray?  The problem
with this is that DiffArrays live in the pure world, not the IO world.
This is one good reason they have to be protected by MVars: the
imperative oeprations happen behind the scenes, so the programmer gets
no chance to do his own locking or otherwise ensure that the DiffArray
is uesd safely.

Functions like withDiffArray don't work too well in the pure world,
because you have to arrange that the "inner" part is fully deepSeq'd
before you can release the lock.


More information about the Glasgow-haskell-users mailing list