Skip to content

Commit

Permalink
use queueSize in Gradient2Limit only when latencies are low
Browse files Browse the repository at this point in the history
  • Loading branch information
udaysagar2177 committed Aug 1, 2019
1 parent f7aec2c commit cc849e0
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,12 @@ private Gradient2Limit(Builder builder) {

@Override
public int _update(final long startTime, final long rtt, final int inflight, final boolean didDrop) {
final double queueSize = this.queueSize.apply((int)this.estimatedLimit);

this.lastRtt = rtt;
final double shortRtt = (double)rtt;
final double longRtt = this.longRtt.add(rtt).doubleValue();

shortRttSampleListener.addSample(shortRtt);
longRttSampleListener.addSample(longRtt);
queueSizeSampleListener.addSample(queueSize);

// If the long RTT is substantially larger than the short RTT then reduce the long RTT measurement.
// This can happen when latency returns to normal after a prolonged prior of excessive load. Reducing the
Expand All @@ -286,9 +283,14 @@ public int _update(final long startTime, final long rtt, final int inflight, fin
final double gradient = didDrop ? 0.5
: Math.max(0.5, Math.min(1.0, tolerance * longRtt / shortRtt));

// Don't grow the limit if not necessary
if (gradient == 1.0 && inflight < estimatedLimit / 2) {
return (int) estimatedLimit;
double queueSize = 0;
if (gradient == 1.0) {
if (inflight < estimatedLimit / 2) {
// Don't grow the limit if not necessary
return (int) estimatedLimit;
}
queueSize = this.queueSize.apply((int)this.estimatedLimit);
queueSizeSampleListener.addSample(queueSize);
}

double newLimit = estimatedLimit * gradient + queueSize;
Expand Down

0 comments on commit cc849e0

Please sign in to comment.