FrankYang0529 commented on code in PR #20000:
URL: https://github.com/apache/kafka/pull/20000#discussion_r2598805118


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/assignor/UniformHomogeneousAssignmentBuilder.java:
##########
@@ -101,6 +113,24 @@ public class UniformHomogeneousAssignmentBuilder {
         this.unassignedPartitions = new ArrayList<>();
 
         this.targetAssignment = new HashMap<>();
+        this.partitionRacks = new HashMap<>();
+
+        Set<String> allMemberRacks = new HashSet<>();
+        for (String memberId : groupSpec.memberIds()) {
+            
groupSpec.memberSubscription(memberId).rackId().ifPresent(allMemberRacks::add);
+        }
+
+        Set<String> allPartitionRacks = new HashSet<>();
+        for (Uuid topicId : this.subscribedTopicIds) {
+            int partitionCount = 
subscribedTopicDescriber.numPartitions(topicId);
+            for (int partitionId = 0; partitionId < partitionCount; 
partitionId++) {
+                Set<String> racks = 
subscribedTopicDescriber.racksForPartition(topicId, partitionId);
+                partitionRacks.put(new TopicIdPartition(topicId, partitionId), 
racks);
+                allPartitionRacks.addAll(racks);
+            }
+        }

Review Comment:
   > @dajac mentioned we could try shortcutting the rack-aware part if no 
members have racks.
   
   Yes, good suggestion. I changed the code to skip gathering the racks of all 
partitions if no members have racks. However, for rack-awareness assignment, it 
still needs to gather information and the worst case may cost `293.988` ms for 
500,000 topic-partitions to 10,000 members. Can we afford this cost in server 
side? Thanks.



-- 
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]

Reply via email to