[
https://issues.apache.org/jira/browse/KAFKA-2050?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14380809#comment-14380809
]
Sriharsha Chintalapani commented on KAFKA-2050:
-----------------------------------------------
[~timbrooks] changes looks good to me. But can you send the patch using
kafka-patch-review.py
https://cwiki.apache.org/confluence/display/KAFKA/Patch+submission+and+review
> 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
> Attachments: dont_call_queue_size.patch
>
>
> 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)