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

Masklinn masklinn@REDACTED
Thu Feb 23 09:46:25 CET 2012


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).

> Using escape analysis to determine if the whole message should be
> copied or only a reference would require a rewrite of the GC from
> copy-and-collect to something like mark and sweep.

Not sure why.

> And I'm doubtful
> that many cases could be identified where a none of the terms part of
> the data sent would be kept in the process sending the message.

Yes, so am I. It would mostly be useful for small one-off messages, and
because Erlang has no "unique" semantics (à la rust) it wouldn't work
when messages are being sent from a function (which is pretty much
always the case when using OTP).


More information about the erlang-questions mailing list