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

Bryan O'Sullivan bos at
Sat Jul 10 14:09:48 EDT 2010

Hi, Roman —

Recently, I switched the mwc-random package ( over from running in the ST
monad to using your primitive package. I didn't notice initially, but this
caused a huge performance regression.

mwc-random uses ST internally, and runs the benchmarks/Quickie
benchmark in 0.017 seconds.

mwc-random uses PrimMonad internally, and takes 1.328 seconds to run
the same benchmark.

That's about a factor of 80 slowdown. This causes a massive knock-on
performance loss in packages such as criterion that need fast PRNGs.

The problem is very easy to reproduce:

cabal install mwc-random-
cabal install mwc-random-
darcs get
cd mwc-random/benchmarks
ghc -fforce-recomp -O  -package mwc-random- --make Quickie -o
ghc -fforce-recomp -O  -package mwc-random- --make Quickie -o

time ./quickie-411
time ./quickie-513

If you could shed any light, I'd be most grateful, as this has me a bit
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Glasgow-haskell-users mailing list