[Haskell-cafe] Re: Parallelism and expensive calculations that may not be needed

Simon Marlow simonmarhaskell at gmail.com
Fri Jun 8 11:12:50 EDT 2007


Felipe Almeida Lessa wrote:
> On 6/8/07, Simon Marlow <simonmarhaskell at gmail.com> wrote:
>> The problem occurs when you've found the Nothing, but the rest of the 
>> list has
>> already been sparked.  You really want to throw away all those sparks, 
>> but
>> there's no way to do that currently.  One way you could improve the 
>> situation
>> though is to only spark the next N elements in the list, limiting the 
>> amount of
>> speculation.
> 
> I see. I was hoping that GHC would see that the sparked thunk could be
> garbage collected (as the rest of the list with sparks was thrown
> away) and would not force it. It is expensive to GC before starting
> every spark, of course, but maybe the GC could look for sparks that
> could be removed whenever it collects?

Actually at the moment the GC treats sparks as roots, but that's wrong.  Thanks 
for reminding me, I must fix that sometime.

Cheers,
	Simon


More information about the Haskell-Cafe mailing list