You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cd...@apache.org on 2008/01/25 03:04:34 UTC

svn commit: r615098 - in /hadoop/core/trunk: CHANGES.txt conf/hadoop-default.xml src/java/org/apache/hadoop/ipc/Client.java src/java/org/apache/hadoop/ipc/Server.java

Author: cdouglas
Date: Thu Jan 24 18:04:31 2008
New Revision: 615098

URL: http://svn.apache.org/viewvc?rev=615098&view=rev
Log:
HADOOP-2232. Add an option to disable Nagle's algorithm in the IPC stack.
Contributed by Clint Morgan.



Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/conf/hadoop-default.xml
    hadoop/core/trunk/src/java/org/apache/hadoop/ipc/Client.java
    hadoop/core/trunk/src/java/org/apache/hadoop/ipc/Server.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=615098&r1=615097&r2=615098&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu Jan 24 18:04:31 2008
@@ -287,6 +287,9 @@
 
     HADOOP-2431. Test HDFS File Permissions. (Hairong Kuang via shv)
 
+    HADOOP-2232. Add an option to disable Nagle's algorithm in the IPC stack.
+    (Clint Morgan via cdouglas)
+
   OPTIMIZATIONS
 
     HADOOP-1898.  Release the lock protecting the last time of the last stack

Modified: hadoop/core/trunk/conf/hadoop-default.xml
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/conf/hadoop-default.xml?rev=615098&r1=615097&r2=615098&view=diff
==============================================================================
--- hadoop/core/trunk/conf/hadoop-default.xml (original)
+++ hadoop/core/trunk/conf/hadoop-default.xml Thu Jan 24 18:04:31 2008
@@ -988,6 +988,24 @@
   </description>
 </property>
 
+<property>
+  <name>ipc.server.tcpnodelay</name>
+  <value>false</value>
+  <description>Turn on/off Nagle's algorithm for the TCP socket connection on 
+  the server. Setting to true disables the algorithm and may decrease latency
+  with a cost of more/smaller packets. 
+  </description>
+</property>
+
+<property>
+  <name>ipc.client.tcpnodelay</name>
+  <value>false</value>
+  <description>Turn on/off Nagle's algorithm for the TCP socket connection on 
+  the client. Setting to true disables the algorithm and may decrease latency
+  with a cost of more/smaller packets. 
+  </description>
+</property>
+
 <!-- Job Notification Configuration -->
 
 <!--

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/ipc/Client.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/ipc/Client.java?rev=615098&r1=615097&r2=615098&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/ipc/Client.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/ipc/Client.java Thu Jan 24 18:04:31 2008
@@ -71,6 +71,7 @@
   private int maxIdleTime; //connections will be culled if it was idle for 
                            //maxIdleTime msecs
   private int maxRetries; //the max. no. of retries for socket connections
+  private boolean tcpNoDelay; // if T then disable Nagle's Algorithm
   private Thread connectionCullerThread;
   private SocketFactory socketFactory;           // how to create sockets
   private boolean simulateError = false;         // unit tests
@@ -156,6 +157,7 @@
       while (true) {
         try {
           this.socket = socketFactory.createSocket();
+          this.socket.setTcpNoDelay(tcpNoDelay);
           this.socket.connect(remoteId.getAddress(), FSConstants.READ_TIMEOUT);
           break;
         } catch (IOException ie) { //SocketTimeoutException is also caught 
@@ -451,6 +453,7 @@
     this.timeout = conf.getInt("ipc.client.timeout", 10000);
     this.maxIdleTime = conf.getInt("ipc.client.connection.maxidletime", 1000);
     this.maxRetries = conf.getInt("ipc.client.connect.max.retries", 10);
+    this.tcpNoDelay = conf.getBoolean("ipc.client.tcpnodelay", false);
     this.conf = conf;
     this.socketFactory = factory;
     this.connectionCullerThread = new ConnectionCuller();

Modified: hadoop/core/trunk/src/java/org/apache/hadoop/ipc/Server.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/java/org/apache/hadoop/ipc/Server.java?rev=615098&r1=615097&r2=615098&view=diff
==============================================================================
--- hadoop/core/trunk/src/java/org/apache/hadoop/ipc/Server.java (original)
+++ hadoop/core/trunk/src/java/org/apache/hadoop/ipc/Server.java Thu Jan 24 18:04:31 2008
@@ -161,6 +161,7 @@
   private long maxCallStartAge;
   private int maxQueueSize;
   private int socketSendBufferSize;
+  private boolean tcpNoDelay; // if T then disable Nagle's Algorithm
 
   volatile private boolean running = true;         // true while server runs
   private LinkedList<Call> callQueue = new LinkedList<Call>(); // queued calls
@@ -391,6 +392,7 @@
       ServerSocketChannel server = (ServerSocketChannel) key.channel();
       SocketChannel channel = server.accept();
       channel.configureBlocking(false);
+      channel.socket().setTcpNoDelay(tcpNoDelay);
       SelectionKey readKey = channel.register(selector, SelectionKey.OP_READ);
       c = new Connection(readKey, channel, System.currentTimeMillis());
       readKey.attach(c);