I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 43c18d0f authored by jrandom's avatar jrandom Committed by zzz
Browse files

(techincally) reduced the minimum bandwidth rate to 1KBps, but NO ONE SHOULD...

(techincally) reduced the minimum bandwidth rate to 1KBps, but NO ONE SHOULD SET IT THAT LOW.  do not reduce your limits below 6KBps until More Stuff Gets Done.
logging
parent 65d85f74
No related branches found
No related tags found
No related merge requests found
......@@ -38,9 +38,13 @@ public class BandwidthLimitedOutputStream extends FilterOutputStream {
public void write(int val) throws IOException {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Writing a single byte!", new Exception("Single byte from..."));
long before = _context.clock().now();
FIFOBandwidthLimiter.Request req = _context.bandwidthLimiter().requestOutbound(1, _peerTarget);
// only a single byte, no need to loop
req.waitForNextAllocation();
long waited = _context.clock().now() - before;
if ( (waited > 1000) && (_log.shouldLog(Log.WARN)) )
_log.warn("Waiting to write a byte took too long [" + waited + "ms");
out.write(val);
}
public void write(byte src[]) throws IOException {
......@@ -65,6 +69,7 @@ public class BandwidthLimitedOutputStream extends FilterOutputStream {
out.write(src, off + written, toWrite);
} catch (IOException ioe) {
_currentRequest.abort();
_currentRequest = null;
throw ioe;
}
written += toWrite;
......
......@@ -138,7 +138,9 @@ public class FIFOBandwidthLimiter {
if (_log.shouldLog(Log.WARN))
_log.warn("Still denying the " + _pendingInboundRequests.size()
+ " pending inbound requests (available "
+ _availableInboundBytes + "/" + _availableOutboundBytes + " in/out)");
+ _availableInboundBytes + "/" + _availableOutboundBytes
+ " in/out, longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out)");
}
}
}
......@@ -151,6 +153,31 @@ public class FIFOBandwidthLimiter {
}
}
private long locked_getLongestInboundWait() {
long start = -1;
for (int i = 0; i < _pendingInboundRequests.size(); i++) {
SimpleRequest req = (SimpleRequest)_pendingInboundRequests.get(i);
if ( (start < 0) || (start > req.getRequestTime()) )
start = req.getRequestTime();
}
if (start == -1)
return 0;
else
return _context.clock().now() - start;
}
private long locked_getLongestOutboundWait() {
long start = -1;
for (int i = 0; i < _pendingOutboundRequests.size(); i++) {
SimpleRequest req = (SimpleRequest)_pendingOutboundRequests.get(i);
if ( (start < 0) || (start > req.getRequestTime()) )
start = req.getRequestTime();
}
if (start == -1)
return 0;
else
return _context.clock().now() - start;
}
/**
* There are no limits, so just give every inbound request whatever they want
*
......@@ -229,14 +256,18 @@ public class FIFOBandwidthLimiter {
+ req.getRequestName() + " (wanted "
+ req.getTotalInboundRequested() + " bytes, waited "
+ waited
+ "ms) pending " + _pendingInboundRequests.size());
+ "ms) pending " + _pendingInboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out");
} else {
if (_log.shouldLog(Log.INFO))
_log.info("Allocating " + allocated + " bytes inbound to finish the partial grant to "
+ req.getRequestName() + " (total "
+ req.getTotalInboundRequested() + " bytes, waited "
+ waited
+ "ms) pending " + _pendingInboundRequests.size());
+ "ms) pending " + _pendingInboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out");
_pendingInboundRequests.remove(i);
i--;
if (waited > 10)
......@@ -259,7 +290,9 @@ public class FIFOBandwidthLimiter {
if (_log.shouldLog(Log.WARN))
_log.warn("Still denying the " + _pendingOutboundRequests.size()
+ " pending outbound requests (available "
+ _availableInboundBytes + "/" + _availableOutboundBytes + " in/out)");
+ _availableInboundBytes + "/" + _availableOutboundBytes + " in/out, "
+ "longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out)");
}
}
}
......@@ -292,7 +325,9 @@ public class FIFOBandwidthLimiter {
_log.info("Granting outbound request " + req.getRequestName() + " fully for "
+ req.getTotalOutboundRequested() + " bytes (waited "
+ waited
+ "ms) pending " + _pendingOutboundRequests.size());
+ "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out");
if (waited > 10)
_context.statManager().addRateData("bwLimiter.outboundDelayedTime", waited, waited);
}
......@@ -350,14 +385,18 @@ public class FIFOBandwidthLimiter {
+ req.getRequestName() + " (wanted "
+ req.getTotalOutboundRequested() + " bytes, waited "
+ waited
+ "ms) pending " + _pendingOutboundRequests.size());
+ "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out");
} else {
if (_log.shouldLog(Log.INFO))
_log.info("Allocating " + allocated + " bytes outbound to finish the partial grant to "
+ req.getRequestName() + " (total "
+ req.getTotalOutboundRequested() + " bytes, waited "
+ waited
+ "ms) pending " + _pendingOutboundRequests.size());
+ "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out)");
_pendingOutboundRequests.remove(i);
i--;
if (waited > 10)
......
......@@ -27,13 +27,13 @@ class FIFOBandwidthRefiller implements Runnable {
public static final String PROP_REPLENISH_FREQUENCY = "i2np.bandwidth.replenishFrequencyMs";
/** For now, until there is some tuning and safe throttling, we set the floor at 6KBps inbound */
public static final int MIN_INBOUND_BANDWIDTH = 6;
public static final int MIN_INBOUND_BANDWIDTH = 1;
/** For now, until there is some tuning and safe throttling, we set the floor at 6KBps outbound */
public static final int MIN_OUTBOUND_BANDWIDTH = 6;
public static final int MIN_OUTBOUND_BANDWIDTH = 1;
/** For now, until there is some tuning and safe throttling, we set the floor at a 10 second burst */
public static final int MIN_INBOUND_BANDWIDTH_PEAK = 6;
public static final int MIN_INBOUND_BANDWIDTH_PEAK = 1;
/** For now, until there is some tuning and safe throttling, we set the floor at a 10 second burst */
public static final int MIN_OUTBOUND_BANDWIDTH_PEAK = 6;
public static final int MIN_OUTBOUND_BANDWIDTH_PEAK = 1;
/** Updating the bandwidth more than once a second is silly. once every 2 or 5 seconds is less so. */
public static final long MIN_REPLENISH_FREQUENCY = 1000;
......@@ -107,6 +107,8 @@ class FIFOBandwidthRefiller implements Runnable {
}
return true;
} else {
if (_log.shouldLog(Log.WARN))
_log.warn("Refresh delay too fast (" + numMs + ")");
return false;
}
}
......
......@@ -75,10 +75,14 @@ public abstract class TransportImpl implements Transport {
long lifetime = msg.getLifetime();
if (lifetime > 5000) {
if (_log.shouldLog(Log.WARN))
_log.warn("afterSend: [success=" + sendSuccessful + "]\n" + msg.toString());
_log.warn("afterSend: [success=" + sendSuccessful + "]" + msg.getMessageSize() + "byte "
+ msg.getMessageType() + " from " + _context.routerHash().toBase64().substring(0,6)
+ " to " + msg.getTarget().getIdentity().calculateHash().toBase64().substring(0,6) + "\n" + msg.toString());
} else {
if (_log.shouldLog(Log.INFO))
_log.info("afterSend: [success=" + sendSuccessful + "]\n" + msg.toString());
_log.info("afterSend: [success=" + sendSuccessful + "]" + msg.getMessageSize() + "byte "
+ msg.getMessageType() + " from " + _context.routerHash().toBase64().substring(0,6)
+ " to " + msg.getTarget().getIdentity().calculateHash().toBase64().substring(0,6) + "\n" + msg.toString());
}
if (sendSuccessful) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment