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-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org