You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "David Arthur (JIRA)" <ji...@apache.org> on 2012/10/04 15:01:09 UTC

[jira] [Updated] (KAFKA-456) ProducerSendThread calls ListBuffer.size a whole bunch. That is a O(n) operation

     [ https://issues.apache.org/jira/browse/KAFKA-456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Arthur updated KAFKA-456:
-------------------------------

    Attachment: KAFKA-456.patch

I looked around in other parts of the code for similar situations (lots of calls to ListBuffer#size), didn't see any that were unnecessary.

In the worst case, this saves two calls to size(); in the common case, it saves one call.
                
> ProducerSendThread calls ListBuffer.size a whole bunch. That is a O(n) operation
> --------------------------------------------------------------------------------
>
>                 Key: KAFKA-456
>                 URL: https://issues.apache.org/jira/browse/KAFKA-456
>             Project: Kafka
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 0.8, 0.7.1, 0.7.2
>         Environment: NA
>            Reporter: Matthew Rathbone
>            Priority: Minor
>              Labels: newbie
>             Fix For: 0.8
>
>         Attachments: KAFKA-456.patch
>
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Hi all,
> So there are various statements throughout the async code that call 'events.size', mostly for debugging purposes.
> Problem is that this call is O(n), so it could add up if the batch size is high. (it's a ListBuffer)
> I see this in at least ProducerSendThread (x4), likely more. Will factor this out myself soon when I start hacking on the project, just wanted to put this somewhere.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira