From 0428726e300fb2becd2e26e878d45fd8f2a369da Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Fri, 10 Oct 2008 17:27:23 +0000 Subject: [PATCH] * Profiles: Reduce reject penalty in capacity calculation to avoid a congestion collapse --- .../i2p/router/peermanager/CapacityCalculator.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/router/java/src/net/i2p/router/peermanager/CapacityCalculator.java b/router/java/src/net/i2p/router/peermanager/CapacityCalculator.java index d92e8b49ba..87d13c16e2 100644 --- a/router/java/src/net/i2p/router/peermanager/CapacityCalculator.java +++ b/router/java/src/net/i2p/router/peermanager/CapacityCalculator.java @@ -100,6 +100,13 @@ public class CapacityCalculator extends Calculator { long eventCount = 0; if (curAccepted != null) eventCount = curAccepted.getCurrentEventCount() + curAccepted.getLastEventCount(); + // Punish for rejections. + // We don't want to simply do eventCount -= rejected or we get to zero with 50% rejection, + // and we don't want everybody to be at zero during times of congestion. + if (eventCount > 0) { + long rejected = curRejected.getCurrentEventCount() + curRejected.getLastEventCount(); + eventCount = eventCount * eventCount / (eventCount + rejected); + } double stretch = ((double)ESTIMATE_PERIOD) / period; double val = eventCount * stretch; long failed = 0; @@ -116,12 +123,6 @@ public class CapacityCalculator extends Calculator { val -= failed * stretch; } - //if ( (period <= 10*60*1000) && (curRejected.getCurrentEventCount() + curRejected.getLastEventCount() > 0) ) { - // //System.out.println("10m period has rejected " + (curRejected.getCurrentEventCount() + curRejected.getLastEventCount()) + " times"); - // return 0.0d; - //} else - val -= stretch * (curRejected.getCurrentEventCount() + curRejected.getLastEventCount()); - val += GROWTH_FACTOR; if (val >= 0) { -- GitLab