All of lore.kernel.org
 help / color / mirror / Atom feed
* Disabling nagle algorithm
@ 2011-05-29 17:34 C K Kashyap
  2011-05-30  3:48 ` Anupam Kapoor
  0 siblings, 1 reply; 13+ messages in thread
From: C K Kashyap @ 2011-05-29 17:34 UTC (permalink / raw)
  To: kernelnewbies

Hi,
Is setting *net.ipv4.tcp_low_latency to 1 the right way of disabling nagle's
algorithm?*
*Regards,*
*Kashyap*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110529/8d8ac8c9/attachment.html 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-29 17:34 Disabling nagle algorithm C K Kashyap
@ 2011-05-30  3:48 ` Anupam Kapoor
  2011-05-30  3:51   ` C K Kashyap
  0 siblings, 1 reply; 13+ messages in thread
From: Anupam Kapoor @ 2011-05-30  3:48 UTC (permalink / raw)
  To: kernelnewbies

afaik, it disables tcp-prequeue nothing to do with nagle anyways.
also, doing this might have marginal benefits if anything at all due
to most overhead being specific to context switching than anything
else.

anupam

On Sun, May 29, 2011 at 11:04 PM, C K Kashyap <ckkashyap@gmail.com> wrote:
> Hi,
> Is setting?net.ipv4.tcp_low_latency to 1 the right way of disabling nagle's
> algorithm?
> Regards,
> Kashyap
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>



-- 
In the beginning was the lambda, and the lambda was with Emacs, and
Emacs was the lambda.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-30  3:48 ` Anupam Kapoor
@ 2011-05-30  3:51   ` C K Kashyap
  2011-05-30  4:23     ` Anupam Kapoor
  0 siblings, 1 reply; 13+ messages in thread
From: C K Kashyap @ 2011-05-30  3:51 UTC (permalink / raw)
  To: kernelnewbies

On Mon, May 30, 2011 at 9:18 AM, Anupam Kapoor <anupam.kapoor@gmail.com>wrote:

> afaik, it disables tcp-prequeue nothing to do with nagle anyways.
> also, doing this might have marginal benefits if anything at all due
> to most overhead being specific to context switching than anything
> else.
>
> Thanks Anupam ... can you pleast tell me how I could disable nagle's algo?
At a system level. I've seen a lot of info on socket param on the net.

Regards,
Kashyap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110530/8554ee2c/attachment.html 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-30  3:51   ` C K Kashyap
@ 2011-05-30  4:23     ` Anupam Kapoor
  2011-05-30  4:47       ` C K Kashyap
  0 siblings, 1 reply; 13+ messages in thread
From: Anupam Kapoor @ 2011-05-30  4:23 UTC (permalink / raw)
  To: kernelnewbies

is tcp_nodelay not an option ?

anupam

On Mon, May 30, 2011 at 9:21 AM, C K Kashyap <ckkashyap@gmail.com> wrote:
>
>
> On Mon, May 30, 2011 at 9:18 AM, Anupam Kapoor <anupam.kapoor@gmail.com>
> wrote:
>>
>> afaik, it disables tcp-prequeue nothing to do with nagle anyways.
>> also, doing this might have marginal benefits if anything at all due
>> to most overhead being specific to context switching than anything
>> else.
>>
> Thanks Anupam ... can you pleast tell me how I could disable nagle's algo?
> At a system level. I've seen a lot of info on socket param on the net.
> Regards,
> Kashyap



-- 
In the beginning was the lambda, and the lambda was with Emacs, and
Emacs was the lambda.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-30  4:23     ` Anupam Kapoor
@ 2011-05-30  4:47       ` C K Kashyap
  2011-05-30  7:39         ` Peter Teoh
  0 siblings, 1 reply; 13+ messages in thread
From: C K Kashyap @ 2011-05-30  4:47 UTC (permalink / raw)
  To: kernelnewbies

On Mon, May 30, 2011 at 9:53 AM, Anupam Kapoor <anupam.kapoor@gmail.com>wrote:

> is tcp_nodelay not an option ?
>
>
Is this a socket option or is there a system wide setting for tcp_nodelay?


