diff options
author | unknown <konstantin@mysql.com> | 2005-01-25 02:31:51 +0300 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2005-01-25 02:31:51 +0300 |
commit | dc43c6ea4b2bd3c466049674b4c760cad9ad2979 (patch) | |
tree | acf1d9a2743f4e2584213f4b4a0d876dd29a64cc /vio | |
parent | 4332ac91cd902b70fdbd605c9954413d5b2ce9e5 (diff) | |
download | mariadb-git-dc43c6ea4b2bd3c466049674b4c760cad9ad2979.tar.gz |
A fix for Bug#5787 "mysql_stmt_prepare is upto 8 times slower":
it's crucial to disable Nagle algorithm on client for no-reply commands
(like mysql_stmt_free) to always work fast.
Nagle algorithm instructs the sender to buffer (store) data if any
unacknowledged data is outstanding and the size of to-send data is less than
the network segment. It was exactly the case with COM_STMT_CLOSE after
COM_STMT_PREPARE, so the client was waiting for Nagle timer to expire or
for ACK from the server, while the server was holding up ACK because of
delayed acknowledgement algorithm.
The tricky part is that we have been already disabling Nagle
algorithm (by setting TCP_NODELAY)
almost everywhere except Windows (and maybe Netware).
It is the reason why the bug was repeatable only with Windows client.
vio/viosocket.c:
A fix for Bug#5787 "mysql_stmt_prepare is upto 8 times slower":
if we disable Nagle algorithm, do it everywhere.
Diffstat (limited to 'vio')
-rw-r--r-- | vio/viosocket.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c index bcba05beef1..202d70b6c26 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -142,23 +142,29 @@ int vio_fastsend(Vio * vio __attribute__((unused))) int r=0; DBUG_ENTER("vio_fastsend"); -#ifdef IPTOS_THROUGHPUT +#if defined(IPTOS_THROUGHPUT) && !defined(__EMX__) { -#ifndef __EMX__ int tos = IPTOS_THROUGHPUT; - if (!setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos))) -#endif /* !__EMX__ */ - { - int nodelay = 1; - if (setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void *) &nodelay, - sizeof(nodelay))) { - DBUG_PRINT("warning", - ("Couldn't set socket option for fast send")); - r= -1; - } - } + r= setsockopt(vio->sd, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(tos)); + } +#endif /* IPTOS_THROUGHPUT && !__EMX__ */ + if (!r) + { +#ifdef __WIN__ + BOOL nodelay= 1; + r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (const char*) &nodelay, + sizeof(nodelay)); +#else + int nodelay = 1; + r= setsockopt(vio->sd, IPPROTO_TCP, TCP_NODELAY, (void*) &nodelay, + sizeof(nodelay)); +#endif /* __WIN__ */ + } + if (r) + { + DBUG_PRINT("warning", ("Couldn't set socket option for fast send")); + r= -1; } -#endif /* IPTOS_THROUGHPUT */ DBUG_PRINT("exit", ("%d", r)); DBUG_RETURN(r); } |