[Haskell-cafe] forkIO on multicore

2008-12-19 Thread Paul Keir
Hi all, I'm seeing no performance increase with a simple coarse-grained 2-thread code using Control.Concurrent. I compile with: > hc conc.hs -o conc --make -threaded and I run with > time ./conc +RTS -N2 But using either "-N1" or "-N2", the program runs in about 1.8secs. (I'd prefer a longer

Re: [Haskell-cafe] forkIO on multicore

2008-12-19 Thread Felipe Lessa
On Fri, Dec 19, 2008 at 2:27 PM, Paul Keir wrote: > I'm seeing no performance increase with a simple coarse-grained > 2-thread code using Control.Concurrent. I compile with: I didn't test your code, but [...] > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) > heavytask m = putMVar m (fibs !! 10

Re: [Haskell-cafe] forkIO on multicore

2008-12-19 Thread Don Stewart
pkeir: > Hi all, > > I'm seeing no performance increase with a simple coarse-grained > 2-thread code using Control.Concurrent. I compile with: > > > hc conc.hs -o conc --make -threaded Also, if you care about performance in the slightest , please use -O2 Code is typically 10-30x faster with opt

Re: [Haskell-cafe] forkIO on multicore

2008-12-19 Thread Luke Palmer
On Fri, Dec 19, 2008 at 9:27 AM, Paul Keir wrote: > Hi all, > > I'm seeing no performance increase with a simple coarse-grained > 2-thread code using Control.Concurrent. I compile with: > > > hc conc.hs -o conc --make -threaded > > and I run with > > > time ./conc +RTS -N2 > > But using either

Re: [Haskell-cafe] forkIO on multicore

2008-12-19 Thread Jake McArthur
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul Keir wrote: > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) This is a CAF (Constant Applicative Form). Since it is actually a constant it is never garbage collected, and is always shared, so each thread is only calculating it once. You have essenti

Re: [Haskell-cafe] forkIO on multicore

2008-12-19 Thread Luke Palmer
On Fri, Dec 19, 2008 at 9:27 AM, Paul Keir wrote: > module Main where > > import Control.Concurrent > > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) > > heavytask m = putMVar m (fibs !! 10) Oh, also, heavytask is not very heavy at all. It just writes the thunk (fibs !! 10) into the MVar

RE: [Haskell-cafe] forkIO on multicore

2008-12-19 Thread Paul Keir
I did indeed intend for the threads to evaluate before writing to the two variables, thanks. > heavytask m = putMVar m $! (fibs !! 10) I now see a time difference, but as you suggested, in the wrong direction (1.5s for one, and 3.6s for two threads). I was hoping for each thread to independen

Re: [Haskell-cafe] forkIO on multicore

2008-12-19 Thread Felipe Lessa
On Fri, Dec 19, 2008 at 3:16 PM, Paul Keir wrote: > can I not expect each thread to run on a separate core? Try moving 'fibs' inside 'heavyTask', like heavytask m = putMVar m $! (let fibs = 0 : 1 : zipWith (+) fibs (tail fibs) in (fibs !! 10)) Maybe this may trick the compiler into not shar

Re: [Haskell-cafe] forkIO on multicore

2008-12-19 Thread Duncan Coutts
On Fri, 2008-12-19 at 10:42 -0600, Jake McArthur wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Paul Keir wrote: > > fibs = 0 : 1 : zipWith (+) fibs (tail fibs) > > This is a CAF (Constant Applicative Form). Since it is actually a > constant it is never garbage collected, and is alw

RE: [Haskell-cafe] forkIO on multicore

2008-12-21 Thread Paul Keir
> So this benchmark is primarily a stress test of the parallel garbage > collector since it is GC that is taking 75-80% of the time. Note that > the mutator elapsed time goes down slightly with 2 cores compared to 1 > however the GC elapsed time goes up slightly. Thanks Duncan, Jake et al. I'm mor

RE: [Haskell-cafe] forkIO on multicore[MESSAGE NOT SCANNED]

2008-12-19 Thread Paul Keir
Thanks Luke, and everyone else. Ok, back to the drawing board. Paul From: Luke Palmer [mailto:lrpal...@gmail.com] Sent: 19 December 2008 16:44 To: Paul Keir Cc: haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] forkIO on multicore[MESSAGE NOT SCANNED] On Fri, Dec 19, 2008 at 9:27

Re: [Haskell-cafe] forkIO on multicore[MESSAGE NOT SCANNED]

2008-12-19 Thread Jake McArthur
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul Keir wrote: > Thanks Luke, and everyone else. Ok, back to the drawing board. You may be interested in this: http://cgi.cse.unsw.edu.au/~dons/blog/2007/11/29 - - Jake -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using

RE: [Haskell-cafe] forkIO on multicore[MESSAGE NOT SCANNED]

2008-12-23 Thread Paul Keir
Hi Duncan, I'm following the story regarding (parallel) GC in this example with interest, but forgive me if I ask a more minor question regarding your modification of an extra parameter, "n", to "heavytask". Does this really help (to ensure that each core does work independently)? Surely, with fib

RE: [Haskell-cafe] forkIO on multicore[MESSAGE NOT SCANNED]

2008-12-26 Thread Duncan Coutts
On Tue, 2008-12-23 at 18:27 +, Paul Keir wrote: > Hi Duncan, > > I'm following the story regarding (parallel) GC in this example > with interest, but forgive me if I ask a more minor question > regarding your modification of an extra parameter, "n", to > "heavytask". Does this really help (to