Description:
Sorry if this is not the correct place to ask about a feature request.
I support MySQL on a system (VMS) that has a very small default TCP send and receive buffer size, unfortuently I have not been able to get this system setting changed, connections are made over links with some latency and the throughput is limited.
Being able to specify the SO_SNDBUF and SO_RCVBUF sizes as a compile time option would allow the MySQL client/server libraries to make more efficient use of TCPIP in an environment where the defaults are inappropriately small and there is some latency, and result sets exceed the buffer sizes.
I may well be the only person in this situation, and I anticipate this request is likely to fall on stoney ground, however, I thought no harm in asking.
How to repeat:
On a system with small default TCP send and receive buffer sizes, such as 6144 bytes, profile a connection from a client to a host (the host can be on regular Linux box) where the network has some latency (anything over 10ms should be enough), ensure the dataset returned is greater than the buffer size, so a quick query that returns 1MB of data would suffice.
On Linux the middle value of:
/proc/sys/net/ipv4/tcp_wmem
/proc/sys/net/ipv4/tcp_rmem
can be used to change the intial buffer sizes, (depending on your kernel and if it has autotuning /proc/sys/net/ipv4/tcp_moderate_rcvbuf may need to be removed or set to 0).
On any (but especially a recent) Linux Kernel it may be difficult (if not impossible) to simulate a VMS TCPIP stack with small default send and receive buffer sizes.
Suggested fix:
Here is the start of a patch:
violate.h
/* set SO_SND_BUF and SO_RCV_BUF at IPPROTO_TCP level, when possible */
int vio_snd_rcv_buf(Vio *vio, int buf_size);
net.c
my_net_init
vio_fastsend(vio);
vio_snd_rcv_buf(vio,36864); /* make this a build option #ifdef */
viosocket.c
int vio_snd_rcv_buf(Vio * vio, int buf_size)
{
int r_snd=0;
int r_rcv=0;
int r=0;
DBUG_ENTER("vio_snd_rcv_buf");
DBUG_PRINT("enter",("buf_size: %d",buf_size));
if (vio->type != VIO_TYPE_NAMEDPIPE)
{
if (buf_size)
{
r_snd = setsockopt(vio->sd, SOL_SOCKET, SO_SNDBUF, (char*)&buf_size, sizeof(buf_size));
r_rcv = setsockopt(vio->sd, SOL_SOCKET, SO_RCVBUF, (char*)&buf_size, sizeof(buf_size));
}
}
if (r_snd)
{
DBUG_PRINT("warning", ("Couldn't set socket option for SNDBUF"));
r= -1;
}
if (r_rcv)
{
DBUG_PRINT("warning", ("Couldn't set socket option for RCVBUF"));
r= -1;
}
DBUG_PRINT("exit", ("%d", r));
DBUG_RETURN(r);
}
Thanks for reading.
Peter (Stig) Edwards
Description: Sorry if this is not the correct place to ask about a feature request. I support MySQL on a system (VMS) that has a very small default TCP send and receive buffer size, unfortuently I have not been able to get this system setting changed, connections are made over links with some latency and the throughput is limited. Being able to specify the SO_SNDBUF and SO_RCVBUF sizes as a compile time option would allow the MySQL client/server libraries to make more efficient use of TCPIP in an environment where the defaults are inappropriately small and there is some latency, and result sets exceed the buffer sizes. I may well be the only person in this situation, and I anticipate this request is likely to fall on stoney ground, however, I thought no harm in asking. How to repeat: On a system with small default TCP send and receive buffer sizes, such as 6144 bytes, profile a connection from a client to a host (the host can be on regular Linux box) where the network has some latency (anything over 10ms should be enough), ensure the dataset returned is greater than the buffer size, so a quick query that returns 1MB of data would suffice. On Linux the middle value of: /proc/sys/net/ipv4/tcp_wmem /proc/sys/net/ipv4/tcp_rmem can be used to change the intial buffer sizes, (depending on your kernel and if it has autotuning /proc/sys/net/ipv4/tcp_moderate_rcvbuf may need to be removed or set to 0). On any (but especially a recent) Linux Kernel it may be difficult (if not impossible) to simulate a VMS TCPIP stack with small default send and receive buffer sizes. Suggested fix: Here is the start of a patch: violate.h /* set SO_SND_BUF and SO_RCV_BUF at IPPROTO_TCP level, when possible */ int vio_snd_rcv_buf(Vio *vio, int buf_size); net.c my_net_init vio_fastsend(vio); vio_snd_rcv_buf(vio,36864); /* make this a build option #ifdef */ viosocket.c int vio_snd_rcv_buf(Vio * vio, int buf_size) { int r_snd=0; int r_rcv=0; int r=0; DBUG_ENTER("vio_snd_rcv_buf"); DBUG_PRINT("enter",("buf_size: %d",buf_size)); if (vio->type != VIO_TYPE_NAMEDPIPE) { if (buf_size) { r_snd = setsockopt(vio->sd, SOL_SOCKET, SO_SNDBUF, (char*)&buf_size, sizeof(buf_size)); r_rcv = setsockopt(vio->sd, SOL_SOCKET, SO_RCVBUF, (char*)&buf_size, sizeof(buf_size)); } } if (r_snd) { DBUG_PRINT("warning", ("Couldn't set socket option for SNDBUF")); r= -1; } if (r_rcv) { DBUG_PRINT("warning", ("Couldn't set socket option for RCVBUF")); r= -1; } DBUG_PRINT("exit", ("%d", r)); DBUG_RETURN(r); } Thanks for reading. Peter (Stig) Edwards