<div dir="ltr">Regarding this suggestion in docs, I had some funny times because I blindly applied this suggestion on an application with large amount of not very active sockets.<div><br></div><div>On my machine default settings for kernel buffers were</div><div>[{sndbuf,87040},{recbuf,372480}]</div><div><br></div><div>So, I ended up having 360kb userspace buffer per socket and I had like 10s of thousands of sockets.</div><div><br></div><div>And that was very difficult to track down (`erlang:memory()` showed a lots of `binary` memory, while sum of sizes of binaries referenced by processes (via `process_info(P, binary)`) was 2 orders of magnitude smaller).</div><div>I found the root cause only intuitively and I still don't know if there are any tool that is able to point me to a right direction. Even `[erlang:port_info(Port, memory) || Port <- erlang:ports()]` didn't show this memory.</div><div>I also had prometheus BEAM allocators dashboard like this oneĀ <a href="https://github.com/deadtrickster/beam-dashboards/blob/master/BEAM-memory_allocators.png">https://github.com/deadtrickster/beam-dashboards/blob/master/BEAM-memory_allocators.png</a> and it showed me 90% allocator utilization. So, nothing looked suspicious except just extremely high memory usage.<br><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">> On Wed, Jun 20, 2018 at 12:07 PM Lukas Larsson <</span><a href="mailto:lukas@erlang.org" style="color:rgb(17,85,204);font-size:12.8px;background-color:rgb(255,255,255)">lukas@erlang.org</a><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">> wrote:<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">><br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">>> So if anyone is running a performance critical UDP server that has set<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">>> the "recbuf" to a high value, I really recommend that you lower the<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">>> "buffer" size to something close to the max expected packet size.<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">>><br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">><br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">> That's interesting because the official documentation says:<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">><br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">> "It is recommended to have val(buffer) >= max(val(sndbuf),val(recbuf)) to<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">> avoid performance issues because of unnecessary copying."<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">><br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">><br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">> Maybe the documentation is wrong because that doesn't make much sense;<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">> sndbuf and recbuf are sent to the kernel and are supposed to be bigger than<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">> the user's buffer.<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">></span><br style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">I think that part of the documentation is mainly written with TCP in mind,<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">not UDP. Also, following the docs works fine if it weren't for the bug<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">uncovered in this mail thread. I'll see what I can do about making the docs<br></span><span style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">better.</span></blockquote></div></div>