roc230 / spymemcached

Automatically exported from code.google.com/p/spymemcached
0 stars 0 forks source link

Turn off TCP nagle can hugely improve performance #88

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In my test case (I use IPoIB in an InfiniBand network), the first pass
cache always miss. If we keep TCP Nagle on (the default setting), a cache
miss report will take more than 33ms delay (because it is a short message
"END\r\n"). After turn nagle off, the delay reduce to 0.8ms.

We only need 1 line change to get such performance improvement:

--- a/net/spy/memcached/MemcachedConnection.java     2009-04-02
08:44:08.000000000 +0800
+++ b/net/spy/memcached/MemcachedConnection.java        2009-09-02
22:36:54.000000000 +0800
@@ -89,6 +89,9 @@
                        ch.configureBlocking(false);
                        MemcachedNode qa=f.createMemcachedNode(sa, ch,
bufSize);
                        int ops=0;
+
+                       ch.socket().setTcpNoDelay(true);
+
                        if(ch.connect(sa)) {
                                getLogger().info("Connected to %s
immediately", qa);
                                connected(qa);

However we'd better to add a configuration option to control it.

Original issue reported on code.google.com by pi3or...@gmail.com on 2 Sep 2009 at 2:42

GoogleCodeExporter commented 9 years ago
Great, I'm pushing this change in as you.

Original comment by dsalli...@gmail.com on 6 Sep 2009 at 5:14