Details
-
Improvement
-
Status: Resolved
-
Trivial
-
Resolution: Fixed
-
None
-
None
-
None
Description
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
Attachments
Issue Links
- links to