Set the default for UDPRcvBuf and UDPSndBuf to 1M.
It may not be obvious, but due to the way tinc operates (single-threaded control loop with no intermediate packet buffer), UDP send and receive buffers can have a massive impact on performance. It is therefore of paramount importance that the buffers be large enough to prevent packet drops that could occur while tinc is processing a packet. Leaving that value to the OS default could be reasonable if we weren't relying on it so much. Instead, this makes performance somewhat unpredictable. In practice, the worst case scenario occurs on Windows, where Microsoft had the brillant idea of making the buffers 8K in size by default, no matter what the link speed is. Considering that 8K flies past in a matter of microseconds on >1G links, this is extremely inappropriate. On these systems, changing the buffer size to 1M results in *obscene* raw throughput improvements; I have observed a 10X jump from 40 Mbit/s to 400 Mbit/s on my system. In this commit, we stop trusting the OS to get this right and we use a fixed 1M value instead, which should be enough for <=1G links.
This commit is contained in:
parent
6568cffd52
commit
94f49a163a
4 changed files with 16 additions and 12 deletions
|
|
@ -854,14 +854,14 @@ static bool setup_myself(void) {
|
|||
}
|
||||
|
||||
if(get_config_int(lookup_config(config_tree, "UDPRcvBuf"), &udp_rcvbuf)) {
|
||||
if(udp_rcvbuf <= 0) {
|
||||
if(udp_rcvbuf < 0) {
|
||||
logger(DEBUG_ALWAYS, LOG_ERR, "UDPRcvBuf cannot be negative!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(get_config_int(lookup_config(config_tree, "UDPSndBuf"), &udp_sndbuf)) {
|
||||
if(udp_sndbuf <= 0) {
|
||||
if(udp_sndbuf < 0) {
|
||||
logger(DEBUG_ALWAYS, LOG_ERR, "UDPSndBuf cannot be negative!");
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@
|
|||
int addressfamily = AF_UNSPEC;
|
||||
int maxtimeout = 900;
|
||||
int seconds_till_retry = 5;
|
||||
int udp_rcvbuf = 0;
|
||||
int udp_sndbuf = 0;
|
||||
int udp_rcvbuf = 1024 * 1024;
|
||||
int udp_sndbuf = 1024 * 1024;
|
||||
int max_connection_burst = 100;
|
||||
|
||||
listen_socket_t listen_socket[MAXSOCKETS];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue