Johan,

please don't http://cygwin.com/acronyms/#TOFU.  Thanks.

On Jan  4 21:25, Johan van den Berg wrote:
> I am very happy to report that increasing the send and receive buffers
> has done the job (at least, on a 10MBit link but will be testing a
> 100Mbit in a few days). I calculated the ideal size as per
> http://www.ibm.com/developerworks/linux/library/l-hisock/index.html

it's nice to know that you could increase the performance by increasing
the buffer sizes.  However, I'm reluctant to implement this as a generic
option.  As far as I know the socket buffers are taken from nonpaged pool,
so generically using 2 Meg buffers will take a lot of precious resources.

I made a test in a local LAN between Linux and a W7 64 bit machine, and
I didn't see a lot of difference between 64K, 2 Megs, or letting the OS
decide.  So I'm wondering if it's not the best option to let the OS
decide starting with Vista and later.

How's the performance in your scenario when applying the below patch
instead of yours?


Corinna


Index: net.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/net.cc,v
retrieving revision 1.294
diff -u -p -r1.294 net.cc
--- net.cc      17 Dec 2011 23:39:46 -0000      1.294
+++ net.cc      9 Jan 2012 13:41:23 -0000
@@ -569,26 +569,46 @@ fdsock (cygheap_fdmanip& fd, const devic
      be nice, though.
 
      (*) Maximum normal TCP window size.  Coincidence?  */
-  ((fhandler_socket *) fd)->rmem () = 65535;
-  ((fhandler_socket *) fd)->wmem () = 65535;
-  if (::setsockopt (soc, SOL_SOCKET, SO_RCVBUF,
-                   (char *) &((fhandler_socket *) fd)->rmem (), sizeof (int)))
+  if (wincap.has_sendmsg ())   /* FIXME.  Invent another wincap. */
     {
-      debug_printf ("setsockopt(SO_RCVBUF) failed, %lu", WSAGetLastError ());
       if (::getsockopt (soc, SOL_SOCKET, SO_RCVBUF,
                        (char *) &((fhandler_socket *) fd)->rmem (),
                        (size = sizeof (int), &size)))
        system_printf ("getsockopt(SO_RCVBUF) failed, %lu", WSAGetLastError ());
-    }
-  if (::setsockopt (soc, SOL_SOCKET, SO_SNDBUF,
-                   (char *) &((fhandler_socket *) fd)->wmem (), sizeof (int)))
-    {
-      debug_printf ("setsockopt(SO_SNDBUF) failed, %lu", WSAGetLastError ());
       if (::getsockopt (soc, SOL_SOCKET, SO_SNDBUF,
                        (char *) &((fhandler_socket *) fd)->wmem (),
                        (size = sizeof (int), &size)))
        system_printf ("getsockopt(SO_SNDBUF) failed, %lu", WSAGetLastError ());
     }
+  else
+    {
+      ((fhandler_socket *) fd)->rmem () = 65535;
+      ((fhandler_socket *) fd)->wmem () = 65535;
+      if (::setsockopt (soc, SOL_SOCKET, SO_RCVBUF,
+                       (char *) &((fhandler_socket *) fd)->rmem (),
+                       sizeof (int)))
+       {
+         debug_printf ("setsockopt(SO_RCVBUF) failed, %lu",
+                       WSAGetLastError ());
+         if (::getsockopt (soc, SOL_SOCKET, SO_RCVBUF,
+                           (char *) &((fhandler_socket *) fd)->rmem (),
+                           (size = sizeof (int), &size)))
+           system_printf ("getsockopt(SO_RCVBUF) failed, %lu",
+                          WSAGetLastError ());
+       }
+      if (::setsockopt (soc, SOL_SOCKET, SO_SNDBUF,
+                       (char *) &((fhandler_socket *) fd)->wmem (),
+                       sizeof (int)))
+       {
+         debug_printf ("setsockopt(SO_SNDBUF) failed, %lu",
+                       WSAGetLastError ());
+         if (::getsockopt (soc, SOL_SOCKET, SO_SNDBUF,
+                           (char *) &((fhandler_socket *) fd)->wmem (),
+                           (size = sizeof (int), &size)))
+           system_printf ("getsockopt(SO_SNDBUF) failed, %lu",
+                          WSAGetLastError ());
+       }
+    }
 
   return true;
 }
Index: fhandler_socket.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_socket.cc,v
retrieving revision 1.284
diff -u -p -r1.284 fhandler_socket.cc
--- fhandler_socket.cc  4 Dec 2011 17:58:24 -0000       1.284
+++ fhandler_socket.cc  9 Jan 2012 13:41:23 -0000
@@ -1598,7 +1598,7 @@ fhandler_socket::send_internal (struct _
       /* CV 2009-12-02: Don't split datagram messages. */
       /* FIXME: Look for a way to split a message into the least number of
                pieces to minimize the number of WsaSendTo calls. */
-      if (get_socket_type () == SOCK_STREAM)
+      if (!wincap.has_sendmsg () && get_socket_type () == SOCK_STREAM)
        {
          buf.buf = wsamsg->lpBuffers[i].buf + off;
          buf.len = wsamsg->lpBuffers[i].len - off;
@@ -1611,7 +1611,7 @@ fhandler_socket::send_internal (struct _
        {
          if (use_sendmsg)
            res = WSASendMsg (get_socket (), wsamsg, flags, &ret, NULL, NULL);
-         else if (get_socket_type () == SOCK_STREAM)
+         else if (!wincap.has_sendmsg () && get_socket_type () == SOCK_STREAM)
            res = WSASendTo (get_socket (), &buf, 1, &ret, flags,
                             wsamsg->name, wsamsg->namelen, NULL, NULL);
          else

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply via email to