[erlang-questions] Question about Erlang's term serialization for message passing

Bjorn Gustavsson bjorn@REDACTED
Wed Mar 7 07:26:50 CET 2007


Christoph Dornheim <cd5@REDACTED> writes:

> Hi,
> 
> when experimenting with distributed message passing and the external term format
> transformation with term_to_binary, I wonder if the internal encoding used for
> passing Erlang terms to local or remote processes is a representation of their
> in-memory pointer structure (similar to Java's serialization of object graphs)
> or if it is value-oriented like the external term format.

They are value oriented-oriented in both cases.

For local message sending, the term in its internal format will simply
be copied to the other process.

The external term format is used when sending messages to an Erlang process
on another node. (But compared to term_to_binary/1, there is an atom cache used,
to speed up sending and receiving of atoms.)

> I guess the former is true since otherwise message passing would lead to
> problems such that data possibly needs more memory space in the receiving
> process than in the sending one (think of sending [L,L] for L=[1,2,3] from
> process P1 to P2: if something like term_to_binary is used for encoding the
> received term needs the same space as [L,[1,2,3]] would have been sent).

Such terms will indeed grow when sent to another process.

> 
> Is there any documentation about Erlang's data serialization method?
> Any hints are welcome.

The external term format is documented in

  erts/emulator/internal_doc/erl_ext_dist.txt

in the source distribution.

/Bjorn

-- 
Björn Gustavsson, Erlang/OTP, Ericsson AB




More information about the erlang-questions mailing list