Yang-LI-CS commented on code in PR #787: URL: https://github.com/apache/flink-kubernetes-operator/pull/787#discussion_r1516370446
########## flink-autoscaler/src/main/java/org/apache/flink/autoscaler/ScalingExecutor.java: ########## @@ -153,6 +160,52 @@ public boolean scaleResource( return true; } + private void updateBiggestVertexParallelism( + Context context, + Map<JobVertexID, Map<ScalingMetric, EvaluatedScalingMetric>> evaluatedMetrics, + Map<JobVertexID, ScalingSummary> scalingSummaries) { + int taskSlotsPerTm = context.getConfiguration().get(TaskManagerOptions.NUM_TASK_SLOTS); + + Map<Integer, Set<JobVertexID>> parallelismVertexMap = new HashMap<>(); + int maxParallelism = 0; + + for (Map.Entry<JobVertexID, ScalingSummary> entry : scalingSummaries.entrySet()) { + JobVertexID vertex = entry.getKey(); + ScalingSummary summary = entry.getValue(); + int newParallelism = summary.getNewParallelism(); + + // Update maxParallelism if a new maximum is found + if (newParallelism > maxParallelism) { + maxParallelism = newParallelism; + } + + // Map newParallelism to JobVertexID + parallelismVertexMap.computeIfAbsent(newParallelism, k -> new HashSet<>()).add(vertex); + } + + // After the loop, retrieve the JobVertexIDs with the maxParallelism value + Set<JobVertexID> verticesWithMaxParallelism = + parallelismVertexMap.getOrDefault(maxParallelism, new HashSet<>()); + + // Compute the maximum parallelism for a given taskSlotsPerTm + var time = maxParallelism / taskSlotsPerTm; + if (maxParallelism > time * taskSlotsPerTm) { + maxParallelism = (time + 1) * taskSlotsPerTm; + } + + final var finalMaxNewParallelism = maxParallelism; + + scalingSummaries.forEach( + (vertexID, summary) -> { + if (verticesWithMaxParallelism.contains(vertexID)) { + // Here, you update the newParallelism for each matching JobVertexID + summary.setNewParallelism( + finalMaxNewParallelism); // Assuming setNewParallelism updates the Review Comment: Good question, it's interesting, but since I have never tested this configuration in my test, I'll stay with adjustement only for the maximum in this PR :) -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org