<div dir="ltr">Increased cost to send to larger mailboxes is a sort of simple approach to work balancing. The idea is that if mailbox of some process grows, we should (naively) try and skew scheduling in such a way so it gets more processing time to clean up that mailbox. So we increase the cost of sending to it, and this makes senders schedule out faster and wait for their turn longer (as they get shorter time to run). This in theory might make the "busy" process with the large mailbox get more CPU and fix the problem faster.<div><br></div><div>Of course this <b>naive </b>approach won't work if the mailbox grows because the receiver ignores new messages. Such system is sick and must be debugged and code must be modified so that extra messages are flushed (dropped). This is <b>artificial </b>feature, as sending is a very cheap operation.</div><div><br></div><div>Increased cost of receive is another thing, and indeed it depends on how many instructions are executed to scan and find the right message in <b>selective </b>receive.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-03-05 16:11 GMT+01:00 Sasha Fonseca <span dir="ltr"><<a href="mailto:sashaafm@gmail.com" target="_blank">sashaafm@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span style="font-size:14px">I’ve read the following blog post (<a href="http://jlouisramblings.blogspot.pt/2013/01/how-erlang-does-scheduling.html" target="_blank">http://jlouisramblings.<wbr>blogspot.pt/2013/01/how-<wbr>erlang-does-scheduling.html</a>), and it has the following excerpt which got me thinking:</span><div><span style="font-size:14px"><br></span></div><div><span style="color:rgb(51,51,51);font-family:'Helvetica Neue Light',HelveticaNeue-Light,'Helvetica Neue',Helvetica,Arial,sans-serif;text-align:justify;background-color:rgb(255,255,255);font-size:14px"><i>Both processes and ports have a "reduction budget" of 2000 reductions. Any operation in the system costs reductions. This includes function calls in loops, calling built-in-functions (BIFs), garbage collecting heaps of that process[n1], storing/reading from ETS, sending messages (<b>The size of the recipients mailbox counts, large mailboxes are more expensive to send to</b>). </i></span></div><div><span style="color:rgb(51,51,51);font-family:'Helvetica Neue Light',HelveticaNeue-Light,'Helvetica Neue',Helvetica,Arial,sans-serif;text-align:justify;background-color:rgb(255,255,255);font-size:14px"><i><br></i></span></div><div style="text-align:justify"><font color="#333333"><span style="background-color:rgb(255,255,255);font-size:14px">I’m wondering how does the size of a process’s mailbox relates the reduction count? Is it due to each message having to be matched against several message patterns in a case condition, for example? Also how large would the mailbox have to be to noticed any kind of impact in, let’s say, a server process?</span></font></div></div><br>______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>