You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Tim Brooks (JIRA)" <ji...@apache.org> on 2015/03/25 22:11:53 UTC

[jira] [Created] (KAFKA-2050) Avoid calling .size() on java.util.ConcurrentLinkedQueue

Tim Brooks created KAFKA-2050:
---------------------------------

             Summary: Avoid calling .size() on java.util.ConcurrentLinkedQueue
                 Key: KAFKA-2050
                 URL: https://issues.apache.org/jira/browse/KAFKA-2050
             Project: Kafka
          Issue Type: Bug
          Components: network
            Reporter: Tim Brooks
            Assignee: Jun Rao


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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)