Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-16669

Remove extra collection copy when generating DescribeAclsResource

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • None
    • 3.9.0
    • 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

          Activity

            People

              chiacyu Chia-Chuan Yu
              chia7712 Chia-Ping Tsai
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: