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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • network
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: