<div dir="ltr">
<div>Does this bug only affect multicast UDP or also normal UDP?</div><div><br></div><div>What values should I use for buffer and recbuf in a UDP socket receiving 1Mbps with 1500 Bytes MTU?</div><div>I thought I need N*MTU recbuf so the pid will be able to handle a small burst of UDP packets.</div><div>This is what I currently have:<br></div><div>gen_udp:open(0, [binary, {active, once}, {recbuf, 16*1024}])</div>

<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 22, 2018 at 4:07 AM, Michael Stellar <span dir="ltr"><<a href="mailto:unexplained@gmail.com" target="_blank">unexplained@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Looks good, does these patch already being committed upstream?</div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 21, 2018 at 8:56 PM Danil Zagoskin <<a href="mailto:z@gosk.in" target="_blank">z@gosk.in</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hmm, seems like the value should be very close to expected size.<div>Setting buffer to 2048 did not change anything <span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">significantly</span>.</div><div>The results in my previous message are with {buffer, 2048} option left from earlier experiments.</div></div><div><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Wed, Jun 20, 2018 at 8:06 PM Lukas Larsson <<a href="mailto:lukas@erlang.org" target="_blank">lukas@erlang.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Jun 20, 2018 at 1:56 PM Jonas Falkevik <<a href="mailto:jonas.falkevik@mobilearts.com" target="_blank">jonas.falkevik@mobilearts.com</a><wbr>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><div>Are you adding the multicast network to the loop back interface? Using some other interface that does not allow multicast traffic?</div></div></div><div class="gmail_extra"><br></div></div></blockquote><div><br></div><div>I though I had, but apparently not.... I managed to reproduce the test case now.</div><div><br></div><div>I also spent some time staring at the code in the inet_driver and realized what the problem was in there. It would seem that a performance/feature fix for SCTP in R15B inadvertently introduced this behaviour for UDP :( I've pushed a bug fix to that problem in the inet_driver to the same branch. In my tests the scheduler utilization goes form 71% to about 4% with both patches. With the fix in the inet driver, my allocator patch does not really do any difference for this specific testcase, but I'll keep that fix anyways as it is a "good thing". I should probably also add a benchmark for this so that it does not happen again....</div><div><br></div><div>I'd also like to add that changing the test-case to use a smaller user-space buffer also has the same effect. So if anyone is running a performance critical UDP server that has set the "recbuf" to a high value, I really recommend that you lower the "buffer" size to something close to the max expected packet size. In the example that Danil provided I applied the following patch:</div><div><br></div><div><div><font face="monospace, monospace">diff --git a/udptest.erl b/udptest.erl</font></div><div><font face="monospace, monospace">index 16a1798..4edeef0 100644</font></div><div><font face="monospace, monospace">--- a/udptest.erl</font></div><div><font face="monospace, monospace">+++ b/udptest.erl</font></div><div><font face="monospace, monospace">@@ -33,7 +33,9 @@ send_packet(ID, S, Addr, Port) -></font></div><div><font face="monospace, monospace"> </font></div><div><font face="monospace, monospace"> start_reader(Addr, Port) -></font></div><div><font face="monospace, monospace">   GwIP = {0,0,0,0}, % {127,0,0,1},</font></div><div><font face="monospace, monospace">-  Common = [binary,{reuseaddr,true},{<wbr>recbuf,2*1024*1024},inet,{<wbr>read_packets,100},{active,500}<wbr>],</font></div><div><font face="monospace, monospace">+  Common = [binary,{reuseaddr,true},</font></div><div><font face="monospace, monospace">+            {buffer,1500}, %% 1500 is just an example value, don't just copy this. You need to know what you max UDP packet size will be.</font></div><div><font face="monospace, monospace">+            {recbuf,2*1024*1024},inet,{<wbr>read_packets,100},{active,500}<wbr>],</font></div><div><font face="monospace, monospace">   Multicast = [{multicast_ttl,4},{multicast_<wbr>loop,true},{ip,Addr},{add_<wbr>membership,{Addr,GwIP}}],</font></div><div><font face="monospace, monospace">   Options = Common ++ Multicast,</font></div><div><font face="monospace, monospace">   spawn(fun() -> run_reader(Port, Options) end).</font></div></div><div><br></div><div>and the scheduler utilization dropped to about 4% there as well.</div><div><br></div><div>Lukas</div><div><br></div></div></div>
</blockquote></div><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div dir="ltr" class="m_-5683844442533299740m_5987953380111566319gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><font face="'courier new', monospace">Danil Zagoskin | <a href="mailto:z@gosk.in" target="_blank">z@gosk.in</a></font></div></div></div></font></span><span class="">
______________________________<wbr>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">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>
</span></blockquote></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>