zentol commented on code in PR #22883:
URL: https://github.com/apache/flink/pull/22883#discussion_r1246586713
##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/allocator/SlotSharingSlotAllocator.java:
##########
@@ -78,31 +80,62 @@ public ResourceCounter calculateRequiredSlots(
return ResourceCounter.withResource(ResourceProfile.UNKNOWN,
numTotalRequiredSlots);
}
- private static Map<SlotSharingGroupId, Integer>
getMaxParallelismForSlotSharingGroups(
- Iterable<JobInformation.VertexInformation> vertices) {
- final Map<SlotSharingGroupId, Integer>
maxParallelismForSlotSharingGroups = new HashMap<>();
+ private static <T> Map<SlotSharingGroupId, T> getPerSlotSharingGroups(
+ Iterable<JobInformation.VertexInformation> vertices,
+ Function<JobInformation.VertexInformation, T> mapper,
+ BiFunction<T, T, T> reducer) {
+ final Map<SlotSharingGroupId, T> extractedPerSlotSharingGroups = new
HashMap<>();
for (JobInformation.VertexInformation vertex : vertices) {
- maxParallelismForSlotSharingGroups.compute(
+ extractedPerSlotSharingGroups.compute(
vertex.getSlotSharingGroup().getSlotSharingGroupId(),
- (slotSharingGroupId, currentMaxParallelism) ->
- currentMaxParallelism == null
- ? vertex.getParallelism()
- : Math.max(currentMaxParallelism,
vertex.getParallelism()));
+ (slotSharingGroupId, currentData) ->
+ currentData == null
+ ? mapper.apply(vertex)
+ : reducer.apply(currentData,
mapper.apply(vertex)));
}
- return maxParallelismForSlotSharingGroups;
+ return extractedPerSlotSharingGroups;
+ }
+
+ private static Map<SlotSharingGroupId, Integer>
getMinParallelismPerSlotSharingGroup(
Review Comment:
Instead of computing these metrics on-demand again and again we should
collect them all upfront in one go.
--
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]