ColtenOuO opened a new pull request, #23328:
URL: https://github.com/apache/kafka/pull/23328

   ### Summary
   
   `AbstractStickyAssignor isBalanced` already builds a `Map<TopicPartition, 
String> allPartitions` mapping each partition to its currently assigned 
consumer, specifically so that lookups can be done in O(1). A few lines later, 
however, it ignores that map for the actual check and instead calls 
`currentAssignment.get(consumer).contains(topicPartition)`, an O(n) scan over a
   `List<TopicPartition>`, to answer the exact same question.
   
   The extra linear factor is paid on every consumer group rebalance, and 
compounds with group/partition count.
   
   This PR replaces the `List.contains()` scan with a lookup against the map 
that already exists, which is semantically equivalent (including null-handling 
behavior for unassigned partitions) but O(1) instead of O(n).
   
   ### Changes
   
   - `AbstractStickyAssignor#isBalanced`: reuse 
`allPartitions.get(topicPartition)` instead of
     `currentAssignment.get(consumer).contains(topicPartition)`.


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