ShivsundarR commented on code in PR #20746:
URL: https://github.com/apache/kafka/pull/20746#discussion_r2459437934
##########
server/src/main/java/org/apache/kafka/server/share/fetch/PartitionMaxBytesStrategy.java:
##########
@@ -58,10 +66,47 @@ static PartitionMaxBytesStrategy type(StrategyType type) {
private static LinkedHashMap<TopicIdPartition, Integer>
uniformPartitionMaxBytes(int requestMaxBytes, Set<TopicIdPartition> partitions,
int acquiredPartitionsSize) {
checkValidArguments(requestMaxBytes, partitions,
acquiredPartitionsSize);
LinkedHashMap<TopicIdPartition, Integer> partitionMaxBytes = new
LinkedHashMap<>();
- partitions.forEach(partition -> partitionMaxBytes.put(partition,
requestMaxBytes / acquiredPartitionsSize));
+ if (requestMaxBytes >= acquiredPartitionsSize) {
+ // Case 1: requestMaxBytes can be evenly distributed within
partitions. If there is extra bytes left post
+ // dividing it uniformly, assign it randomly to any one of the
partitions.
Review Comment:
> If there is extra bytes left post dividing it uniformly, assign it
randomly to any one of the partitions
Should we consider splitting the extra bytes like Case 3 (one byte to as
many partitions as possible) instead of assigning to randomly to one partition.
For example: if `requestMaxBytes` = 10, `acquiredPartitionsSize` = 6.
- Then in Case 1, we would currently give 1 byte each to 6 partitions and
then randomly give 4 bytes to a select partition making the final split as
{5,1,1,1,1,1}.
- If we can split the remaining 4 bytes equally as well(like Case 3), final
split would be {2, 2, 2, 2, 1, 1}. We would prefer this right?
--
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]