@@ -261,15 +261,12 @@ private Gradient2Limit(Builder builder) {
261261
262262 @ Override
263263 public int _update (final long startTime , final long rtt , final int inflight , final boolean didDrop ) {
264- final double queueSize = this .queueSize .apply ((int )this .estimatedLimit );
265-
266264 this .lastRtt = rtt ;
267265 final double shortRtt = (double )rtt ;
268266 final double longRtt = this .longRtt .add (rtt ).doubleValue ();
269267
270268 shortRttSampleListener .addSample (shortRtt );
271269 longRttSampleListener .addSample (longRtt );
272- queueSizeSampleListener .addSample (queueSize );
273270
274271 // If the long RTT is substantially larger than the short RTT then reduce the long RTT measurement.
275272 // This can happen when latency returns to normal after a prolonged prior of excessive load. Reducing the
@@ -286,9 +283,14 @@ public int _update(final long startTime, final long rtt, final int inflight, fin
286283 final double gradient = didDrop ? 0.5
287284 : Math .max (0.5 , Math .min (1.0 , tolerance * longRtt / shortRtt ));
288285
286+ double queueSize = 0 ;
289287 // Don't grow the limit if not necessary
290- if (gradient == 1.0 && inflight < estimatedLimit / 2 ) {
291- return (int ) estimatedLimit ;
288+ if (gradient == 1.0 ) {
289+ if (inflight < estimatedLimit / 2 ) {
290+ return (int ) estimatedLimit ;
291+ }
292+ queueSize = this .queueSize .apply ((int )this .estimatedLimit );
293+ queueSizeSampleListener .addSample (queueSize );
292294 }
293295
294296 double newLimit = estimatedLimit * gradient + queueSize ;
0 commit comments