Tunnels: Limit requested client tunnels during congestion

This will probably also reduce builds at startup.
Limits may require tweaks after further testing.
This commit is contained in:
zzz
2022-12-29 12:07:48 -05:00
parent 32ffd056a1
commit dcb8009c63
3 changed files with 22 additions and 3 deletions

View File

@@ -1,3 +1,6 @@
2022-12-29 zzz
* Tunnels: Limit requested client tunnels during congestion
2022-12-26 zzz 2022-12-26 zzz
* Console: Sort tunnels by name on /tunnels, /configtunnels, /i2ptunnel * Console: Sort tunnels by name on /tunnels, /configtunnels, /i2ptunnel
* Router: Don't blocklist our own IP * Router: Don't blocklist our own IP

View File

@@ -18,10 +18,10 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Git"; public final static String ID = "Git";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 12; public final static long BUILD = 13;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "-rc";
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
public static void main(String args[]) { public static void main(String args[]) {
System.out.println("I2P Router version: " + FULL_VERSION); System.out.println("I2P Router version: " + FULL_VERSION);

View File

@@ -332,8 +332,24 @@ public class TunnelPool {
if (_settings.getLength() == 0 && _settings.getLengthVariance() == 0) if (_settings.getLength() == 0 && _settings.getLengthVariance() == 0)
return 1; return 1;
int rv = _settings.getTotalQuantity(); int rv = _settings.getTotalQuantity();
if (!_settings.isExploratory()) if (!_settings.isExploratory()) {
if (rv <= 1)
return rv; return rv;
// throttle client tunnel builds in times of congestion
int fails = _consecutiveBuildTimeouts.get();
if (fails > 4) {
if (fails > 8) {
rv = 1;
if (_log.shouldWarn())
_log.warn("Limit to 1 tunnel after " + fails + " consec. build timeouts on " + this);
} else if (rv > 2) {
rv--;
if (_log.shouldWarn())
_log.warn("Limit to " + rv + " tunnels after " + fails + " consec. build timeouts on " + this);
}
}
return rv;
}
// TODO high-bw non-ff also // TODO high-bw non-ff also
if (_context.netDb().floodfillEnabled() && if (_context.netDb().floodfillEnabled() &&
_context.router().getUptime() > 5*60*1000) { _context.router().getUptime() > 5*60*1000) {