Performance improvement or streaming large result sets.

-bash-4.1$ time mysql -h 127.0.0.1 -P4007 -umassi -pmassi information_schema -q -e "select * from engines a, engines b, engines c, engines d, engines e;" > /dev/null

real	1m16.137s
user	0m0.660s
sys	0m0.392s
-bash-4.1$ time mysql -h 127.0.0.1 -P4007 -umassi -pmassi information_schema -q -e "select * from engines a, engines b, engines c, engines d, engines e;" > /dev/null

real	0m0.980s
user	0m0.944s
sys	0m0.027s
This commit is contained in:
Mark Riddoch 2014-09-16 12:37:57 +01:00
parent dc6db1d3d4
commit f3d32087d8
4 changed files with 18 additions and 6 deletions

View File

@ -23,8 +23,15 @@
// network buffer is 32K
#define MAX_BUFFER_SIZE 32768
// socket send buffer for backend
#define GW_BACKEND_SO_SNDBUF 1024
/**
* Configuration for send and receive socket buffer sizes for
* backend and cleint connections.
*/
#define GW_BACKEND_SO_SNDBUF 32768
#define GW_BACKEND_SO_RCVBUF 32768
#define GW_CLIENT_SO_SNDBUF 32768
#define GW_CLIENT_SO_RCVBUF 32768
#define GW_NOINTR_CALL(A) do { errno = 0; A; } while (errno == EINTR)
#define GW_MYSQL_LOOP_TIMEOUT 300000000

View File

@ -82,10 +82,6 @@
#endif
#define GW_NOINTR_CALL(A) do { errno = 0; A; } while (errno == EINTR)
// network buffer is 32K
#define MAX_BUFFER_SIZE 32768
// socket send buffer for backend
#define GW_BACKEND_SO_SNDBUF 1024
#define SMALL_CHUNK 1024
#define MAX_CHUNK SMALL_CHUNK * 8 * 4
#define ToHex(Y) (Y>='0'&&Y<='9'?Y-'0':Y-'A'+10)

View File

@ -1180,7 +1180,10 @@ int gw_MySQLAccept(DCB *listener)
conn_open[c_sock] = true;
#endif
/* set nonblocking */
sendbuf = GW_BACKEND_SO_SNDBUF;
setsockopt(c_sock, SOL_SOCKET, SO_SNDBUF, &sendbuf, optlen);
sendbuf = GW_BACKEND_SO_RCVBUF;
setsockopt(c_sock, SOL_SOCKET, SO_RCVBUF, &sendbuf, optlen);
setnonblocking(c_sock);
client_dcb = dcb_alloc(DCB_ROLE_REQUEST_HANDLER);

View File

@ -34,6 +34,7 @@
*
*/
#include <gw.h>
#include "mysql_client_server_protocol.h"
#include <skygw_types.h>
#include <skygw_utils.h>
@ -741,6 +742,7 @@ int gw_do_connect_to_backend(
struct sockaddr_in serv_addr;
int rv;
int so = 0;
int bufsize;
memset(&serv_addr, 0, sizeof serv_addr);
serv_addr.sin_family = AF_INET;
@ -764,6 +766,10 @@ int gw_do_connect_to_backend(
/* prepare for connect */
setipaddress(&serv_addr.sin_addr, host);
serv_addr.sin_port = htons(port);
bufsize = GW_CLIENT_SO_SNDBUF;
setsockopt(so, SOL_SOCKET, SO_SNDBUF, &bufsize, sizeof(bufsize));
bufsize = GW_CLIENT_SO_RCVBUF;
setsockopt(so, SOL_SOCKET, SO_RCVBUF, &bufsize, sizeof(bufsize));
/* set socket to as non-blocking here */
setnonblocking(so);
rv = connect(so, (struct sockaddr *)&serv_addr, sizeof(serv_addr));