[erlang-questions] data sharing is outside the semantics of Erlang, but it sure is useful
Tue Sep 15 12:12:57 CEST 2009
Ulf Wiger writes:
> Mikael Pettersson wrote:
> > Erlang's default memory model doesn't allow same-node processes to
> > share memory(*), so you will lose sharing in message sends.
> Yes, but there are two levels of sharing here.
> 1. The sharing of terms across processes, as with large binaries
> 2. The relative sharing within the term itself.
> The latter could be preserved using a sharing-preserving copy.
> As this is invariably more expensive than the current copying
> algorithm when there is no sharing to preserve (likely a very
> common case), it is reasonable that this isn't the default.
> The problem today is that you cannot make a sharing-preserving
> copy between processes at the Erlang level even if your life
> depended on it, and in some cases, this may indeed be the case,
> figuratively speaking. Some data structures simply cannot be
> passed in a message or in a spawn, since the loss of sharing
> leads to a memory explosion.
So a sharing-preserving term_to_binary might fix the worst
problems, even if it requires some non-default option and
requires users to explicitly wrap and unwrap parts of messages?
Just trying to see if this is something worth pursuing or not.
More information about the erlang-questions