increase the replenish frequency to occur every .1s

logging
This commit is contained in:
jrandom
2004-07-27 17:20:42 +00:00
committed by zzz
parent 54aeab1524
commit 399865e6c8
4 changed files with 20 additions and 46 deletions

View File

@ -35,6 +35,8 @@ public class BandwidthLimitedOutputStream extends FilterOutputStream {
_currentRequest = null; _currentRequest = null;
} }
public FIFOBandwidthLimiter.Request getCurrentRequest() { return _currentRequest; }
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..."));

View File

@ -139,8 +139,7 @@ public class FIFOBandwidthLimiter {
_log.warn("Still denying the " + _pendingInboundRequests.size() _log.warn("Still denying the " + _pendingInboundRequests.size()
+ " pending inbound requests (available " + " pending inbound requests (available "
+ _availableInboundBytes + "/" + _availableOutboundBytes + _availableInboundBytes + "/" + _availableOutboundBytes
+ " in/out, longest waited " + locked_getLongestInboundWait() + " in/out, longest waited " + locked_getLongestInboundWait() + " in)");
+ "/" + locked_getLongestOutboundWait() + " in/out)");
} }
} }
} }
@ -169,6 +168,7 @@ public class FIFOBandwidthLimiter {
long start = -1; long start = -1;
for (int i = 0; i < _pendingOutboundRequests.size(); i++) { for (int i = 0; i < _pendingOutboundRequests.size(); i++) {
SimpleRequest req = (SimpleRequest)_pendingOutboundRequests.get(i); SimpleRequest req = (SimpleRequest)_pendingOutboundRequests.get(i);
if (req == null) continue;
if ( (start < 0) || (start > req.getRequestTime()) ) if ( (start < 0) || (start > req.getRequestTime()) )
start = req.getRequestTime(); start = req.getRequestTime();
} }
@ -257,8 +257,7 @@ public class FIFOBandwidthLimiter {
+ req.getTotalInboundRequested() + " bytes, waited " + req.getTotalInboundRequested() + " bytes, waited "
+ waited + waited
+ "ms) pending " + _pendingInboundRequests.size() + "ms) pending " + _pendingInboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait() + ", longest waited " + locked_getLongestInboundWait() + " in");
+ "/" + 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 "
@ -266,8 +265,7 @@ public class FIFOBandwidthLimiter {
+ req.getTotalInboundRequested() + " bytes, waited " + req.getTotalInboundRequested() + " bytes, waited "
+ waited + waited
+ "ms) pending " + _pendingInboundRequests.size() + "ms) pending " + _pendingInboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait() + ", longest waited " + locked_getLongestInboundWait() + " out");
+ "/" + locked_getLongestOutboundWait() + " in/out");
_pendingInboundRequests.remove(i); _pendingInboundRequests.remove(i);
i--; i--;
if (waited > 10) if (waited > 10)
@ -291,8 +289,7 @@ public class FIFOBandwidthLimiter {
_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() + "longest waited " + locked_getLongestOutboundWait() + " out)");
+ "/" + locked_getLongestOutboundWait() + " in/out)");
} }
} }
} }
@ -326,8 +323,7 @@ public class FIFOBandwidthLimiter {
+ req.getTotalOutboundRequested() + " bytes (waited " + req.getTotalOutboundRequested() + " bytes (waited "
+ waited + waited
+ "ms) pending " + _pendingOutboundRequests.size() + "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait() + ", longest waited " + locked_getLongestOutboundWait() + " out");
+ "/" + locked_getLongestOutboundWait() + " in/out");
if (waited > 10) if (waited > 10)
_context.statManager().addRateData("bwLimiter.outboundDelayedTime", waited, waited); _context.statManager().addRateData("bwLimiter.outboundDelayedTime", waited, waited);
} }
@ -386,8 +382,7 @@ public class FIFOBandwidthLimiter {
+ req.getTotalOutboundRequested() + " bytes, waited " + req.getTotalOutboundRequested() + " bytes, waited "
+ waited + waited
+ "ms) pending " + _pendingOutboundRequests.size() + "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait() + ", longest waited " + locked_getLongestOutboundWait() + " out");
+ "/" + 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 "
@ -395,8 +390,7 @@ public class FIFOBandwidthLimiter {
+ req.getTotalOutboundRequested() + " bytes, waited " + req.getTotalOutboundRequested() + " bytes, waited "
+ waited + waited
+ "ms) pending " + _pendingOutboundRequests.size() + "ms) pending " + _pendingOutboundRequests.size()
+ ", longest waited " + locked_getLongestInboundWait() + ", longest waited " + locked_getLongestOutboundWait() + " out)");
+ "/" + locked_getLongestOutboundWait() + " in/out)");
_pendingOutboundRequests.remove(i); _pendingOutboundRequests.remove(i);
i--; i--;
if (waited > 10) if (waited > 10)

View File

