Massive slowdown in mwc-random after switching to use of primitive package

Roman Leshchinskiy rl at cse.unsw.edu.au
Mon Jul 12 23:14:30 EDT 2010


On 11/07/2010, at 22:49, Bryan O'Sullivan wrote:

> On Sun, Jul 11, 2010 at 12:59 AM, Dan Doel <dan.doel at gmail.com> wrote:
> 
>> You're using GHC 6.12.x presumably?
> 
> That's right.
>  
>> There are known performance problems with
>> using abstract PrimMonads in that version (and, actually, just using IO as
>> well).
>> 
> 
> Ah, that's a shame. I'm surprised it would be affecting IO too!

FWIW, I tried a couple of different designs when writing primitive and the current one seems to works best with 6.12, at least for the things I'm using it for. Really, 6.12 just seems to be rather hopeless here.

>> In the IO case for instance, checking the core tends to reveal lots of casting
>> between RealWorld and PrimState IO, despite the fact that those should be
>> identical.
>> 
> 
> I'd certainly noticed that the Core for the PrimMonad code was huge and almost impossible to follow for the enormous amount of casting that was taking place.

The head has -dsuppress-coercions which omits coercion terms when pretty printing Core. It would be easy to backport that to 6.12.

> I might revert both mwc-random and statistics back to using plain ST for now, then, as having them run slightly faster than 1% of their former speed is a bit painful :-( 

I fear that's the only sensible solution. I wouldn't throw away your current code, though, as 6.14 won't have these problems (hopefully).

Roman




More information about the Glasgow-haskell-users mailing list