<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><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">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>> 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},{recbuf,2*1024*1024},inet,{read_packets,100},{active,500}],</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,{read_packets,100},{active,500}],</font></div><div><font face="monospace, monospace"> Multicast = [{multicast_ttl,4},{multicast_loop,true},{ip,Addr},{add_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>-- <br><div dir="ltr" class="gmail_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>