Regards,
Kashyap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110530/796cbff9/attachment.html 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-30  4:47       ` C K Kashyap
@ 2011-05-30  7:39         ` Peter Teoh
  2011-05-30  8:07           ` C K Kashyap
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Teoh @ 2011-05-30  7:39 UTC (permalink / raw)
  To: kernelnewbies

On Mon, May 30, 2011 at 12:47 PM, C K Kashyap <ckkashyap@gmail.com> wrote:
>
>
> On Mon, May 30, 2011 at 9:53 AM, Anupam Kapoor <anupam.kapoor@gmail.com>
> wrote:
>>
>> is tcp_nodelay not an option ?
>>
>
> Is this a socket option or is there a system wide setting for tcp_nodelay?

Yes, TCP_NODELAY is a socket option:

Going back to the kernel source:

include/linux/tcp.h:

#define TCP_NODELAY             1       /* Turn off Nagle's algorithm. */

and this:

       u8      nonagle     : 4,/* Disable Nagle algorithm?             */

and looking into the kernel source code:

./fs/ocfs2/cluster/tcp.c:
	ret = sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY,

./net/rds/tcp.c:
	sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
the above are just two of the examples of how to set TCP_NODELAY in the kernel.

At the userspace level:

http://www.linuxquestions.org/questions/other-*nix-55/how-do-i-disable-the-nagle-algorithm-in-enterprise-linux-3-kernel-ver-2-4-21-4-a-556170/

should be the correct way, except that the poster is attempting to do
it in a kernel that does not support it.

As documented in http://linux.die.net/man/7/tcp, the supported kernel
is 2.5.71 and onwards.

-- 
Regards,
Peter Teoh

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-30  7:39         ` Peter Teoh
@ 2011-05-30  8:07           ` C K Kashyap
  2011-05-30  8:34             ` Peter Teoh
  0 siblings, 1 reply; 13+ messages in thread
From: C K Kashyap @ 2011-05-30  8:07 UTC (permalink / raw)
  To: kernelnewbies

>
> Yes, TCP_NODELAY is a socket option:
>
> Going back to the kernel source:
>
> include/linux/tcp.h:
>
> #define TCP_NODELAY             1       /* Turn off Nagle's algorithm. */
>
> and this:
>
>       u8      nonagle     : 4,/* Disable Nagle algorithm?             */
>
> and looking into the kernel source code:
>
> ./fs/ocfs2/cluster/tcp.c:
>        ret = sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY,
>
> ./net/rds/tcp.c:
>        sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user
> *)&val,
> the above are just two of the examples of how to set TCP_NODELAY in the
> kernel.
>
> At the userspace level:
>
>
> http://www.linuxquestions.org/questions/other-*nix-55/how-do-i-disable-the-nagle-algorithm-in-enterprise-linux-3-kernel-ver-2-4-21-4-a-556170/
>
> should be the correct way, except that the poster is attempting to do
> it in a kernel that does not support it.
>
> As documented in http://linux.die.net/man/7/tcp, the supported kernel
> is 2.5.71 and onwards.
>
>
 Okay ... so, the situation I have at hand is that there is this app I
cannot modify. I'd like to see its performance with nagle disabled. Is this
possible?

While at it, is there a way to see the socket options of the socket
descriptors in a running app?

