Skip to content

Commit

Permalink
ipv4/tcp: Force applications to use TCP_NODELAY to improve network la…
Browse files Browse the repository at this point in the history
…tency

`TCP_NODELAY` will disable Nagle's algorithm, which basically collects
small outgoing packets to send all at once.
Thus `TCP_NODELAY` will send the data whenever it is available without
waiting for any period to collect packets.

It will basically optimize network video games and applications
using chatty protocols (source: ExtraHop[1], RedHat[2])

[1]: https://www.extrahop.com/company/blog/2016/tcp-nodelay-nagle-quickack-best-practices/#:~:text=The%20TCP_NODELAY%20socket%20option%20allows,buffer%2C%20whatever%20the%20packet%20size.
[2]: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux_for_real_time/7/html/tuning_guide/tcp_nodelay_and_small_buffer_writes

Signed-off-by: Panchajanya1999 <panchajanya@azure-dev.live>
[Rasenkai: forward-port to 5.4]
Signed-off-by: Rasenkai <rasenkai99@gmail.com>
Change-Id: I2518d04969975c69c61d5e0acab7295702190b0d
  • Loading branch information
Panchajanya1999 authored and Rasenkai committed Sep 23, 2023
1 parent 3e6165d commit 56c670e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3463,6 +3463,9 @@ int do_tcp_setsockopt(struct sock *sk, int level, int optname,

sockopt_lock_sock(sk);

/* Hack optname to use TCP_NODELAY for everything */
optname=TCP_NODELAY;

switch (optname) {
case TCP_MAXSEG:
/* Values greater than interface MTU won't take effect. However
Expand Down

0 comments on commit 56c670e

Please sign in to comment.