]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: client/server: Enable the TCP_NODELAY option for all connections.
authorStephan Bosch <stephan@dovecot.fi>
Thu, 16 Jun 2016 20:02:08 +0000 (22:02 +0200)
committerStephan Bosch <stephan@dovecot.fi>
Thu, 16 Jun 2016 20:07:27 +0000 (22:07 +0200)
This disables the TCP Nagle algorithm. With the Nagle algorithm enabled, TCP waits a little to accumulate more data in a small segment before it is sent. For transfer of large continuous payloads, this is not useful and even harmful.
If the final remaining bit of the payload is small, the TCP layer will wait for a significant amount of time at the end of the payload. For many sequential transfers, this amounts to much waiting time.
This is particularly evident in the test-http-payload test suite tool. Setting TCP_NODELAY decreases its run time from up to 20 minutes to about half a minute my system.

src/lib-http/http-client-connection.c
src/lib-http/http-server-connection.c

index fed1bba1687b335369936c5bd0ee26bb138259ab..9c07f3ec24b3878523c012565ea56fa081375a3b 100644 (file)
@@ -1195,6 +1195,7 @@ http_client_connection_connected(struct connection *_conn, bool success)
                conn->connected_timestamp = ioloop_timeval;
                http_client_connection_debug(conn, "Connected");
 
+               (void)net_set_tcp_nodelay(_conn->fd_out, TRUE);
                if (set->socket_send_buffer_size > 0) {
                        if (net_set_send_buffer_size(_conn->fd_out,
                                set->socket_send_buffer_size) < 0)
index ce0ee5be6416bde1733e6cfb7dd8e8257ddc4bc3..34aaf9549c593847d56e91a9a4e4afea5143c975 100644 (file)
@@ -1035,6 +1035,8 @@ http_server_connection_create(struct http_server *server,
        conn->callbacks = callbacks;
        conn->context = context;
 
+       (void)net_set_tcp_nodelay(fd_out, TRUE);
+
        /* get a name for this connection */
        if (fd_in != fd_out || net_getpeername(fd_in, &addr, &port) < 0) {
                name = t_strdup_printf("[%u]", id);