select() too slow

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Mar 15 21:49:00 GMT 2006


On Mar 15 19:07, Pedro Inacio wrote:
> 
> On 2006/03/14, at 22:43, Christopher Faylor wrote:
> 
> >On Tue, Mar 14, 2006 at 09:42:25PM +0000, Pedro Inacio wrote:
> >
> >I don't have any 100MB files sitting around but when I tried this on a
> >14MB file, I find that cygwin is about 2X slower, not an order of
> >magnitude slower.  Taking away the pipe and using regular file  
> >redirection
> >makes things a little faster on cygwin.
> >
> >So, I can't explain why you are seeing such extreme slowdowns.  I  
> >am using
> >the equivalent of a snapshot in my tests, however.  Maybe that's the
> >difference.
> >
> >cgf
> 
> I have created a 14MB file and the results were:
> 
> On Linux: 4 seconds
> On Cygwin: 44 Seconds
> 
> The test were made on 3 different platforms, and the results the same.
> Cygwin is not just 2X slower but 11X slower, each is too much.

It looks like this is a TCP_NODELAY issue.  You tend to get the problem
if a socket is used "interactively", which means, being used for reading
and writing in arbitrary order.

Unfortunately the Nagle algorithm on Windows is somewhat sluggish.  I've
tried your echo_server with and without Nagle disabled.  Sending a 17
Megs file from my Cygwin box to an echo_server on my Linux box takes
between 4 and 5 seconds.

Sending a 17 Megs file from Linux to an echo_server on Cygwin takes
about 55 seconds.  However, when I disable the Nagle algorithm in the
echo_server, it takes between 2 and 9 seconds.  I don't understand the
unexact interval, but I also don't see how that could be Cygwin's fault.


--- echo_server.c.ORIG  2006-03-15 22:37:41.905621200 +0100
+++ echo_server.c       2006-03-15 22:45:56.597789300 +0100
@@ -62,6 +62,10 @@ int main(void) {
 
   fcntl(client_fd, F_SETFL, fcntl(client_fd, F_GETFL) | O_NONBLOCK);
 
+  int opt = 1;
+  if (setsockopt(client_fd, IPPROTO_TCP, TCP_NODELAY, &opt, sizeof opt) == -1)
+    fprintf(stderr,"setsockopt TCP_NODELAY: %.100s", strerror(errno));
+
   while(1) {
     FD_ZERO(&read_fds);
     FD_ZERO(&write_fds);


Corinna  

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

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



More information about the Cygwin mailing list