Sending messages to non-existing process

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Sending messages to non-existing process

Frank Muller
Hey guys

Is there any side effect of sending an infinite stream of messages to a non-existing process registered by name?

Ex.
1> Term = ….
2> register(foo, self()).
3> 1 / 0.
4> [ foo ! Term || _ <- lists:eq(1. <a href="tel:10000000000000" dir="ltr">10000000000000) ].

I’m curious about how the VM handles this scenario internally:

1. messages are simply discarded? And if this the case, will this hurt the VM’s performances?
2. something else???

Finally, what will happen if during the sending, a process get registered with name 'foo' ? 

Thanks in advance
/Frank

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Sending messages to non-existing process

Dmytro Lytovchenko
1. A lookup of the process is performed in the dictionary of all pids.
2. Having null result, the message is dropped (and remains in sender's heap until the next garbage collection)

There should be no side effect other than the cost of locking/unlocking processes dict for that lookup.
Sudden process registration should from that moment have all messages copied into the receiving heap, one copy per send, creating 100000000 copies on the receiver heap.


On Fri, 25 Jan 2019 at 15:50, Frank Muller <[hidden email]> wrote:
Hey guys

Is there any side effect of sending an infinite stream of messages to a non-existing process registered by name?

Ex.
1> Term = ….
2> register(foo, self()).
3> 1 / 0.
4> [ foo ! Term || _ <- lists:eq(1. <a href="tel:10000000000000" dir="ltr" target="_blank">10000000000000) ].

I’m curious about how the VM handles this scenario internally:

1. messages are simply discarded? And if this the case, will this hurt the VM’s performances?
2. something else???

Finally, what will happen if during the sending, a process get registered with name 'foo' ? 

Thanks in advance
/Frank
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Sending messages to non-existing process

Frank Muller
Hey Dmytro

So no matter if receiving process exists or not, those 100000000 messages have to be copied on the sender’s heap until next garbage collection is performed? Did I get it correctly?

/Frank

1. A lookup of the process is performed in the dictionary of all pids.
2. Having null result, the message is dropped (and remains in sender's heap until the next garbage collection)

There should be no side effect other than the cost of locking/unlocking processes dict for that lookup.
Sudden process registration should from that moment have all messages copied into the receiving heap, one copy per send, creating 100000000 copies on the receiver heap.


On Fri, 25 Jan 2019 at 15:50, Frank Muller <[hidden email]> wrote:
Hey guys

Is there any side effect of sending an infinite stream of messages to a non-existing process registered by name?

Ex.
1> Term = ….
2> register(foo, self()).
3> 1 / 0.
4> [ foo ! Term || _ <- lists:eq(1. <a href="tel:10000000000000" dir="ltr" target="_blank">10000000000000) ].

I’m curious about how the VM handles this scenario internally:

1. messages are simply discarded? And if this the case, will this hurt the VM’s performances?
2. something else???

Finally, what will happen if during the sending, a process get registered with name 'foo' ? 

Thanks in advance
/Frank
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Sending messages to non-existing process

Dmytro Lytovchenko
You already have it on the senders heap created in the line above.
If receiver exists at any point, there will be a copy to receivers heap.
If receiver never existed, then no new copies will be made.

On Fri, 25 Jan 2019 at 16:19, Frank Muller <[hidden email]> wrote:
Hey Dmytro

So no matter if receiving process exists or not, those 100000000 messages have to be copied on the sender’s heap until next garbage collection is performed? Did I get it correctly?

/Frank

1. A lookup of the process is performed in the dictionary of all pids.
2. Having null result, the message is dropped (and remains in sender's heap until the next garbage collection)

There should be no side effect other than the cost of locking/unlocking processes dict for that lookup.
Sudden process registration should from that moment have all messages copied into the receiving heap, one copy per send, creating 100000000 copies on the receiver heap.


On Fri, 25 Jan 2019 at 15:50, Frank Muller <[hidden email]> wrote:
Hey guys

Is there any side effect of sending an infinite stream of messages to a non-existing process registered by name?

Ex.
1> Term = ….
2> register(foo, self()).
3> 1 / 0.
4> [ foo ! Term || _ <- lists:eq(1. <a href="tel:10000000000000" dir="ltr" target="_blank">10000000000000) ].

I’m curious about how the VM handles this scenario internally:

1. messages are simply discarded? And if this the case, will this hurt the VM’s performances?
2. something else???

Finally, what will happen if during the sending, a process get registered with name 'foo' ? 

Thanks in advance
/Frank
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Sending messages to non-existing process

Frank Muller
Thank you for the clarification.

/Frank

You already have it on the senders heap created in the line above.
If receiver exists at any point, there will be a copy to receivers heap.
If receiver never existed, then no new copies will be made.

On Fri, 25 Jan 2019 at 16:19, Frank Muller <[hidden email]> wrote:
Hey Dmytro

So no matter if receiving process exists or not, those 100000000 messages have to be copied on the sender’s heap until next garbage collection is performed? Did I get it correctly?

/Frank

1. A lookup of the process is performed in the dictionary of all pids.
2. Having null result, the message is dropped (and remains in sender's heap until the next garbage collection)

There should be no side effect other than the cost of locking/unlocking processes dict for that lookup.
Sudden process registration should from that moment have all messages copied into the receiving heap, one copy per send, creating 100000000 copies on the receiver heap.


On Fri, 25 Jan 2019 at 15:50, Frank Muller <[hidden email]> wrote:
Hey guys

Is there any side effect of sending an infinite stream of messages to a non-existing process registered by name?

Ex.
1> Term = ….
2> register(foo, self()).
3> 1 / 0.
4> [ foo ! Term || _ <- lists:eq(1. <a href="tel:10000000000000" dir="ltr" target="_blank">10000000000000) ].

I’m curious about how the VM handles this scenario internally:

1. messages are simply discarded? And if this the case, will this hurt the VM’s performances?
2. something else???

Finally, what will happen if during the sending, a process get registered with name 'foo' ? 

Thanks in advance
/Frank
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions