Search code examples
concurrencyerlangdistributed-computingpid

Erlang - How is the creation integer (a part of a distributed pid representation ) actually created?


In a distributed Erlang system pids can have two different representations: i) internal; ii) external.
The internal representation has the following shape: < A.B.C >

The external representation, used for instance when a message has to travel across different nodes, is instead composed of the following elements: < node_id, ID, serial, creation > according to the official documentation.
Where node_id is the name of the node, ID and serial identify the process on node_id and creation is an integer used to distinguish the node from past (crashed) version of itself.

What I could not find is how the creation integer is created by the VM.

By setting a small experiment on my PC, I have seen that if I create and kill the same node several times the counter is always increased by 1, and by creating the same node on different machines, the creation integers are different, but have some similarities in their structure, for instance:

machine 1 -> creation integer = 1647595383   
machine 2 -> creation integer = 1647596018 

Do any of you have any knowledge about how this integer is created? If so could you please explain it to me and possibly reference some (more or less) official documentation?


Solution

  • The creation is sent as a part of the response to node registration in epmd, see details on that protocol.

    If you have a custom erl_epmd module, you can also provide your own way of creating the creation-value.

    The original creation is the local time of when the node with that name is first registered, and then it is bumped once for each time the name is re-registered.