<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 09/12/2012 04:10 AM, Björn-Egil Dahlberg wrote:<br>
<span style="white-space: pre;">> Hi,<br>
> <br>
> Sharing within a compounded data term is not preserved on
send nor<br>
> in term to binary.<br>
> <br>
> One way to reinstate sharing is to walk through the
compounded term <br>
> and look for sharing (Wind3d uses this trick).<br>
> <br>
> Ex. Ls = <list of items>, {Sh,_} = lists:mapfold(fun(I,
T) -> case<br>
> gb_trees:lookup(I,T) of none -> {I,
gb_trees:enter(I,I,T)}; {value,<br>
> V} -> {V, T} end end, gb_trees:empty(), Ls), Sh.<br>
> <br>
> (disclaimer: I am writing code when sleepy and I always
forget the <br>
> mapfold syntax. But you get the idea.)<br>
> <br>
> This approach requires some knowledge about the structure of
the<br>
> data to be reshared. It will also temporary increase the
total memory<br>
> while performing the resharing.<br>
> <br>
> I'm sure there are other, perhaps much better, approaches as
well to <br>
> this problem.<br>
> <br>
> There exists several proposals on preserved sharing on send,
but<br>
> none are currently implemented in the vm.<br>
> <br>
> // Björn-Egil<br>
> <br>
> Skickat från min iPad<br>
> <br>
> 11 sep 2012 kl. 23:45 skrev Roland<br>
> <a class="moz-txt-link-rfc2396E" href="mailto:roland.koelbel@student.tuwien.ac.at"><roland.koelbel@student.tuwien.ac.at></a>:<br>
> <br>
>> Hello!<br>
>> <br>
>> I want to move the state of my process to another
process.<br>
>> Unfortunately this is not possible without a huge
increase in<br>
>> memory consumption as by copying the state the "copy on
write<br>
>> semantics" are lost.<br>
>> <br>
>> This behaviour is demonstrated in my attached simplified
t_process<br>
>> module.<br>
>> <br>
>> -> {ok, Pid} = t_process:start_link(). ->
t_process:bloat(Pid). --><br>
>> memory consumption of the process is at 6657256 after
"bloat" is<br>
>> finished -> t_process:reload_bag(P1). --> memory
consumption is at<br>
>> 26295176 (4 times as much)<br>
>> <br>
>> No data has not been modified in any way, the data stays
the same.<br>
>> <br>
>> My question is: Despite what i want to do with this state
transfer,<br>
>> is there any way to copy the state of a process without
losing the<br>
>> "copy on write semantics", so that the target process has
the same<br>
>> memory footprint as the original one?<br>
>> <br>
>> Can someone point me to any direction/documentation on
how i can<br>
>> get arround this issue?</span><br>
Hi,<br>
<br>
Actually that's funny because there is some work [1] by Nikos
Papaspyrou and Kostis Sagonas that will be presented on Friday the
14th on the Erlang Workshop in Copenhagen! It's an (experimental)
implementation of a copy that preserves sharing...<br>
<br>
Maybe you could take a look at the code in that repo. :-)<br>
<br>
<br>
Best regards,<br>
Yiannis<br>
<br>
[1]: <a class="moz-txt-link-freetext" href="https://github.com/nickie/otp">https://github.com/nickie/otp</a><br>
<br>
-- <br>
Yiannis Tsiouris<br>
Ph.D. student,<br>
Software Engineering Laboratory,<br>
National Technical University of Athens<br>
WWW: <a class="moz-txt-link-freetext" href="http://www.softlab.ntua.gr/~gtsiour">http://www.softlab.ntua.gr/~gtsiour</a><br>
<br>
</body>
</html>