Skip to content

Commit 1942584

Browse files
authored
Merge pull request #52 from elandau/feature/gradient_tweak
Smooth gradient limit increase
2 parents dab482a + 685aebf commit 1942584

File tree

1 file changed

+4
-4
lines changed
  • concurrency-limits-core/src/main/java/com/netflix/concurrency/limits/limit

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,14 @@ public synchronized void update(SampleWindow sample) {
270270
newLimit = estimatedLimit * gradient + queueSize;
271271
}
272272

273+
// Apply a smoothing factor when reducing the limit only
274+
newLimit = (1-smoothing) * estimatedLimit + smoothing*(newLimit);
275+
newLimit = Math.max(Math.max(minLimit, queueSize), Math.min(maxLimit, newLimit));
276+
273277
if ((int)newLimit != (int)estimatedLimit) {
274278
// Don't grow the limit because we are app limited
275279
if (sample.getMaxInFlight() < estimatedLimit / 2) {
276280
return;
277-
// Apply a smoothing factor when reducing the limit only
278-
} else if (newLimit < estimatedLimit) {
279-
newLimit = (1-smoothing) * estimatedLimit + smoothing*(newLimit);
280281
}
281282

282283
if (LOG.isDebugEnabled()) {
@@ -289,7 +290,6 @@ public synchronized void update(SampleWindow sample) {
289290
}
290291
}
291292

292-
newLimit = Math.max(Math.max(minLimit, queueSize), Math.min(maxLimit, newLimit));
293293
estimatedLimit = newLimit;
294294
}
295295

0 commit comments

Comments
 (0)