[Haskell-cafe] Parallel weirdness

Jake Mcarthur jake.mcarthur at gmail.com
Sat Apr 19 12:17:16 EDT 2008


Okay, here are my thoughts:

On Apr 19, 2008, at 9:56 AM, Andrew Coppin wrote:

> Weird thing #1: The first time you sort the data, it takes a few  
> seconds. The other 7 times, it takes a split second - roughly 100x  
> faster. Wuh?

This looks like standard memoization to me. I know, I know, GHC  
doesn't automagically memoize… it still has some behaviors I  
personally would label as a sort of primitive memoization, and this is  
one of them.

I learned about this by losing an argument. ;)

> Weird thing #2: The parallel version runs *faster* than the  
> sequential one in all cases - even with SMP disabled! (We're only  
> talking a few percent faster, but still.)

> Weird thing #3: Adding the "-threaded" compiler option makes  
> *everything* run a few percent faster. Even with only 1 OS thread.

I think these are not noteworthy. Weird things happen in benchmarks  
(which is why I have learned not to trust them).

> Weird thing #4: Adding "-N2" makes *everything* slow down a few  
> percent. In particular, Task Manager shows only one CPU core in use.

Then your algorithm must not truly be parallel. That is the only  
explanation I can think of.

- Jake McArthur


More information about the Haskell-Cafe mailing list