GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Reset busy counters after triggering an auto-scale-up decision · netty/netty@25c8c2c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • common/src/main/java/io/netty/util/concurrent
    • AutoScalingEventExecutorChooserFactory.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎common/src/main/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactory.java‎

Copy file name to clipboardExpand all lines: common/src/main/java/io/netty/util/concurrent/AutoScalingEventExecutorChooserFactory.java
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ public List<AutoScalingUtilizationMetric> executorUtilizations() {
267267

268268
private final class UtilizationMonitor implements Runnable {
269269
private final List<SingleThreadEventExecutor> consistentlyIdleChildren = new ArrayList<>(maxChildren);
270+
private final List<SingleThreadEventExecutor> consistentlyBusyChildren = new ArrayList<>(maxChildren);
270271
private long lastCheckTimeNanos;
271272

272273
@Override
@@ -297,8 +298,8 @@ public void run() {
297298
return;
298299
}
299300

300-
int consistentlyBusyChildren = 0;
301301
consistentlyIdleChildren.clear();
302+
consistentlyBusyChildren.clear();
302303

303304
final AutoScalingState currentState = state.get();
304305

@@ -341,7 +342,7 @@ public void run() {
341342
int busyCycles = eventExecutor.getAndIncrementBusyCycles();
342343
eventExecutor.resetIdleCycles();
343344
if (busyCycles >= scalingPatienceCycles) {
344-
consistentlyBusyChildren++;
345+
consistentlyBusyChildren.add(eventExecutor);
345346
}
346347
} else {
347348
// Utilization is in the normal range, reset counters.
@@ -356,11 +357,17 @@ public void run() {
356357
int currentActive = currentState.activeChildrenCount;
357358

358359
// Make scaling decisions based on stable states.
359-
if (consistentlyBusyChildren > 0 && currentActive < maxChildren) {
360+
if (!consistentlyBusyChildren.isEmpty() && currentActive < maxChildren) {
360361
// Scale Up, we have children that have been busy for multiple cycles.
361-
int threadsToAdd = Math.min(consistentlyBusyChildren, maxRampUpStep);
362+
int threadsToAdd = Math.min(consistentlyBusyChildren.size(), maxRampUpStep);
362363
threadsToAdd = Math.min(threadsToAdd, maxChildren - currentActive);
363364
if (threadsToAdd > 0) {
365+
// Reset the counters of the children that justified this decision so that they need
366+
// another full patience period of sustained load before triggering a further scale-up.
367+
for (SingleThreadEventExecutor busyChild : consistentlyBusyChildren) {
368+
busyChild.resetBusyCycles();
369+
busyChild.resetIdleCycles();
370+
}
364371
tryScaleUpBy(threadsToAdd);
365372
// State change is handled by tryScaleUpBy, no need for rebuild here.
366373
return; // Exit to avoid conflicting scale down logic in the same cycle.

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.