dlr         2002/12/03 09:22:27

  Modified:    src/java/org/apache/xmlrpc WebServer.java
  Log:
  Applied patch by Ed Tellman <[EMAIL PROTECTED]>.  Here's what Ed has to
  say about the change:
  
    "I am using Windows 2000, jdk 1.4.1.
  
    I wrote a simple performance test which repeatedly makes an XML-RPC
    call, to see how many calls I could make each second.
  
    I was surprised to find that in my system enabling HTTP keep alive
    dramatically reduced the performance, instead of improving it as I
    expected.  I did a bit of experimenting, and found that setting the
    TCP no-delay option on the socket helped quite a bit.  After I did
    this, the performance with keep alive was about twice as good as the
    performance without it."
  
  Ed suggests that we provide a global flag to gate the toggling of the
  TCP_NODELAY socket option, but we'll hold off on that until someone
  actually voices a need for such a flag.  Apache httpd 2.0 also sets
  this socket option, relying on APR to determine whether the underlying
  platform's TCP stack supports it.  XML-RPC will go out on a limb and
  rely on Java to do the Right Thing (cross your fingers, folks!).
  
  In case you're curious, here's a reasonably good description of
  TCP_NODELAY from CVS revision 1.102 of httpd-2.0/server/mpm_common.c:
  
    "The Nagle algorithm says that we should delay sending partial
    packets in hopes of getting more data.  We don't want to do
    this; we are not telnet.  There are bad interactions between
    persistent connections and Nagle's algorithm that have very severe
    performance penalties.  (Failing to disable Nagle is not much of a
    problem with simple HTTP.)
  
    In spite of these problems, failure here is not a shooting offense."
  
  A comment in /usr/include/netinet/tcp.h on my RedHat 7.3 box speaks
  similarly of TCP_NODELAY:
  
    "Don't delay send to coalesce packets."
  
  Considering that things still work okay with Nagle's algorithm active,
  I've added handling of SocketException around setting of the
  TCP_NODELAY flag which reports the error and keeps on chuggin'.
  
  Revision  Changes    Path
  1.22      +10 -0     xml-rpc/src/java/org/apache/xmlrpc/WebServer.java
  
  Index: WebServer.java
  ===================================================================
  RCS file: /home/cvs/xml-rpc/src/java/org/apache/xmlrpc/WebServer.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -u -r1.21 -r1.22
  --- WebServer.java    10 Oct 2002 00:24:12 -0000      1.21
  +++ WebServer.java    3 Dec 2002 17:22:26 -0000       1.22
  @@ -64,6 +64,7 @@
   import java.net.InetAddress;
   import java.net.ServerSocket;
   import java.net.Socket;
  +import java.net.SocketException;
   import java.util.EmptyStackException;
   import java.util.Stack;
   import java.util.StringTokenizer;
  @@ -482,6 +483,15 @@
                   try
                   {
                       Socket socket = serverSocket.accept();
  +                    try
  +                    {
  +                        socket.setTcpNoDelay(true);
  +                    }
  +                    catch (SocketException socketOptEx)
  +                    {
  +                        System.err.println(socketOptEx);
  +                    }
  +
                       if (allowConnection(socket))
                       {
                           Runner runner = getRunner();
  
  
  


Reply via email to