[racket] Concurrent execution
Beautiful!
the results are much clearer this way, and it's good to know why. I noticed (googled) that you have had this figured out long ago :) This was a great learning excercise, and I'm glad I was on the right track.
br, jukka
> -----Original Message-----
> From: Eli Barzilay [mailto:eli at barzilay.org]
> Sent: 03 October 2011 22:57
> To: jukka.tuominen at finndesign.fi
> Cc: Sam Tobin-Hochstadt; Racket mailing list; Robby Findler; Ivanyi
> Peter
> Subject: Re: [racket] Concurrent execution
>
>
> Four hours ago, jukka.tuominen at finndesign.fi wrote:
> >
> > Wow, that's great Sam!
> >
> > I tried to create a simple test around it (below), but it's
> hard to find a
> > pattern in the results. A few notes, though:
> >
> > - The results vary a great deal from run to run
> > - 'Plain map' seems to do things in parallel itself!?
> > (by looking at the System Monitor during the test run)
> > This may paralyze secondary parallelizing :)
> > - Plain map does usually better with short lists. No wonder.
> > - The amount of distribution should be related to the available
> > number of HW processors; not the more the merrier, obviously.
>
> Using factorial to measure speed is not a good idea -- since with
> bigger numbers much of the time is spent on GC work for the bignums.
> Also, it looks like you were timing the printouts too, and with big
> numbers that can take a considerable amount of time too.
>
> Here's a short test using a factorial -- note that pmap takes a bit
> more overall cpu time, but the real time is much shorter.
>
> -> (define (pmap f xs)
> (map touch (map (λ (x) (future (lambda () (f x)))) xs)))
> -> (define (fib n) (if (<= n 1) n (+ (fib (- n 1)) (fib (- n 2)))))
> -> (time (map fib '(35 36 37 38)))
> cpu time: 5088 real time: 5098 gc time: 0
> '(9227465 14930352 24157817 39088169)
> -> (time (pmap fib '(35 36 37 38)))
> cpu time: 5106 real time: 2292 gc time: 0
> '(9227465 14930352 24157817 39088169)
>
> --
> ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
> http://barzilay.org/ Maze is Life!
>