1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-07 07:43:13 +02:00

Remove explicit setting of send/receive buffer as modern OSs don't

need this and it slows things down for servers.

For clients it's not much of an issue, since traffic rates are low.

However, for server-to-server links it is an entirely different matter.
It is (only) noticeable if you have lots of traffic, such as when there
is a lot to sync while linking two servers, and especially when the two
servers are geographically further apart.
Tested with 100,000 G-lines on both sides being synced (20MB traffic):
* 20ms RTT (same country/state): speed up of x3
* 200ms RTT (transpacific): speed up of x6
This commit is contained in:
Bram Matthys
2021-03-14 16:04:43 +01:00
parent a880532ca7
commit 022ed9ae71
3 changed files with 9 additions and 22 deletions
-12
View File
@@ -32,18 +32,6 @@ extern int fd_fileopen(const char *path, unsigned int flags);
#define FD_SELECT_READ 0x1
#define FD_SELECT_WRITE 0x2
/* Socket buffer sizes for clients and servers
* Note that these have been carefully chosen so you shouldn't touch these.
* If you make these much higher then be aware that this means you loose
* send queue / receive queue protection, otherwise known as "Excess flood"
* and "SendQ Exceeded", since these queues are ON TOP of UnrealIRCd's
* own queueing mechanism, it uses the OS TCP Socket queue.
*/
#define USER_SOCKET_RECEIVE_BUFFER 8192
#define USER_SOCKET_SEND_BUFFER 32768
#define SERVER_SOCKET_RECEIVE_BUFFER 131072
#define SERVER_SOCKET_SEND_BUFFER 131072
extern void fd_setselect(int fd, int flags, IOCallbackFunc iocb, void *data);
extern void fd_select(time_t delay); /* backend-specific */
extern void fd_refresh(int fd); /* backend-specific */
-5
View File
@@ -244,11 +244,6 @@ Server *make_server(Client *client)
del_from_id_hash_table(client->id, client);
*client->id = '\0';
}
if (MyConnect(client) && (client->local->fd >= 0))
{
/* Give servers a large socket buffer for performance */
set_socket_buffers(client->local->fd, SERVER_SOCKET_RECEIVE_BUFFER, SERVER_SOCKET_SEND_BUFFER);
}
return client->serv;
}
+9 -5
View File
@@ -703,10 +703,7 @@ void set_ipv6_opts(int fd)
}
/** This sets the *OS* socket buffers.
* Note that setting these high is not always a good idea.
* For example for regular users we keep the receive buffer tight
* so we detect a high receive queue (Excess Flood) properly.
* See include/fdlist.h for more information
* This shouldn't be needed anymore, but I've left the function here.
*/
void set_socket_buffers(int fd, int rcvbuf, int sndbuf)
{
@@ -726,17 +723,24 @@ void set_sock_opts(int fd, Client *client, int ipv6)
if (ipv6)
set_ipv6_opts(fd);
#ifdef SO_REUSEADDR
opt = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof(opt)) < 0)
report_error("setsockopt(SO_REUSEADDR) %s:%s", client);
#endif
#if defined(SO_USELOOPBACK) && !defined(_WIN32)
opt = 1;
if (setsockopt(fd, SOL_SOCKET, SO_USELOOPBACK, (void *)&opt, sizeof(opt)) < 0)
report_error("setsockopt(SO_USELOOPBACK) %s:%s", client);
#endif
set_socket_buffers(fd, USER_SOCKET_RECEIVE_BUFFER, USER_SOCKET_SEND_BUFFER);
/* Previously we also called set_socket_buffers() to set some
* specific buffer limits. This is no longer needed on modern OS's.
* Setting it explicitly actually slows things down.
*/
/* Set to non blocking: */
#if !defined(_WIN32)
if ((opt = fcntl(fd, F_GETFL, 0)) == -1)