You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "rkhachatryan (via GitHub)" <gi...@apache.org> on 2023/02/21 08:48:21 UTC

[GitHub] [flink] rkhachatryan commented on a diff in pull request #21981: [FLINK-21450][runtime] Support LocalRecovery by AdaptiveScheduler

rkhachatryan commented on code in PR #21981:
URL: https://github.com/apache/flink/pull/21981#discussion_r1112741455


##########
flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/adaptive/allocator/SlotSharingSlotAllocator.java:
##########
@@ -121,16 +133,13 @@ public Optional<VertexParallelismWithSlotSharing> determineParallelism(
                             slotSharingGroupParallelism.get(
                                     slotSharingGroup.getSlotSharingGroupId()));
 
-            final Iterable<ExecutionSlotSharingGroup> sharedSlotToVertexAssignment =
+            final List<ExecutionSlotSharingGroup> sharedSlotToVertexAssignment =
                     createExecutionSlotSharingGroups(vertexParallelism);
 
-            for (ExecutionSlotSharingGroup executionSlotSharingGroup :
-                    sharedSlotToVertexAssignment) {
-                final SlotInfo slotInfo = slotIterator.next();
-
-                assignments.add(
-                        new ExecutionSlotSharingGroupAndSlot(executionSlotSharingGroup, slotInfo));
-            }
+            SlotAssigner.AssignmentResult result =
+                    slotAssigner.assignSlots(freeSlots, sharedSlotToVertexAssignment);
+            assignments.addAll(result.assignments);
+            freeSlots = result.remainingSlots;

Review Comment:
   Because `assignSlots` is called in a loop, and internally iterates over the `freeSlots`, the complexity here is suboptimal. Lower-priority slots are added over and over into the queue inside `assignSlots`, resulting in quadratic complexity.
   
   I was thinking about making free slots part of `SlotAssigner` state (passed into constructor).
   
   WDYT @dmvk ?



-- 
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-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org