[Haskell-cafe] optimising for vector units

Jan-Willem Maessen - Sun Labs East Janwillem.Maessen at Sun.COM
Tue Jul 27 14:38:00 EDT 2004


MR K P SCHUPKE wrote:
> A final point someone made about the cost of starting threads... Surely 
> the obvious approach
> is to start one OS thread per execution unit, and do all the thread 
> starting with the very
> lightweight haskell threads...

That was me.  I think you're underestimating the cost of starting 
threads even in this very lightweight world.  Again, tens of 
instructions between startup, shutdown, and (very important) 
synchronization to make sure that other threads see the results which 
were produced.  It *can* be done without locks, but it often can't be 
done without memory fences of some sort.

If you actually have to start OS threads, the cost is thousands or 
tens of thousands of cycles.

Even with very lightweight thread creation, you probably don't want to 
  do a multiplication in a separate thread---unless it's, say, an 
Integer multiply with a minimum of a thousand digits or so.

-Jan-Willem Maessen

> Keean
> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list