diff mbox series

slirp: disable Nagle in outgoing connections

Message ID 23118.27370.136663.284087@guava.gson.org
State New
Headers show
Series slirp: disable Nagle in outgoing connections | expand

Commit Message

Andreas Gustafsson Jan. 4, 2018, 5:56 p.m. UTC
slirp: disable Nagle in outgoing connections

When setting up an outgoing user mode networking TCP connection,
disable the Nagle algorithm in the host-side connection.  Either the
guest is already doing Nagle, in which case there is no point in doing
it twice, or it has chosen to disable it, in which case we should
respect that choice.

This change speeds up GDB remote debugging over TCP over user mode
networking (with GDB runing on the guest) by multiple orders of
magnitude, and has been part of the local patches applied by pkgsrc
since 2012 with no reported ill effects.

Signed-off-by: Andreas Gustafsson <gson@gson.org>
---
 slirp/tcp_subr.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Kamil Rytarowski March 7, 2018, 9:13 a.m. UTC | #1
This patch is correct. LLDB expects 1sec for reply, GDB by default 2.

Debuggers use this option to disable Nagle algorithm in order to quickly
transfer messages between gdb-server and gdb-client. It's also fairy
portable across systems.

On 04.01.2018 18:56, Andreas Gustafsson wrote:
> slirp: disable Nagle in outgoing connections
> 
> When setting up an outgoing user mode networking TCP connection,
> disable the Nagle algorithm in the host-side connection.  Either the
> guest is already doing Nagle, in which case there is no point in doing
> it twice, or it has chosen to disable it, in which case we should
> respect that choice.
> 
> This change speeds up GDB remote debugging over TCP over user mode
> networking (with GDB runing on the guest) by multiple orders of
> magnitude, and has been part of the local patches applied by pkgsrc
> since 2012 with no reported ill effects.
> 
> Signed-off-by: Andreas Gustafsson <gson@gson.org>

Signed-off-by: Kamil Rytarowski <n54@gmx.com>

> ---
>  slirp/tcp_subr.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
> index da0d53743f..8d0f94b75f 100644
> --- a/slirp/tcp_subr.c
> +++ b/slirp/tcp_subr.c
> @@ -416,6 +416,8 @@ int tcp_fconnect(struct socket *so, unsigned short af)
>      socket_set_fast_reuse(s);
>      opt = 1;
>      qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt));
> +    opt = 1;
> +    qemu_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt));
>  
>      addr = so->fhost.ss;
>      DEBUG_CALL(" connect()ing")
>
Philippe Mathieu-Daudé March 7, 2018, 9:38 a.m. UTC | #2
On 03/07/2018 06:13 AM, Kamil Rytarowski wrote:
> This patch is correct. LLDB expects 1sec for reply, GDB by default 2.
> 
> Debuggers use this option to disable Nagle algorithm in order to quickly
> transfer messages between gdb-server and gdb-client. It's also fairy
> portable across systems.
> 
> On 04.01.2018 18:56, Andreas Gustafsson wrote:
>> slirp: disable Nagle in outgoing connections
>>
>> When setting up an outgoing user mode networking TCP connection,
>> disable the Nagle algorithm in the host-side connection.  Either the
>> guest is already doing Nagle, in which case there is no point in doing
>> it twice, or it has chosen to disable it, in which case we should
>> respect that choice.
>>
>> This change speeds up GDB remote debugging over TCP over user mode
>> networking (with GDB runing on the guest) by multiple orders of
>> magnitude, and has been part of the local patches applied by pkgsrc
>> since 2012 with no reported ill effects.
>>
>> Signed-off-by: Andreas Gustafsson <gson@gson.org>
> 
> Signed-off-by: Kamil Rytarowski <n54@gmx.com>

