Mercurial > dovecot > core-2.2
changeset 21042:770b5fe8cc16
lib-http: client/server: Enable the TCP_NODELAY option for all connections.
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.
author | Stephan Bosch <stephan@dovecot.fi> |
---|---|
date | Thu, 16 Jun 2016 22:02:08 +0200 |
parents | 13a159cfd232 |
children | a56f60c2d992 |
files | src/lib-http/http-client-connection.c src/lib-http/http-server-connection.c |
diffstat | 2 files changed, 2 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-http/http-client-connection.c Thu Jun 16 22:01:06 2016 +0200 +++ b/src/lib-http/http-client-connection.c Thu Jun 16 22:02:08 2016 +0200 @@ -1253,6 +1253,7 @@ 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)
--- a/src/lib-http/http-server-connection.c Thu Jun 16 22:01:06 2016 +0200 +++ b/src/lib-http/http-server-connection.c Thu Jun 16 22:02:08 2016 +0200 @@ -1072,6 +1072,7 @@ i_error("net_set_recv_buffer_size(%"PRIuSIZE_T") failed: %m", set->socket_recv_buffer_size); } + (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) {