[Haskell-cafe] Real-time garbage collection for Haskell

Don Stewart dons at galois.com
Thu Mar 4 14:10:00 EST 2010

> On 2010-03-01 19:37 +0000 (Mon), Thomas Schilling wrote:
> > A possible workaround would be to sprinkle lots of 'rnf's around your
> > code....
> As I learned rather to my chagrin on a large project, you generally
> don't want to do that. I spent a couple of days writing instance
> of NFData and loading up my application with rnfs and then watched
> performance fall into a sinkhole.
> I believe that the problem is that rnf traverses the entirety of a large
> data structure even if it's already strict and doesn't need traversal.
> My guess is that doing this frequently on data structures (such as Maps)
> of less than tiny size was blowing out my cache.

And rnf will do the traversal whether it is needed or not.
Imo, it is better  to ensure the structures you want are necessarily
strict by definition, so that only the minimum additional evaluation is

'rnf' really is a hammer, but not everything is a nail.

-- Don

More information about the Haskell-Cafe mailing list