@ -24,7 +24,7 @@ class FIFOBandwidthRefiller implements Runnable {
public static final String PROP_OUTBOUND_BANDWIDTH = "i2np.bandwidth.outboundKBytesPerSecond"; public static final String PROP_OUTBOUND_BANDWIDTH = "i2np.bandwidth.outboundKBytesPerSecond";
public static final String PROP_INBOUND_BANDWIDTH_PEAK = "i2np.bandwidth.inboundBurstKBytes"; public static final String PROP_INBOUND_BANDWIDTH_PEAK = "i2np.bandwidth.inboundBurstKBytes";
public static final String PROP_OUTBOUND_BANDWIDTH_PEAK = "i2np.bandwidth.outboundBurstKBytes"; public static final String PROP_OUTBOUND_BANDWIDTH_PEAK = "i2np.bandwidth.outboundBurstKBytes";
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 = 1; public static final int MIN_INBOUND_BANDWIDTH = 1;
@ -35,9 +35,9 @@ class FIFOBandwidthRefiller implements Runnable {
/** 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 = 1; 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 = 100;
private static final long DEFAULT_REPLENISH_FREQUENCY = 1*1000; private static final long DEFAULT_REPLENISH_FREQUENCY = 100;
public FIFOBandwidthRefiller(I2PAppContext context, FIFOBandwidthLimiter limiter) { public FIFOBandwidthRefiller(I2PAppContext context, FIFOBandwidthLimiter limiter) {
_limiter = limiter; _limiter = limiter;
@ -79,9 +79,9 @@ class FIFOBandwidthRefiller implements Runnable {
+ _limiter.getAvailableOutboundBytes()+ ", rate in=" + _limiter.getAvailableOutboundBytes()+ ", rate in="
+ _inboundKBytesPerSecond + ", out=" + _inboundKBytesPerSecond + ", out="
+ _outboundKBytesPerSecond +")"); + _outboundKBytesPerSecond +")");
if (numMs >= 1000) { if (numMs >= MIN_REPLENISH_FREQUENCY) {
long inboundToAdd = 1024*_inboundKBytesPerSecond * (numMs/1000); long inboundToAdd = (1024*_inboundKBytesPerSecond * numMs)/1000;
long outboundToAdd = 1024*_outboundKBytesPerSecond * (numMs/1000); long outboundToAdd = (1024*_outboundKBytesPerSecond * numMs)/1000;
if (inboundToAdd < 0) inboundToAdd = 0; if (inboundToAdd < 0) inboundToAdd = 0;
if (outboundToAdd < 0) outboundToAdd = 0; if (outboundToAdd < 0) outboundToAdd = 0;
@ -118,8 +118,9 @@ class FIFOBandwidthRefiller implements Runnable {
updateOutboundRate(); updateOutboundRate();
updateInboundPeak(); updateInboundPeak();
updateOutboundPeak(); updateOutboundPeak();
updateReplenishFrequency();
_replenishFrequency = DEFAULT_REPLENISH_FREQUENCY;
if (_inboundKBytesPerSecond <= 0) { if (_inboundKBytesPerSecond <= 0) {
_limiter.setInboundUnlimited(true); _limiter.setInboundUnlimited(true);
} else { } else {
@ -240,27 +241,4 @@ class FIFOBandwidthRefiller implements Runnable {
} }
} }
private void updateReplenishFrequency() {
String freqMs = _context.getProperty(PROP_REPLENISH_FREQUENCY);
if ( (freqMs != null) &&
(freqMs.trim().length() > 0) &&
(!(freqMs.equals(String.valueOf(_replenishFrequency)))) ) {
// frequency was specified *and* changed
try {
long ms = Long.parseLong(freqMs);
if (ms >= MIN_REPLENISH_FREQUENCY)
_replenishFrequency = ms;
else
_replenishFrequency = MIN_REPLENISH_FREQUENCY;
} catch (NumberFormatException nfe) {
if (_log.shouldLog(Log.WARN))
_log.warn("Invalid replenish frequency [" + freqMs
+ "]");
}
} else {
if (_log.shouldLog(Log.DEBUG))
_log.debug("Replenish frequency not specified in the config via " + PROP_REPLENISH_FREQUENCY);
_replenishFrequency = DEFAULT_REPLENISH_FREQUENCY;
}
}
} }

View File

@ -76,12 +76,12 @@ public abstract class TransportImpl implements Transport {
if (lifetime > 5000) { if (lifetime > 5000) {
if (_log.shouldLog(Log.WARN)) if (_log.shouldLog(Log.WARN))
_log.warn("afterSend: [success=" + sendSuccessful + "]" + msg.getMessageSize() + "byte " _log.warn("afterSend: [success=" + sendSuccessful + "]" + msg.getMessageSize() + "byte "
+ msg.getMessageType() + " from " + _context.routerHash().toBase64().substring(0,6) + msg.getMessageType() + " " + msg.getMessageId() + " from " + _context.routerHash().toBase64().substring(0,6)
+ " to " + msg.getTarget().getIdentity().calculateHash().toBase64().substring(0,6) + "\n" + msg.toString()); + " 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 + "]" + msg.getMessageSize() + "byte " _log.info("afterSend: [success=" + sendSuccessful + "]" + msg.getMessageSize() + "byte "
+ msg.getMessageType() + " from " + _context.routerHash().toBase64().substring(0,6) + msg.getMessageType() + " " + msg.getMessageId() + " from " + _context.routerHash().toBase64().substring(0,6)
+ " to " + msg.getTarget().getIdentity().calculateHash().toBase64().substring(0,6) + "\n" + msg.toString()); + " to " + msg.getTarget().getIdentity().calculateHash().toBase64().substring(0,6) + "\n" + msg.toString());
} }