Ubuntu 64 Bit and GHCs Garbage Collector
Hi,
Update: I tested a kernel 2.6.31-12 (from kernel.org) and had the same (if not even worse) behaviour as with 2.6.31-19. So, I apologize. It has nothing to do with Ubuntu per se, but probably with the linux-kernel; that makes me wonder if I haven’t done something faulty: that behaviour should have attracted the attention of some other Haskell developers in the meantime, but I couldn’t find any information on it. So, take in mind that the following could be incorrect…
finding this strange behaviour had cost me a lot of hours (see also my post on the haskell-cafe mailing list), because honestly, who do you blame if your parallel programm behaves strangely:
- yourself
- the compiler
- the special patches of your OS vendor to your linux kernel
Since the probabilities of an error in 2. are quite low (at lot of people use GHC and its parallelization techniques) and — at least I thought that — those in 3. are low, too (some of those people from 1. should be using my OS with GHC for parallel development), I chose 1. Hence, I spent a lot of time trying to find synchronisation and performance problems in my code, which in fact, weren’t there!
The current setup of a standard Ubuntu 9.10 (64 bit) is a vanilla kernel (2.6.31-19-generic) , used with GHC 6.12.1. Look at this small and seemingly innocent program
-- 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
showCReal (fromEnum digits) pi `pseq` return ()
that you can compile with
ghc -- make -O2 -threaded Pi.hs -o pi
Benchmarking with
for i in `seq 1 5`;do time pi 5000 +RTS -N1;done for i in `seq 1 5`;do time pi 5000 +RTS -N2;done
I received the following exemplary runtimes for the vanilla ubuntu kernel.
And this is the threadscope profile of a particular bad run:

As you can see, nearly all time is spend in the Garbage Collector, doing…things, GCs do…
I then compiled my own kernel2.633 from kernel.org and received these results:
Conclusion: At least for me and my parallel programs (and even some innocent toy programs like Pi.hs) does the standard Ubuntu 64bit kernel harm parallel performance (especially that of the GC) a lot.
I find this highly surprising:
- Ubuntu is a widely used distribution
- 64 bit versions are also becoming quite common
- in my perception Haskell developers use parallelism a lot
Question. Either the intersection of these properties is quite small or my measurements have some serious flaw. I’d be glad if someone could disprove my results (and give me the opportunity to learn a bit) or support my measurements.


