[Haskell] memory management
ekmett at gmail.com
Thu Aug 6 14:16:26 EDT 2009
Meacham's JHC was headed towards region inference for a while (and may still
be), and I spent some time trying to use region inference in a research
compiler of my own, and I think both projects effectively came to that same
conclusion -- regions and laziness don't mix. Finding useful regions in a
lazy language is hard.
You can't effectively annotate them in the source due to laziness decoupling
object lifetimes from that of your source stack frames, so you need to infer
them once you've translated into some strict intermediate representation,
and the regions you can infer are finicky and brittle at best. Region-based
code optimization in ML tends to center around identifying which region is
leaking and why, and without any sort of source code tie for the region
system, that becomes a seriously black box. Thunks tend to hold onto lots of
context, so minor source changes yield vastly different region profiles.
Finally, all of the effort is called into question by the fact that regions
alone can't even handle a lot of interesting cases, so you need a collector
Tofte et al. wrote a retrospective at some point basically talking about the
now-known limitations of region based memory management [
http://portal.acm.org/citation.cfm?id=993040 , pre-print:
http://www.elsman.com/retro.pdf], which I think has the right balance of
optimism and pragmatism where it comes to region-based memory management and
talks about many of these issues.
On Thu, Aug 6, 2009 at 3:22 AM, Simon Peyton-Jones <simonpj at microsoft.com>wrote:
> Also region inference is likely to be much less effective in a lazy
> language, because (I think that) data escapes the lifetime of its allocating
> procedure much more often. I don't know of any work that has even tried it.
> | -----Original Message-----
> | From: haskell-bounces at haskell.org [mailto:haskell-bounces at haskell.org]
> | Behalf Of Simon Marlow
> | Sent: 04 August 2009 14:50
> | To: Sam Martin
> | Cc: Colin Runciman; Haskell at haskell.org
> | Subject: Re: [Haskell] memory management
> | On 04/08/2009 13:33, Sam Martin wrote:
> | >> Sounds like region inference to me.
> | >> (https://secure.wikimedia.org/wikipedia/en/wiki/Region_inference)
> | >
> | > Thanks, yes, that's exactly what I had in mind.
> | >
> | > Is anything like this is done in GHC?
> | Not at the moment, no.
> | Bear in mind that with generational GC, allocating memory that quickly
> | becomes garbage is quite cheap.
> | Cheers,
> | Simon
> | _______________________________________________
> | Haskell mailing list
> | Haskell at haskell.org
> | http://www.haskell.org/mailman/listinfo/haskell
> Haskell mailing list
> Haskell at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell