You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Chia-Ping Tsai (Jira)" <ji...@apache.org> on 2024/05/05 13:37:00 UTC

[jira] [Created] (KAFKA-16669) Remove extra collection copy when genrating DescribeAclsResource

Chia-Ping Tsai created KAFKA-16669:
--------------------------------------

             Summary: Remove extra collection copy when genrating DescribeAclsResource
                 Key: KAFKA-16669
                 URL: https://issues.apache.org/jira/browse/KAFKA-16669
             Project: Kafka
          Issue Type: Improvement
            Reporter: Chia-Ping Tsai
            Assignee: Chia-Ping Tsai


There are three collection copy happening in generating DescribeAclsResource

1. Iterable -> HashSet (https://github.com/apache/kafka/blob/25118cec145b1a70a7b1709ca4a7ac367f066c6c/core/src/main/scala/kafka/server/AclApis.scala#L72)

2. HashSet -> Map<R, List> (https://github.com/apache/kafka/blob/25118cec145b1a70a7b1709ca4a7ac367f066c6c/clients/src/main/java/org/apache/kafka/common/requests/DescribeAclsResponse.java#L141)

3. Map<R, List> -> List (https://github.com/apache/kafka/blob/25118cec145b1a70a7b1709ca4a7ac367f066c6c/clients/src/main/java/org/apache/kafka/common/requests/DescribeAclsResponse.java#L146)

We can do two small optimization:

1. remove the first collection copy. This optimization needs two steps: a) change `aclsResources` input type from `Collection` to `Iterable`. b) de-duplicate in second collection copy: HashSet -> Map<R, List>. We use `Set` to replace the `List`

2. set the array size. https://github.com/apache/kafka/blob/25118cec145b1a70a7b1709ca4a7ac367f066c6c/clients/src/main/java/org/apache/kafka/common/requests/DescribeAclsResponse.java#L148




--
This message was sent by Atlassian Jira
(v8.20.10#820010)