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

Avoid calling .size() on java.util.ConcurrentLinkedQueue

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: network
    • Labels:
      None

      Description

      Generally, it seems to be preferred to avoid calling .size() on a Java ConcurrentLinkedQueue. This is an O(N) operation as it must iterate through all the nodes.

      Calling this every time through the loop makes this issue worse under high load. It seems like the same functionality can be attained by just polling and checking for null.

      This is more imperative and less functional, but it seems alright since this is in lower-level networking code.

        Attachments

        1. dont_call_queue_size.patch
          1 kB
          Tim Brooks
        2. KAFKA-2050.patch
          1 kB
          Tim Brooks

          Activity

            People

            • Assignee:
              timbrooks Tim Brooks
              Reporter:
              timbrooks Tim Brooks
              Reviewer:
              Jay Kreps
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: