Skip to contentSkip to conversation

nbd/server: Request TCP_NODELAY

PATCH In review Eric Blake 3 participants 3 messages Apr 4, 2023

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH v2 1/1 nbd/server: Request TCP_NODELAY

Nagle's algorithm adds latency in order to reduce network packet overhead on small packets. But when we are already using corking to merge smaller packets into transactional requests, the extra delay from TCP defaults just gets in the way (see recent commit bd2cd4a4).

For reference, qemu as an NBD client already requests TCP_NODELAY (see nbd_connect() in nbd/client-connection.c); as does libnbd as a client [1], and nbdkit as a server [2]. Furthermore, the NBD spec recommends the use of TCP_NODELAY [3].

[1] https://gitlab.com/nbdkit/libnbd/-/blob/a48a1142/generator/states-connect.c#L39
[2] https://gitlab.com/nbdkit/nbdkit/-/blob/45b72f5b/server/sockets.c#L430
[3] https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md#protocol-phases

CC Florian Westphal <[email protected]>

Message-Id: <[email protected]>
---

v2 fix typo, enhance commit message

Given that corking made it in through Kevin's tree for 8.0-rc2 but this one did not, but I didn't get any R-b, is there any objection to me doing a pull request to get this into 8.0-rc3?

 nbd/server.c | 1 +
 1 file changed, 1 insertion(+)
nbd/server.c +1 -0
index 848836d4140..3d8d0d81df2 100644
@@ -2758,6 +2758,7 @@ void nbd_client_new(QIOChannelSocket *sioc,
     }
     client->tlsauthz = g_strdup(tlsauthz);
     client->sioc = sioc;
+    qio_channel_set_delay(QIO_CHANNEL(sioc), false);
     object_ref(OBJECT(client->sioc));
     client->ioc = QIO_CHANNEL(sioc);
     object_ref(OBJECT(client->ioc));

base-commit: efcd0ec14b0fe9ee0ee70277763b2d538d19238d

Signature · 1 line
2.39.2
Reviewed-by on v2 1/1
#1 lore raw
Quoted 16 lines · Eric Blake

Nagle's algorithm adds latency in order to reduce network packet overhead on small packets. But when we are already using corking to merge smaller packets into transactional requests, the extra delay from TCP defaults just gets in the way (see recent commit bd2cd4a4).

For reference, qemu as an NBD client already requests TCP_NODELAY (see nbd_connect() in nbd/client-connection.c); as does libnbd as a client [1], and nbdkit as a server [2]. Furthermore, the NBD spec recommends the use of TCP_NODELAY [3].

[1] https://gitlab.com/nbdkit/libnbd/-/blob/a48a1142/generator/states-connect.c#L39
[2] https://gitlab.com/nbdkit/nbdkit/-/blob/45b72f5b/server/sockets.c#L430
[3] https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md#protocol-phases

CC Florian Westphal <[email protected]>
Quoted 8 lines

Message-Id: <[email protected]>
---

v2 fix typo, enhance commit message

Given that corking made it in through Kevin's tree for 8.0-rc2 but this one did not, but I didn't get any R-b, is there any objection to me doing a pull request to get this into 8.0-rc3?

FWIW, no objection.

Quoted 2 lines
  nbd/server.c | 1 +
  1 file changed, 1 insertion(+)
Acked-by on v2 1/1
#2 lore raw
In reply to Eric Blake
Quoted 41 lines · Eric Blake

Nagle's algorithm adds latency in order to reduce network packet overhead on small packets. But when we are already using corking to merge smaller packets into transactional requests, the extra delay from TCP defaults just gets in the way (see recent commit bd2cd4a4).

For reference, qemu as an NBD client already requests TCP_NODELAY (see nbd_connect() in nbd/client-connection.c); as does libnbd as a client [1], and nbdkit as a server [2]. Furthermore, the NBD spec recommends the use of TCP_NODELAY [3].

[1] https://gitlab.com/nbdkit/libnbd/-/blob/a48a1142/generator/states-connect.c#L39
[2] https://gitlab.com/nbdkit/nbdkit/-/blob/45b72f5b/server/sockets.c#L430
[3] https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md#protocol-phases

CC Florian Westphal <[email protected]>

Message-Id: <[email protected]>
---

v2 fix typo, enhance commit message

Given that corking made it in through Kevin's tree for 8.0-rc2 but this one did not, but I didn't get any R-b, is there any objection to me doing a pull request to get this into 8.0-rc3?

  nbd/server.c | 1 +
  1 file changed, 1 insertion(+)
nbd/server.c +1 -0
index 848836d4140..3d8d0d81df2 100644
@@ -2758,6 +2758,7 @@ void nbd_client_new(QIOChannelSocket *sioc,
      }
      client->tlsauthz = g_strdup(tlsauthz);
      client->sioc = sioc;
+    qio_channel_set_delay(QIO_CHANNEL(sioc), false);
      object_ref(OBJECT(client->sioc));
      client->ioc = QIO_CHANNEL(sioc);
      object_ref(OBJECT(client->ioc));
Quoted 1 line

base-commit: efcd0ec14b0fe9ee0ee70277763b2d538d19238d