Regards,
Kashyap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110530/15b44221/attachment.html 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-30  8:07           ` C K Kashyap
@ 2011-05-30  8:34             ` Peter Teoh
  2011-05-30 13:48               ` C K Kashyap
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Teoh @ 2011-05-30  8:34 UTC (permalink / raw)
  To: kernelnewbies

On Mon, May 30, 2011 at 4:07 PM, C K Kashyap <ckkashyap@gmail.com> wrote:
>> Yes, TCP_NODELAY is a socket option:
>>
>> Going back to the kernel source:
>>
>> include/linux/tcp.h:
>>
>> #define TCP_NODELAY ? ? ? ? ? ? 1 ? ? ? /* Turn off Nagle's algorithm. */
>>
>> and this:
>>
>> ? ? ? u8 ? ? ?nonagle ? ? : 4,/* Disable Nagle algorithm? ? ? ? ? ? ? */
>>
>> and looking into the kernel source code:
>>
>> ./fs/ocfs2/cluster/tcp.c:
>> ? ? ? ?ret = sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY,
>>
>> ./net/rds/tcp.c:
>> ? ? ? ?sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user
>> *)&val,
>> the above are just two of the examples of how to set TCP_NODELAY in the
>> kernel.
>>
>> At the userspace level:
>>
>>
>> http://www.linuxquestions.org/questions/other-*nix-55/how-do-i-disable-the-nagle-algorithm-in-enterprise-linux-3-kernel-ver-2-4-21-4-a-556170/
>>
>> should be the correct way, except that the poster is attempting to do
>> it in a kernel that does not support it.
>>
>> As documented in http://linux.die.net/man/7/tcp, the supported kernel
>> is 2.5.71 and onwards.
>>
>
> ?Okay ... so, the situation I have at hand is that there is this app I
> cannot modify. I'd like to see its performance with nagle disabled. Is this
> possible?

as u can see from the above two kernel implementation - each is
implementing the algorithm per-socket level, or connection-level, on
top of TCP, so, yes, u want to do that is possible.   but u will need
to write a kernel module, that implement itself as a netfilter module,
specifically just for the port that your application is using, and
setup socket connection of TCP_NODELAY type.   not sure if it will
work?

> While at it, is there a way to see the socket options of the socket
> descriptors in a running app?
> Regards,

Yes, i think so, just sniff out the network packet, and identify the
correct bit as according to the header:  include/linux/tcp.h:

<snip>
        u16     advmss;         /* Advertised MSS                       */
        u8      frto_counter;   /* Number of new acks after RTO */
        u8      nonagle     : 4,/* Disable Nagle algorithm?             */
                thin_lto    : 1,/* Use linear timeouts for thin streams */
                thin_dupack : 1,/* Fast retransmit on first dupack      */
                unused      : 2;
<snip>

> Kashyap



-- 
Regards,
Peter Teoh

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-30  8:34             ` Peter Teoh
@ 2011-05-30 13:48               ` C K Kashyap
  2011-05-31  0:33                 ` Peter Teoh
  0 siblings, 1 reply; 13+ messages in thread
From: C K Kashyap @ 2011-05-30 13:48 UTC (permalink / raw)
  To: kernelnewbies

>
>
> --
> Regards,
> Peter Teoh
>
>
>

Thank you very much Peter.
Regards,
Kashyap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110530/22aa0222/attachment.html 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-30 13:48               ` C K Kashyap
@ 2011-05-31  0:33                 ` Peter Teoh
  2011-05-31  2:41                   ` Anupam Kapoor
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Teoh @ 2011-05-31  0:33 UTC (permalink / raw)
  To: kernelnewbies

frankly it is not wise to disable nagle, and the solution i proposed
(using netfilter extension) is really too tedious - the added overhead
may slow down the processing, even though disabling nagle aims to
improve latencies.   but modern network card is so fast, that the
bottleneck is not at the network card side, but more likely in the
network gateway, or router side - so u are definitely not going to see
improvement in spite of all the troubles.

-- 
Regards,
Peter Teoh

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-31  0:33                 ` Peter Teoh
@ 2011-05-31  2:41                   ` Anupam Kapoor
  2011-05-31  2:54                     ` Mulyadi Santosa
  2011-06-01  5:31                     ` Anupam Kapoor
  0 siblings, 2 replies; 13+ messages in thread
From: Anupam Kapoor @ 2011-05-31  2:41 UTC (permalink / raw)
  To: kernelnewbies

yup, that's what i also think. is it possible that nagle+delayed-ack
is causing the perceived slow-down ?

anupam

On Tue, May 31, 2011 at 6:03 AM, Peter Teoh <htmldeveloper@gmail.com> wrote:
> frankly it is not wise to disable nagle, and the solution i proposed
> (using netfilter extension) is really too tedious - the added overhead
> may slow down the processing, even though disabling nagle aims to
> improve latencies. ? but modern network card is so fast, that the
> bottleneck is not at the network card side, but more likely in the
> network gateway, or router side - so u are definitely not going to see
> improvement in spite of all the troubles.
>
> --
> Regards,
> Peter Teoh
>



-- 
In the beginning was the lambda, and the lambda was with Emacs, and
Emacs was the lambda.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-31  2:41                   ` Anupam Kapoor
@ 2011-05-31  2:54                     ` Mulyadi Santosa
  2011-06-01  5:31                     ` Anupam Kapoor
  1 sibling, 0 replies; 13+ messages in thread
