From 180cc362cd16403c4871d2e4f7f081a68e788c42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Sun, 11 Aug 2024 23:16:31 +0200 Subject: [PATCH] Network performance improvements (#38) --- NEWS.md | 5 ++++- libtransmission/peer-mgr.c | 32 +++++++++----------------------- libtransmission/peer-msgs.c | 4 ++-- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/NEWS.md b/NEWS.md index bb1e61bba7c..ead9e5fd61e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,11 @@ ## (next) +### All Platforms +- Network performance improvements ([#38](https://github.com/stefantalpalaru/transmission-og/pull/38)) + ### GTK+ Client ### Qt Client -- Use our own icons for the system tray. +- Use our own icons for the system tray ([#37](https://github.com/stefantalpalaru/transmission-og/pull/37)) ## [Transmission OG 3.05](https://github.com/stefantalpalaru/transmission-og/releases/tag/3.05) (2024-08-08) diff --git a/libtransmission/peer-mgr.c b/libtransmission/peer-mgr.c index 1c0c3d0c88f..4a298ae431b 100644 --- a/libtransmission/peer-mgr.c +++ b/libtransmission/peer-mgr.c @@ -47,20 +47,18 @@ enum { for this many calls to rechokeUploads(). */ OPTIMISTIC_UNCHOKE_MULTIPLIER = 4, /* how frequently to reallocate bandwidth */ - BANDWIDTH_PERIOD_MSEC = 500, + BANDWIDTH_PERIOD_MSEC = 250, /* how frequently to age out old piece request lists */ REFILL_UPKEEP_PERIOD_MSEC = (10 * 1000), - /* how frequently to decide which peers live and die */ - RECONNECT_PERIOD_MSEC = 500, /* when many peers are available, keep idle ones this long */ MIN_UPLOAD_IDLE_SECS = (60), /* when few peers are available, keep idle ones this long */ MAX_UPLOAD_IDLE_SECS = (60 * 5), /* max number of peers to ask for per second overall. * this throttle is to avoid overloading the router */ - MAX_CONNECTIONS_PER_SECOND = 12, + MAX_CONNECTIONS_PER_SECOND = 32, /* */ - MAX_CONNECTIONS_PER_PULSE = (int)(MAX_CONNECTIONS_PER_SECOND * (RECONNECT_PERIOD_MSEC / 1000.0)), + MAX_CONNECTIONS_PER_PULSE = (int)(MAX_CONNECTIONS_PER_SECOND * (BANDWIDTH_PERIOD_MSEC / 1000.0)), /* number of bad pieces a peer is allowed to send before we ban them */ MAX_BAD_PIECES_PER_PEER = 5, /* amount of time to keep a list of request pieces lying around @@ -74,8 +72,12 @@ enum { MYFLAG_UNREACHABLE = 2, /* the minimum we'll wait before attempting to reconnect to a peer */ MINIMUM_RECONNECT_INTERVAL_SECS = 5, + /* regular wait before attempting to reconnect to a peer (increases with each failure) */ + RECONNECT_INTERVAL_SECS = 60, + /* the maximum we'll wait before attempting to reconnect to a peer */ + MAXIMUM_RECONNECT_INTERVAL_SECS = 600, /** how long we'll let requests we've made linger before we cancel them */ - REQUEST_TTL_SECS = 90, + REQUEST_TTL_SECS = 60, /* */ NO_BLOCKS_CANCEL_HISTORY = 120, /* */ @@ -3174,24 +3176,8 @@ static int getReconnectIntervalSecs(struct peer_atom const *atom, time_t const n sec = 10; break; - case 2: - sec = 60 * 2; - break; - - case 3: - sec = 60 * 15; - break; - - case 4: - sec = 60 * 30; - break; - - case 5: - sec = 60 * 60; - break; - default: - sec = 60 * 120; + sec = MIN(RECONNECT_INTERVAL_SECS * step, MAXIMUM_RECONNECT_INTERVAL_SECS); break; } } diff --git a/libtransmission/peer-msgs.c b/libtransmission/peer-msgs.c index 631154caa98..f82be319d23 100644 --- a/libtransmission/peer-msgs.c +++ b/libtransmission/peer-msgs.c @@ -72,8 +72,8 @@ enum { KEEPALIVE_INTERVAL_SECS = 100, /* */ PEX_INTERVAL_SECS = 90, /* sec between sendPex() calls */ - /* */ - REQQ = 512, + /* https://github.com/arvidn/libtorrent/blob/2ab8fedabb7716947edc77958da6d0b5e1040df9/src/settings_pack.cpp#L254 */ + REQQ = 2000, /* */ METADATA_REQQ = 64, /* */