Peter Divianszky | 5 Nov 23:34 2012
Picon

more sharing in generated code

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)

Joachim Breitner | 6 Nov 09:25 2012
Picon

Re: more sharing in generated code

Hi,

Am Montag, den 05.11.2012, 23:34 +0100 schrieb Peter Divianszky:
> 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
> 
> update :: Weak r -> r -> x -> x
> update r_old r_new x_old x_new = unsafePerformIO $ do
>      eval x_new
>      b <- x_old === x_new
>      when b (replace r_new r_old)
>      return x_new
(Continue reading)


Gmane