[ 
https://issues.apache.org/jira/browse/KAFKA-938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13681497#comment-13681497
 ] 

Joel Koshy commented on KAFKA-938:
----------------------------------

Actually, small correction: I overlooked that the delayMs val converts the 
given delay from its source unit to milliseconds. So the only caveat is that 
precision will be lost if the desired timeunit is nanos - which we don't really 
need so I don't think we need any further changes here. Thanks again!
                
> High CPU usage when more or less idle
> -------------------------------------
>
>                 Key: KAFKA-938
>                 URL: https://issues.apache.org/jira/browse/KAFKA-938
>             Project: Kafka
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 0.8
>            Reporter: Sam Meder
>            Priority: Critical
>             Fix For: 0.8
>
>         Attachments: timeunit.patch
>
>
> We've noticed Kafka using a lot of CPU in a pretty much idle environment and 
> tracked it down to it's DelayedItem implementation. In particular, the time 
> conversion for how much longer to wait:
>   def getDelay(unit: TimeUnit): Long = {
>     val elapsedMs = (SystemTime.milliseconds - createdMs)
>     unit.convert(max(delayMs - elapsedMs, 0), unit)
>   }
> does not actually convert, so Kafka ends up treating a ms value like 
> nanoseconds, e.g. waking up every 100 ns or so. The above code should really 
> be:
>   def getDelay(unit: TimeUnit): Long = {
>     val elapsedMs = (SystemTime.milliseconds - createdMs)
>     unit.convert(max(delayMs - elapsedMs, 0), TimeUnit.MILLISECONDS)
>   }
> I'll attach a patch.

--
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

Reply via email to