From 1ef2d768e71981e4429376a0cb25dbed14dfae52 Mon Sep 17 00:00:00 2001 From: David Galeano Date: Tue, 27 Jun 2017 01:09:49 +0100 Subject: socket.c: Disable Nagle's algorithm on TCP sockets (#6915) Reducing latency is more interesting than optimizing bandwidth for Nvim's typical use-cases. --- src/nvim/event/socket.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index 30a71a5586..a796f303ab 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -66,6 +66,7 @@ int socket_watcher_init(Loop *loop, SocketWatcher *watcher, watcher->uv.tcp.addrinfo = request.addrinfo; uv_tcp_init(&loop->uv, &watcher->uv.tcp.handle); + uv_tcp_nodelay(&watcher->uv.tcp.handle, true); watcher->stream = STRUCT_CAST(uv_stream_t, &watcher->uv.tcp.handle); } else { uv_pipe_init(&loop->uv, &watcher->uv.pipe.handle, 0); @@ -146,6 +147,7 @@ int socket_watcher_accept(SocketWatcher *watcher, Stream *stream) if (watcher->stream->type == UV_TCP) { client = STRUCT_CAST(uv_stream_t, &stream->uv.tcp); uv_tcp_init(watcher->uv.tcp.handle.loop, (uv_tcp_t *)client); + uv_tcp_nodelay((uv_tcp_t *)client, true); } else { client = STRUCT_CAST(uv_stream_t, &stream->uv.pipe); uv_pipe_init(watcher->uv.pipe.handle.loop, (uv_pipe_t *)client, 0); @@ -237,6 +239,7 @@ bool socket_connect(Loop *loop, Stream *stream, tcp_retry: uv_tcp_init(&loop->uv, tcp); + uv_tcp_nodelay(tcp, true); uv_tcp_connect(&req, tcp, addrinfo->ai_addr, connect_cb); uv_stream = (uv_stream_t *)tcp; -- cgit