Disable Nagle's algorithm, this was exposed by our internal micro benchmark, the streamingInputCall() method happened to have the write-write-read pattern which added 40ms extra delay.

According to our micro benchmark, this change improves the performance, see https://screenshot.googleplex.com/cfxjPGxkgF.png for the previous results, there were 4 out of 6 scenarios had higher latency than netty transport.

https://screenshot.googleplex.com/Rq92tYMvBE.png shows the results after this change, the latencies in all scenarios are less than netty transport.

This commit fixes #60.
This commit is contained in:
Xudong Ma 2015-03-31 19:35:44 +08:00
parent a375eccbea
commit eb2d65bb0c
1 changed files with 1 additions and 0 deletions

View File

@ -208,6 +208,7 @@ public class OkHttpClientTransport implements ClientTransport {
// We assume the sslSocketFactory will verify the server hostname. // We assume the sslSocketFactory will verify the server hostname.
socket = sslSocketFactory.createSocket(socket, authorityHost, address.getPort(), true); socket = sslSocketFactory.createSocket(socket, authorityHost, address.getPort(), true);
} }
socket.setTcpNoDelay(true);
source = Okio.buffer(Okio.source(socket)); source = Okio.buffer(Okio.source(socket));
sink = Okio.buffer(Okio.sink(socket)); sink = Okio.buffer(Okio.sink(socket));
} catch (IOException e) { } catch (IOException e) {