<story><title>It&apos;s always TCP_NODELAY</title><url>https://brooker.co.za/blog/2024/05/09/nagle.html</url></story><parent_chain><item><author>ironman1478</author><text>I&amp;#x27;ve fixed multiple latency issues due to nagle&amp;#x27;s multiple times in my career. It&amp;#x27;s the first thing I jump to. I feel like the logic behind it is sound, but it just doesn&amp;#x27;t work for some workloads. It should be something that an engineer needs to be forced to set while creating a socket, instead of letting the OS choose a default. I think that&amp;#x27;s the main issue. Not that it&amp;#x27;s a good &amp;#x2F; bad option but that there is a setting that people might not know about that manipulates how data is sent over the wire so aggressively.</text></item></parent_chain><comment><author>nh2</author><text>Same here. I have a hobby that on any RPC framework I encounter, I file a Github issue &amp;quot;did you think of TCP_NODELAY or can this framework do only 20 calls per second?&amp;quot;.&lt;p&gt;So far, it&amp;#x27;s found a bug every single time.&lt;p&gt;Some examples: &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;cloud-haskell.atlassian.net&amp;#x2F;browse&amp;#x2F;DP-108&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;cloud-haskell.atlassian.net&amp;#x2F;browse&amp;#x2F;DP-108&lt;/a&gt; or &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;agentm&amp;#x2F;curryer&amp;#x2F;issues&amp;#x2F;3&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;agentm&amp;#x2F;curryer&amp;#x2F;issues&amp;#x2F;3&lt;/a&gt;&lt;p&gt;I disagree on the &amp;quot;not a good &amp;#x2F; bad option&amp;quot; though.&lt;p&gt;It&amp;#x27;s a kernel-side heuristic for &amp;quot;magically fixing&amp;quot; badly behaved applications.&lt;p&gt;As the article states, no sensible application does 1-byte network write() syscalls. Software that does that should be fixed.&lt;p&gt;It makes sense only in the case when you are the kernel sysadmin and somehow cannot fix the software that runs on the machine, maybe for team-political reasons. I claim that&amp;#x27;s pretty rare.&lt;p&gt;For all other cases, it makes sane software extra complicated: You need to explicitly opt-out of odd magic that makes poorly-written software have slightly more throughput, and that makes correctly-written software have huge, surprising latency.&lt;p&gt;John Nagle says here and in linked threads that Delayed Acks are even worse. I agree. But the Send&amp;#x2F;Send&amp;#x2F;Receive receive pattern that Nagle&amp;#x27;s Algorithm degrades is a totally valid and common use case, including anything that does pipelined RPC over TCP.&lt;p&gt;Both Delayed Acks and Nagle&amp;#x27;s Algorithm should be opt-in, in my opinion. It should be called TCP_DELAY, which you can opt-into if you can&amp;#x27;t be asked to implement basic userspace buffering.&lt;p&gt;People shouldn&amp;#x27;t &amp;#x2F;need&amp;#x2F; to know about these. Make the default case be the unsurprising one.</text></comment>
<story><title>It&apos;s always TCP_NODELAY</title><url>https://brooker.co.za/blog/2024/05/09/nagle.html</url></story><parent_chain><item><author>ironman1478</author><text>I&amp;#x27;ve fixed multiple latency issues due to nagle&amp;#x27;s multiple times in my career. It&amp;#x27;s the first thing I jump to. I feel like the logic behind it is sound, but it just doesn&amp;#x27;t work for some workloads. It should be something that an engineer needs to be forced to set while creating a socket, instead of letting the OS choose a default. I think that&amp;#x27;s the main issue. Not that it&amp;#x27;s a good &amp;#x2F; bad option but that there is a setting that people might not know about that manipulates how data is sent over the wire so aggressively.</text></item></parent_chain><comment><author>Sebb767</author><text>&amp;gt; It should be something that an engineer needs to be forced to set while creating a socket, instead of letting the OS choose a default.&lt;p&gt;If the intention is mostly to fix applications with bad `write`-behavior, this would make setting TCP_DELAY a pretty exotic option - you would need a software engineer to be both smart enough to know to set this option, but not smart enough to distribute their write-calls well and&amp;#x2F;or not go for writing their own (probably better fitted) application-specific version of Nagles.</text></comment>