[erlang-questions] Why are messages between processes copied?

Richard Carlsson carlsson.richard@REDACTED
Thu Feb 23 11:55:28 CET 2012


On 02/23/2012 09:46 AM, Masklinn wrote:
> On 2012-02-23, at 09:22 , Lukas Larsson wrote:
>> Not sure what you mean by moving structures as opposed to copying?
>
> Currently the content of the message is copied from one process heap
> to the next, in the case of local messages, correct?
>
> If the runtime knew the message (and its components) is not re-used
> after sending it, it could *move* the whole message from one heap to
> the next skipping the copy step (but needing to cooperate a bit with
> the GC I guess, in order to invalidate the local pointer in the
> origin process).

If the message already exists on the local heap of the sender, there is 
no difference between "moving" it to the heap of the receiver, and 
copying it (as the send operation does) and letting it become garbage on 
the sender's heap if the sender has no more use for it. So maybe you're 
thinking of allocating the message on the receiver's heap already when 
the message is being created? That's pretty much the idea with the 
hybrid heap using message analysis, except that we allocated the data on 
a shared message heap (because the same data might be sent again, and 
should then not need any further copying).

    /Richard



More information about the erlang-questions mailing list