Skip to content

Commit fef7448

Browse files
committed
use queueSize only when latencies are low
1 parent e315b47 commit fef7448

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limit/Gradient2Limit.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)