[Haskell-cafe] localized memory management?

Edward Z. Yang ezyang at mit.edu
Thu Jan 21 04:23:38 UTC 2016

Hello Johannes,

We wrote a PLDI paper on precisely this topic!


The feature never got merged to GHC proper, however, because it required
some changes to GHC's generated code which were a slight pessimization
for people who were not planning on using resource limits (the loss was
characterized in the paper), and it didn't seem right to add an entirely
new way (ala profiling/dynamic/etc) to GHC just to support resource limits.


Excerpts from Johannes Waldmann's message of 2016-01-20 06:53:39 -0800:
> Dear cafe, how would you approach this task:
> find (enumerate) those  x from a list  xs
>   for which some computation is not successful
>      within some resource bound
> (it weeds out uninteresting data, leaving just the hard cases,
> which will be treated later by other means)
> Input and result could be lazy lists, computations are pure.
> If the bounded resource is time, then I can use System.Timeout.
> This puts me into IO, but OK.
> Perhaps I want to do some logging output anyways.
> The problem is with bounding space.
> Assume that "computation on x" (sometimes) allocates a lot.
> Then the whole program will just die with "heap exhausted",
> while in fact I want to terminate just the computation on
> this x, garbage-collect, and continue.
> I could make the space usage explicit:
> each step of the computation could additionally
> compute a number that approximates memory usage.
> (Assume that this usage varies wildly with each step.)
> Then I can stop iterating when this reaches some bound.
> Or, I just compile the computation into a separate executable,
> and I call it (for each x) via the operating system,
> because there I can bound space (with  ulimit)
> Is there some way to achieve this in Haskell land?
> - J.W.

More information about the Haskell-Cafe mailing list