Fly-Style commented on code in PR #18860:
URL: https://github.com/apache/druid/pull/18860#discussion_r2655001988


##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/SeekableStreamSupervisor.java:
##########
@@ -3428,6 +3442,17 @@ private void checkTaskDuration() throws 
ExecutionException, InterruptedException
       // remove this task group from the list of current task groups now that 
it has been handled
       activelyReadingTaskGroups.remove(groupId);
     }
+
+    if (taskAutoScaler != null && activelyReadingTaskGroups.isEmpty()) {

Review Comment:
   done!



##########
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/supervisor/autoscaler/CostBasedAutoScaler.java:
##########
@@ -204,50 +179,46 @@ public int computeOptimalTaskCount(CostMetrics metrics)
       return -1;
     }
 
-    // If idle is already in the ideal range [0.2, 0.6], optimal utilization 
has been achieved.
-    // No scaling is needed - maintain stability by staying at the current 
task count.
-    final double currentIdleRatio = metrics.getPollIdleRatio();
-    if (currentIdleRatio >= 0 && 
WeightedCostFunction.isIdleInIdealRange(currentIdleRatio)) {
-      log.debug(
-          "Idle ratio [%.3f] is in ideal range for supervisorId [%s], no 
scaling needed",
-          currentIdleRatio,
-          supervisorId
-      );
-      return -1;
-    }
-
     int optimalTaskCount = -1;
-    double optimalCost = Double.POSITIVE_INFINITY;
+    CostResult optimalCost = new CostResult();
 
     for (int taskCount : validTaskCounts) {
-      double cost = costFunction.computeCost(metrics, taskCount, config);
-      log.debug("Proposed task count: %d, Cost: %.4f", taskCount, cost);
-      if (cost < optimalCost) {
+      CostResult costResult = costFunction.computeCost(metrics, taskCount, 
config);
+      double cost = costResult.totalCost();
+      log.debug(
+          "Proposed task count: %d, Cost: %.4f (lag: %.4f, idle: %.4f)",
+          taskCount,
+          cost,
+          costResult.lagCost(),
+          costResult.idleCost()
+      );
+      if (cost < optimalCost.totalCost()) {
         optimalTaskCount = taskCount;
-        optimalCost = cost;
+        optimalCost = costResult;
       }
     }
 
-    emitter.emit(metricBuilder.setMetric(AVG_LAG_METRIC, 
metrics.getAvgPartitionLag()));
-    emitter.emit(metricBuilder.setMetric(AVG_IDLE_METRIC, 
metrics.getPollIdleRatio()));
     emitter.emit(metricBuilder.setMetric(OPTIMAL_TASK_COUNT_METRIC, (long) 
optimalTaskCount));
+    emitter.emit(metricBuilder.setMetric(LAG_COST_METRIC, 
optimalCost.lagCost()));
+    emitter.emit(metricBuilder.setMetric(IDLE_COST_METRIC, 
optimalCost.idleCost()));
 
     log.debug(
         "Cost-based scaling evaluation for supervisorId [%s]: current=%d, 
optimal=%d, cost=%.4f, "
         + "avgPartitionLag=%.2f, pollIdleRatio=%.3f",
         supervisorId,
         metrics.getCurrentTaskCount(),
         optimalTaskCount,
-        optimalCost,
+        optimalCost.totalCost(),
         metrics.getAvgPartitionLag(),
         metrics.getPollIdleRatio()
     );
 
+

Review Comment:
   Removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to