[Haskell-cafe] Re: Benchmarking and Garbage Collection
Neil Brown
nccb2 at kent.ac.uk
Fri Mar 5 08:45:25 EST 2010
Simon Marlow wrote:
>> import Control.Concurrent
>> import Control.Concurrent.CML
>> import Control.Monad
>>
>> main :: IO ()
>> main = do let numChoices = 2
>> cs <- replicateM numChoices channel
>> mapM_ forkIO [replicateM_ (100000 `div` numChoices) $ sync $ transmit
>> c () | c <- cs]
>> replicateM_ 100000 $ sync $ choose [receive c (const True) | c <- cs]
>
> Good grief. Can I get a copy of this program? It might be something
> simple that we can fix. Just having lots of threads shouldn't be a
> performance problem per se, we have benchmarks that create millions of
> threads without any problems.
That's all the code you need, along with the cml package from Hackage.
Put the above few lines into GoodGrief.hs (the reply has munged the
indentation slightly), and do:
cabal install cml
ghc --make -threaded GoodGrief.hs
./GoodGrief +RTS -s
That got me the listed results on GHC 6.12.1 (I did use -threaded but
not -N as I was on a single-core machine; I believe the same problem
occurs without -threaded). The problem is in the CML library that the
above code uses.
Neil.
More information about the Haskell-Cafe
mailing list