I suppose you meant "Reviewed-by: Kamil Rytarowski <n54@gmx.com>"

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> 
>> ---
>>  slirp/tcp_subr.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
>> index da0d53743f..8d0f94b75f 100644
>> --- a/slirp/tcp_subr.c
>> +++ b/slirp/tcp_subr.c
>> @@ -416,6 +416,8 @@ int tcp_fconnect(struct socket *so, unsigned short af)
>>      socket_set_fast_reuse(s);
>>      opt = 1;
>>      qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt));
>> +    opt = 1;
>> +    qemu_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt));
>>  
>>      addr = so->fhost.ss;
>>      DEBUG_CALL(" connect()ing")
>>
> 
>
Kamil Rytarowski March 7, 2018, 9:42 a.m. UTC | #3
On 07.03.2018 10:38, Philippe Mathieu-Daudé wrote:
> On 03/07/2018 06:13 AM, Kamil Rytarowski wrote:
>> This patch is correct. LLDB expects 1sec for reply, GDB by default 2.
>>
>> Debuggers use this option to disable Nagle algorithm in order to quickly
>> transfer messages between gdb-server and gdb-client. It's also fairy
>> portable across systems.
>>
>> On 04.01.2018 18:56, Andreas Gustafsson wrote:
>>> slirp: disable Nagle in outgoing connections
>>>
>>> When setting up an outgoing user mode networking TCP connection,
>>> disable the Nagle algorithm in the host-side connection.  Either the
>>> guest is already doing Nagle, in which case there is no point in doing
>>> it twice, or it has chosen to disable it, in which case we should
>>> respect that choice.
>>>
>>> This change speeds up GDB remote debugging over TCP over user mode
>>> networking (with GDB runing on the guest) by multiple orders of
>>> magnitude, and has been part of the local patches applied by pkgsrc
>>> since 2012 with no reported ill effects.
>>>
>>> Signed-off-by: Andreas Gustafsson <gson@gson.org>
>>
>> Signed-off-by: Kamil Rytarowski <n54@gmx.com>
> 
> I suppose you meant "Reviewed-by: Kamil Rytarowski <n54@gmx.com>"
> 

Correct!

> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
Samuel Thibault March 7, 2018, 10:34 p.m. UTC | #4
Hello,

Thanks for the Cc.

I have applied it to my tree.  I don't think there is any reason to
avoid the same change for ingoing connections?  Could one of your review
the attached patch doing it?

Samuel
commit 99a9a5028e0e15aa3b17d6f884c1e5f48dccea90
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Wed Mar 7 23:29:41 2018 +0100

    slirp: disable Nagle in ingoing connections
    
    This follows 3929766fb3e4 ('slirp: disable Nagle in outgoing connections'):
    for the same reasons, ingoing connections should have the Nagle algorithm disabled.
    
    Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

diff --git a/slirp/socket.c b/slirp/socket.c
index cb7b5b608d..81f67b5702 100644
--- a/slirp/socket.c
+++ b/slirp/socket.c
@@ -754,6 +754,8 @@ tcp_listen(Slirp *slirp, uint32_t haddr, u_int hport, uint32_t laddr,
 		return NULL;
 	}
 	qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(int));
+	opt = 1;
+	qemu_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(int));
 
 	getsockname(s,(struct sockaddr *)&addr,&addrlen);
 	so->so_ffamily = AF_INET;
Philippe Mathieu-Daudé March 7, 2018, 10:57 p.m. UTC | #5
On 03/07/2018 07:34 PM, Samuel Thibault wrote:
> Hello,
> 
> Thanks for the Cc.
> 
> I have applied it to my tree.  I don't think there is any reason to
> avoid the same change for ingoing connections?  Could one of your review
> the attached patch doing it?

attached patch:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> 
> Samuel
>
Samuel Thibault March 7, 2018, 11:06 p.m. UTC | #6
Philippe Mathieu-Daudé, on mer. 07 mars 2018 19:57:28 -0300, wrote:
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Thanks!
diff mbox series

Patch

diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index da0d53743f..8d0f94b75f 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -416,6 +416,8 @@  int tcp_fconnect(struct socket *so, unsigned short af)
     socket_set_fast_reuse(s);
     opt = 1;
     qemu_setsockopt(s, SOL_SOCKET, SO_OOBINLINE, &opt, sizeof(opt));
+    opt = 1;
+    qemu_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof(opt));
 
     addr = so->fhost.ss;
     DEBUG_CALL(" connect()ing")