Streaming:

Fix the window size increment logic so it does it much more often.
The code increased the window size by MSS * MSS / N, like
in RFC 2581, but it did it only once every N,
so that was like MSS * MSS / N**2.
Now do it all the time, except for isolated packets like keepalives
that aren't using more than one message of the window.
Seems to speed up outbound significantly, without any
noticable increase in stream.sendsBeforeAck.
This commit is contained in:
zzz
2010-04-10 15:42:08 +00:00
parent 70e9cf5838
commit 8b6751f419
4 changed files with 44 additions and 7 deletions

View File

@@ -386,8 +386,10 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
private static final double RTT_DAMPENING = 0.875;
public void updateRTT(int measuredValue) {
// the rttDev calculation matches that recommended in RFC 2988 (beta = 1/4)
_rttDev = _rttDev + (int)(0.25d*(Math.abs(measuredValue-_rtt)-_rttDev));
int smoothed = (int)(RTT_DAMPENING*_rtt + (1-RTT_DAMPENING)*measuredValue);
// K = 4
_rto = smoothed + (_rttDev<<2);
if (_rto < Connection.MIN_RESEND_DELAY)
_rto = (int)Connection.MIN_RESEND_DELAY;

View File

@@ -328,7 +328,19 @@ public class ConnectionPacketHandler {
}
long lowest = con.getHighestAckedThrough();
if (lowest >= con.getCongestionWindowEnd()) {
// RFC 2581
// Why wait until we get a whole cwin to start updating the window?
// That means we don't start increasing the window until after 1 RTT.
// And whether we increase the window or not (probably not since 1/N),
// we reset the CongestionWindowEnd and have to wait another RTT.
// So we add the acked > 1 and UnackedPacketsSent > 0 cases,
// so we almost always go through the window adjustment code,
// unless we're just sending a single packet now and then.
// This keeps the window size from going sky-high from ping traffic alone.
// Since we don't adjust the window down after idle? (RFC 2581 sec. 4.1)
if (lowest >= con.getCongestionWindowEnd() ||
acked > 1 ||
con.getUnackedPacketsSent() > 0) {
// new packet that ack'ed uncongested data, or an empty ack
int oldWindow = con.getOptions().getWindowSize();
int newWindowSize = oldWindow;
@@ -352,11 +364,12 @@ public class ConnectionPacketHandler {
newWindowSize += acked / factor;
if (_log.shouldLog(Log.DEBUG))
_log.debug("slow start acks = " + acked + " for " + con);
} else if (trend < 0) {
// rtt is shrinking, so lets increment the cwin
newWindowSize++;
if (_log.shouldLog(Log.DEBUG))
_log.debug("trend < 0 for " + con);
// this is too fast since we mostly disabled the CongestionWindowEnd test above
//} else if (trend < 0) {
// // rtt is shrinking, so lets increment the cwin
// newWindowSize++;
// if (_log.shouldLog(Log.DEBUG))
// _log.debug("trend < 0 for " + con);
} else {
// congestion avoidance
// linear growth - increase window 1/N per RTT
@@ -368,6 +381,10 @@ public class ConnectionPacketHandler {
if (_log.shouldLog(Log.DEBUG))
_log.debug("cong. avoid acks = " + acked + " for " + con);
}
} else {
if (_log.shouldLog(Log.DEBUG))
_log.debug("No change to window: " + con.getOptions().getWindowSize() +
" congested? " + congested + " acked: " + acked + " resends: " + numResends);
}
if (newWindowSize <= 0)
@@ -380,6 +397,11 @@ public class ConnectionPacketHandler {
_log.debug("New window size " + newWindowSize + "/" + oldWindow + "/" + con.getOptions().getWindowSize() + " congestionSeenAt: "
+ con.getLastCongestionSeenAt() + " (#resends: " + numResends
+ ") for " + con);
} else {
if (_log.shouldLog(Log.DEBUG))
_log.debug("No change to window: " + con.getOptions().getWindowSize() +
" highestAckedThrough: " + lowest + " congestionWindowEnd: " + con.getCongestionWindowEnd() +
" acked: " + acked + " unacked: " + con.getUnackedPacketsSent());
}
con.windowAdjusted();