delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/01/09/08:44:55

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Mon, 9 Jan 2012 14:43:11 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: socket performance (was Re: Building cygwin1.dll)
Message-ID: <20120109134311.GH15470@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <95814509-4E08-44C6-8E59-026225EC0FF5 AT playsafesa DOT com> <4F04613B DOT 6050505 AT gmail DOT com> <B6F87B4D-C088-49BF-B52C-3D0168EAC78D AT playsafesa DOT com>
MIME-Version: 1.0
In-Reply-To: <B6F87B4D-C088-49BF-B52C-3D0168EAC78D@playsafesa.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019