From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FaOeV-00025v-Ct for qemu-devel@nongnu.org; Sun, 30 Apr 2006 23:00:47 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FaOeT-00025i-OL for qemu-devel@nongnu.org; Sun, 30 Apr 2006 23:00:46 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FaOeT-00025f-Hj for qemu-devel@nongnu.org; Sun, 30 Apr 2006 23:00:45 -0400 Received: from [64.233.162.201] (helo=nz-out-0102.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FaOiC-0007u5-4S for qemu-devel@nongnu.org; Sun, 30 Apr 2006 23:04:36 -0400 Received: by nz-out-0102.google.com with SMTP id 14so2648655nzn for ; Sun, 30 Apr 2006 20:00:44 -0700 (PDT) Message-ID: Date: Sun, 30 Apr 2006 20:00:44 -0700 From: "Ed Swierk" Sender: eswierk@gmail.com MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_8848_8873285.1146452444780" Subject: [Qemu-devel] [PATCH] Improve -net user (slirp) performance by 4x Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org ------=_Part_8848_8873285.1146452444780 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: base64 Content-Disposition: inline VGhyZWUgYnVncyBpbiB0aGUgc2xpcnAgY29kZSBoYXZlIGFuIGVub3Jtb3VzIGFkdmVyc2UgZWZm ZWN0IG9uCm5ldHdvcmtpbmcgcGVyZm9ybWFuY2UuCgoxLiBUaGUgbWF4aW11bSBUQ1Agc2VnbWVu dCBzaXplIGZvciBkYXRhIGZsb3dpbmcgZnJvbSB0aGUgVk0gdG8gdGhlCmhvc3QgaXMgdW5uZWNl c3NhcmlseSBsaW1pdGVkIH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WFzZSBsZXQgbWUKa25vdyBpZiB0aGVyZSBpcyBhbnl0aGluZyBJIGNhbiBkbyB0byBoZWxwIG51 ZGdlIGl0IGludG8gQ1ZTLgoKLS1FZAo= ------=_Part_8848_8873285.1146452444780 Content-Type: text/x-patch; name=qemu-slirp-performance.patch; charset=us-ascii Content-Transfer-Encoding: 7bit X-Attachment-Id: f_emo82qv9 Content-Disposition: attachment; filename="qemu-slirp-performance.patch" diff -BurN qemu-snapshot-2006-03-27_23.orig/slirp/tcp.h qemu-snapshot-2006-03-27_23/slirp/tcp.h --- qemu-snapshot-2006-03-27_23.orig/slirp/tcp.h 2004-04-21 17:10:47.000000000 -0700 +++ qemu-snapshot-2006-03-27_23/slirp/tcp.h 2006-04-11 15:22:05.000000000 -0700 @@ -100,8 +100,10 @@ * With an IP MSS of 576, this is 536, * but 512 is probably more convenient. * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). + * + * We make this 1460 because we only care about Ethernet in the qemu context. */ -#define TCP_MSS 512 +#define TCP_MSS 1460 #define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ diff -BurN qemu-snapshot-2006-03-27_23.orig/slirp/tcp_input.c qemu-snapshot-2006-03-27_23/slirp/tcp_input.c --- qemu-snapshot-2006-03-27_23.orig/slirp/tcp_input.c 2004-10-07 16:27:35.000000000 -0700 +++ qemu-snapshot-2006-03-27_23/slirp/tcp_input.c 2006-04-11 15:22:05.000000000 -0700 @@ -580,28 +580,11 @@ * congestion avoidance sender won't send more until * he gets an ACK. * - * Here are 3 interpretations of what should happen. - * The best (for me) is to delay-ack everything except - * if it's a one-byte packet containing an ESC - * (this means it's an arrow key (or similar) sent using - * Nagel, hence there will be no echo) - * The first of these is the original, the second is the - * middle ground between the other 2 + * It is better to not delay acks at all to maximize + * TCP throughput. See RFC 2581. */ -/* if (((unsigned)ti->ti_len < tp->t_maxseg)) { - */ -/* if (((unsigned)ti->ti_len < tp->t_maxseg && - * (so->so_iptos & IPTOS_LOWDELAY) == 0) || - * ((so->so_iptos & IPTOS_LOWDELAY) && - * ((struct tcpiphdr_2 *)ti)->first_char == (char)27)) { - */ - if ((unsigned)ti->ti_len == 1 && - ((struct tcpiphdr_2 *)ti)->first_char == (char)27) { - tp->t_flags |= TF_ACKNOW; - tcp_output(tp); - } else { - tp->t_flags |= TF_DELACK; - } + tp->t_flags |= TF_ACKNOW; + tcp_output(tp); return; } } /* header prediction */ diff -BurN qemu-snapshot-2006-03-27_23.orig/vl.c qemu-snapshot-2006-03-27_23/vl.c --- qemu-snapshot-2006-03-27_23.orig/vl.c 2006-04-11 15:21:27.000000000 -0700 +++ qemu-snapshot-2006-03-27_23/vl.c 2006-04-11 15:22:05.000000000 -0700 @@ -4026,7 +4026,7 @@ void main_loop_wait(int timeout) { IOHandlerRecord *ioh, *ioh_next; - fd_set rfds, wfds; + fd_set rfds, wfds, xfds; int ret, nfds; struct timeval tv; @@ -4041,6 +4041,7 @@ nfds = -1; FD_ZERO(&rfds); FD_ZERO(&wfds); + FD_ZERO(&xfds); for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) { if (ioh->fd_read && (!ioh->fd_read_poll || @@ -4062,7 +4063,12 @@ #else tv.tv_usec = timeout * 1000; #endif - ret = select(nfds + 1, &rfds, &wfds, NULL, &tv); +#if defined(CONFIG_SLIRP) + if (slirp_inited) { + slirp_select_fill(&nfds, &rfds, &wfds, &xfds); + } +#endif + ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv); if (ret > 0) { /* XXX: better handling of removal */ for(ioh = first_io_handler; ioh != NULL; ioh = ioh_next) { ------=_Part_8848_8873285.1146452444780--