aboutsummaryrefslogtreecommitdiffstats
path: root/android/hw-pipe-net.c
diff options
context:
space:
mode:
authorDavid Turner <digit@android.com>2011-08-15 23:07:03 +0200
committerDavid Turner <digit@android.com>2011-08-15 23:07:55 +0200
commit6d02d6cb12378599d949591d6c5070e2c96dd9dd (patch)
tree6f93adfcbc13a7674940f681ef8418979303d241 /android/hw-pipe-net.c
parentaa5b6d8b42de3ee551e6e496459eb4f836e2da54 (diff)
downloadexternal_qemu-6d02d6cb12378599d949591d6c5070e2c96dd9dd.zip
external_qemu-6d02d6cb12378599d949591d6c5070e2c96dd9dd.tar.gz
external_qemu-6d02d6cb12378599d949591d6c5070e2c96dd9dd.tar.bz2
opengles: improve throughput of TCP socket
Disable the TCP Nagle algorithm to drastically improve the throughput of small packets when creating the TCP socket used to talk with the OpenGLES renderer library. Coupled with a corresponding change in the server part of the code, this improves performance of most applications significantly. + get rid of shouldSetSockOpt field, by performing the buffer adjustment just after the socket is created. Change-Id: Ibacca834ff98d1e9a92fb735f450b925e373fdc0
Diffstat (limited to 'android/hw-pipe-net.c')
-rw-r--r--android/hw-pipe-net.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/android/hw-pipe-net.c b/android/hw-pipe-net.c
index dade446..b3bc6c9 100644
--- a/android/hw-pipe-net.c
+++ b/android/hw-pipe-net.c
@@ -68,7 +68,6 @@ typedef struct {
int wakeWanted;
LoopIo io[1];
AsyncConnector connector[1];
- int shouldSetSocketOpt;
} NetPipe;
static void
@@ -192,7 +191,6 @@ netPipe_initFromAddress( void* hwpipe, const SockAddress* address, Looper* loop
pipe->hwpipe = hwpipe;
pipe->state = STATE_INIT;
- pipe->shouldSetSocketOpt = 0;
{
AsyncStatus status;
@@ -246,19 +244,6 @@ netPipe_sendBuffers( void* opaque, const GoldfishPipeBuffer* buffers, int numBuf
const GoldfishPipeBuffer* buff = buffers;
const GoldfishPipeBuffer* buffEnd = buff + numBuffers;
-#ifdef _WIN32
- if (pipe->shouldSetSocketOpt == 1) {
- int sndbuf = 128 * 1024;
- int len = sizeof(sndbuf);
- if (setsockopt(pipe->io->fd, SOL_SOCKET, SO_SNDBUF,
- (char*)&sndbuf, len) == SOCKET_ERROR) {
- D("Failed to set SO_SNDBUF to %d error=0x%x\n",
- sndbuf, WSAGetLastError());
- }
- pipe->shouldSetSocketOpt = 0;
- }
-#endif
-
for (; buff < buffEnd; buff++)
count += buff->size;
@@ -480,7 +465,22 @@ openglesPipe_init( void* hwpipe, void* _looper, const char* args )
/* For now, simply connect through tcp */
snprintf(temp, sizeof temp, "%d", DEFAULT_OPENGLES_PORT);
pipe = (NetPipe *)netPipe_initTcp(hwpipe, _looper, temp);
- pipe->shouldSetSocketOpt = 1;
+
+ // Disable TCP nagle algorithm to improve throughput of small packets
+ socket_set_nodelay(pipe->io->fd);
+
+ // On Win32, adjust buffer sizes
+#ifdef _WIN32
+ {
+ int sndbuf = 128 * 1024;
+ int len = sizeof(sndbuf);
+ if (setsockopt(pipe->io->fd, SOL_SOCKET, SO_SNDBUF,
+ (char*)&sndbuf, len) == SOCKET_ERROR) {
+ D("Failed to set SO_SNDBUF to %d error=0x%x\n",
+ sndbuf, WSAGetLastError());
+ }
+ }
+#endif /* _WIN32 */
return pipe;
}