'import ccall unsafe' and parallelism

Edward Z. Yang ezyang at mit.edu
Thu Aug 14 16:32:40 UTC 2014


I have to agree with Brandon's diagnosis: unsafePerformIO will
take out a lock, which is likely why you are seeing no parallelism.

Edward

Excerpts from Brandon Allbery's message of 2014-08-14 17:12:00 +0100:
> On Thu, Aug 14, 2014 at 11:54 AM, Christian Höner zu Siederdissen <
> choener at tbi.univie.ac.at> wrote:
> 
> > go xs = unsafePerformIO $ do
> >   forM_ xs $ cfun
> >   return $ somethingUnhealthy
> >
> 
> I wonder if this is your real problem. `unsafePerformIO` does some extra
> locking; the FFI specifies a function `unsafeLocalState`, which in GHC is
> `unsafeDupablePerformIO` which skips the extra locking.
> 


More information about the Glasgow-haskell-users mailing list