[Haskell-cafe] GHC's parallel garbage collector -- what am I doing
mlesniak at uni-kassel.de
Mon Mar 1 10:59:54 EST 2010
Sorry for this long post, but I can't think of a way to describe and explain
the problem in a shorter way.
I've (again) a very strange behaviour with the parallel GC and would be glad
if someone could either reproduce (and explain) it or provide a solution. A
similar but unrelated problem has been described in .
The following demonstration program, which is a much smaller and
single-threaded version of my real problem behaves as my real program.
It does some number crunching by calculating pi to a definable precision:
> -- File Pi.hs
> -- you need the numbers package from hackage.
> module Main where
> import Data.Number.CReal
> import System.Environment
> import GHC.Conc
> main = do
> digits <- (read . head) `fmap` getArgs :: IO Int
> calcPi digits
> calcPi digits = showCReal (fromEnum digits) pi `pseq` return ()
Compile it with
ghc --make -threaded -O2 Pi.hs -o pi
On my two-core machine I get the following quite strange and
* Using one thread:
$ for i in `seq 1 5`;do time pi 5000 +RTS -N1;done
* Using two threads, hence the parallel GC is used:
for i in `seq 1 5`;do time pi 5000 +RTS -N2;done
* Using two threads, but disabling the parallel GC:
for i in `seq 1 5`;do time pi 5000 +RTS -N2 -qg;done
I've additionally attached the threadscope profile of a really bad run,
$ time pi 5000 +RTS -N2 -ls
as file pi.pdf
Just disabling the parallel GC leads to very bad performance in my original
code, which forks threads with forkIO and does a lot of communications. Hence,
using -qg is not a real option for me.
Do I have overlooked some cruical aspect of this problem? If you've
read this far, thank you for reading ... this far ;-)
Dipl.-Inf. Michael C. Lesniak
University of Kassel
Programming Languages / Methodologies Research Group
Department of Computer Science and Electrical Engineering
Wilhelmshöher Allee 73
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 28830 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100301/ab3ecdd2/pi-0001.pdf
More information about the Haskell-Cafe