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

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


Hi, Roman —

Recently, I switched the mwc-random package (
http://hackage.haskell.org/package/mwc-random) 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 0.4.1.1 uses ST internally, and runs the benchmarks/Quickie
benchmark in 0.017 seconds.

mwc-random 0.5.1.3 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-0.4.1.1
cabal install mwc-random-0.5.1.3
darcs get http://darcs.serpentine.com/mwc-random/
cd mwc-random/benchmarks
ghc -fforce-recomp -O  -package mwc-random-0.4.1.1 --make Quickie -o
quickie-411
ghc -fforce-recomp -O  -package mwc-random-0.5.1.3 --make Quickie -o
quickie-513

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

If you could shed any light, I'd be most grateful, as this has me a bit
confounded.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20100710/e3f72f74/attachment.html


More information about the Glasgow-haskell-users mailing list