5 Nov 2012 23:34
more sharing in generated code
Peter Divianszky <divipp <at> gmail.com>
2012-11-05 22:34:15 GMT
2012-11-05 22:34:15 GMT
Hi Joachim,
> > ...
>
> I think one problem with this approach is that now, until "x r'" is
> evaluated, you keep both r and r' alive. If r was _not_ retained by
> anything else, then you are now preventing the GC from freeing it and
> hence increasing the memory footprint.
Good remark, this can be solved with weak pointers, although I don't
know how efficient they are.
----------------------
The next version of the proposal
Replace every record update
r' = r { x = y }
with
r' = r { x = update (weak r) r' (x r) y) }
in generated code if some sharing aware optimization flag is enabled.
Auxilary functions:
weak :: a -> Weak a
-- make a weak pointer which is not followed by GC
(Continue reading)
RSS Feed