From: Mulyadi Santosa @ 2011-05-31  2:54 UTC (permalink / raw)
  To: kernelnewbies

On Tue, May 31, 2011 at 09:41, Anupam Kapoor <anupam.kapoor@gmail.com> wrote:
> yup, that's what i also think. is it possible that nagle+delayed-ack
> is causing the perceived slow-down ?

could be, but have you tried to switch and use various congestion
control ? check /proc/sys/net/ipv4/tcp_congestion_control and here are
enabled ones from my distro stock kernel:
$ grep -i cong /boot/config-`uname -r`
CONFIG_TCP_CONG_ADVANCED=y
CONFIG_TCP_CONG_BIC=y
CONFIG_TCP_CONG_CUBIC=y
CONFIG_TCP_CONG_WESTWOOD=m
CONFIG_TCP_CONG_HTCP=m
CONFIG_TCP_CONG_HSTCP=m
CONFIG_TCP_CONG_HYBLA=m
CONFIG_TCP_CONG_VEGAS=m
CONFIG_TCP_CONG_SCALABLE=m
CONFIG_TCP_CONG_LP=m
CONFIG_TCP_CONG_VENO=m
CONFIG_TCP_CONG_YEAH=m
CONFIG_TCP_CONG_ILLINOIS=m
CONFIG_DEFAULT_TCP_CONG="cubic"

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Disabling nagle algorithm
  2011-05-31  2:41                   ` Anupam Kapoor
  2011-05-31  2:54                     ` Mulyadi Santosa
@ 2011-06-01  5:31                     ` Anupam Kapoor
  1 sibling, 0 replies; 13+ messages in thread
From: Anupam Kapoor @ 2011-06-01  5:31 UTC (permalink / raw)
  To: kernelnewbies

yet another option would be to setup point-to-point ethernet device
(^^) via tun/tap drivers. you can have a userland program receiving
data from the said device, and then use whatever options you want
there.

anupam

On Tue, May 31, 2011 at 8:11 AM, Anupam Kapoor <anupam.kapoor@gmail.com> wrote:
> yup, that's what i also think. is it possible that nagle+delayed-ack
> is causing the perceived slow-down ?
>
> anupam
>
> On Tue, May 31, 2011 at 6:03 AM, Peter Teoh <htmldeveloper@gmail.com> wrote:
>> frankly it is not wise to disable nagle, and the solution i proposed
>> (using netfilter extension) is really too tedious - the added overhead
>> may slow down the processing, even though disabling nagle aims to
>> improve latencies. ? but modern network card is so fast, that the
>> bottleneck is not at the network card side, but more likely in the
>> network gateway, or router side - so u are definitely not going to see
>> improvement in spite of all the troubles.
>>
>> --
>> Regards,
>> Peter Teoh
>>
>
>
>
> --
> In the beginning was the lambda, and the lambda was with Emacs, and
> Emacs was the lambda.
>



-- 
In the beginning was the lambda, and the lambda was with Emacs, and
Emacs was the lambda.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2011-06-01  5:31 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-29 17:34 Disabling nagle algorithm C K Kashyap
2011-05-30  3:48 ` Anupam Kapoor
2011-05-30  3:51   ` C K Kashyap
2011-05-30  4:23     ` Anupam Kapoor
2011-05-30  4:47       ` C K Kashyap
2011-05-30  7:39         ` Peter Teoh
2011-05-30  8:07           ` C K Kashyap
2011-05-30  8:34             ` Peter Teoh
2011-05-30 13:48               ` C K Kashyap
2011-05-31  0:33                 ` Peter Teoh
2011-05-31  2:41                   ` Anupam Kapoor
2011-05-31  2:54                     ` Mulyadi Santosa
2011-06-01  5:31                     ` Anupam Kapoor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.