(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
This commit is contained in:
jrandom
2004-07-25 23:43:13 +00:00
committed by zzz
parent 65d85f7479
commit 43c18d0f4d
4 changed files with 63 additions and 13 deletions

View File

@ -38,9 +38,13 @@ public class BandwidthLimitedOutputStream extends FilterOutputStream {
public void write(int val) throws IOException { public void write(int val) throws IOException {
if (_log.shouldLog(Log.DEBUG)) if (_log.shouldLog(Log.DEBUG))
_log.debug("Writing a single byte!", new Exception("Single byte from...")); _log.debug("Writing a single byte!", new Exception("Single byte from..."));
long before = _context.clock().now();
FIFOBandwidthLimiter.Request req = _context.bandwidthLimiter().requestOutbound(1, _peerTarget); FIFOBandwidthLimiter.Request req = _context.bandwidthLimiter().requestOutbound(1, _peerTarget);
// only a single byte, no need to loop // only a single byte, no need to loop
req.waitForNextAllocation(); 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); out.write(val);
} }
public void write(byte src[]) throws IOException { public void write(byte src[]) throws IOException {
@ -65,6 +69,7 @@ public class BandwidthLimitedOutputStream extends FilterOutputStream {
out.write(src, off + written, toWrite); out.write(src, off + written, toWrite);
} catch (IOException ioe) { } catch (IOException ioe) {
_currentRequest.abort(); _currentRequest.abort();
_currentRequest = null;
throw ioe; throw ioe;
} }
written += toWrite; written += toWrite;

View File

@ -138,7 +138,9 @@ public class FIFOBandwidthLimiter {
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("Still denying the " + _pendingInboundRequests.size() _log.warn("Still denying the " + _pendingInboundRequests.size()
+ " pending inbound requests (available " + " 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 * There are no limits, so just give every inbound request whatever they want
* *
@ -229,14 +256,18 @@ public class FIFOBandwidthLimiter {
+ req.getRequestName() + " (wanted " + req.getRequestName() + " (wanted "
+ req.getTotalInboundRequested() + " bytes, waited " + req.getTotalInboundRequested() + " bytes, waited "
+ waited + waited
+ "ms) pending " + _pendingInboundRequests.size()); + "ms) pending " + _pendingInboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out");
} else { } else {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Allocating " + allocated + " bytes inbound to finish the partial grant to " _log.info("Allocating " + allocated + " bytes inbound to finish the partial grant to "
+ req.getRequestName() + " (total " + req.getRequestName() + " (total "
+ req.getTotalInboundRequested() + " bytes, waited " + req.getTotalInboundRequested() + " bytes, waited "
+ waited + waited
+ "ms) pending " + _pendingInboundRequests.size()); + "ms) pending " + _pendingInboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out");
_pendingInboundRequests.remove(i); _pendingInboundRequests.remove(i);
i--; i--;
if (waited > 10) if (waited > 10)
@ -259,7 +290,9 @@ public class FIFOBandwidthLimiter {
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("Still denying the " + _pendingOutboundRequests.size() _log.warn("Still denying the " + _pendingOutboundRequests.size()
+ " pending outbound requests (available " + " 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 " _log.info("Granting outbound request " + req.getRequestName() + " fully for "
+ req.getTotalOutboundRequested() + " bytes (waited " + req.getTotalOutboundRequested() + " bytes (waited "
+ waited + waited
+ "ms) pending " + _pendingOutboundRequests.size()); + "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out");
if (waited > 10) if (waited > 10)
_context.statManager().addRateData("bwLimiter.outboundDelayedTime", waited, waited); _context.statManager().addRateData("bwLimiter.outboundDelayedTime", waited, waited);
} }
@ -350,14 +385,18 @@ public class FIFOBandwidthLimiter {
+ req.getRequestName() + " (wanted " + req.getRequestName() + " (wanted "
+ req.getTotalOutboundRequested() + " bytes, waited " + req.getTotalOutboundRequested() + " bytes, waited "
+ waited + waited
+ "ms) pending " + _pendingOutboundRequests.size()); + "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out");
} else { } else {
if (_log.shouldLog(Log.INFO)) if (_log.shouldLog(Log.INFO))
_log.info("Allocating " + allocated + " bytes outbound to finish the partial grant to " _log.info("Allocating " + allocated + " bytes outbound to finish the partial grant to "
+ req.getRequestName() + " (total " + req.getRequestName() + " (total "
+ req.getTotalOutboundRequested() + " bytes, waited " + req.getTotalOutboundRequested() + " bytes, waited "
+ waited + waited
+ "ms) pending " + _pendingOutboundRequests.size()); + "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait()
+ "/" + locked_getLongestOutboundWait() + " in/out)");
_pendingOutboundRequests.remove(i); _pendingOutboundRequests.remove(i);
i--; i--;
if (waited > 10) if (waited > 10)

View File

@ -27,13 +27,13 @@ class FIFOBandwidthRefiller implements Runnable {
public static final String PROP_REPLENISH_FREQUENCY = "i2np.bandwidth.replenishFrequencyMs"; 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 */ /** 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 */ /** 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 */ /** 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 */ /** 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. */ /** 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; public static final long MIN_REPLENISH_FREQUENCY = 1000;
@ -107,6 +107,8 @@ class FIFOBandwidthRefiller implements Runnable {
} }
return true; return true;
} else { } else {
if (_log.shouldLog(Log.WARN))
_log.warn("Refresh delay too fast (" + numMs + ")");
return false; return false;
} }
} }

View File

@ -75,10 +75,14 @@ public abstract class TransportImpl implements Transport {
long lifetime = msg.getLifetime(); long lifetime = msg.getLifetime();
if (lifetime > 5000) { if (lifetime > 5000) {
if (_log.shouldLog(Log.WARN)) 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 { } else {
if (_log.shouldLog(Log.INFO)) 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) { if (sendSuccessful) {