You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Ramin Gharib (Jira)" <ji...@apache.org> on 2024/08/19 08:34:00 UTC

[jira] [Comment Edited] (KAFKA-17100) GlobalStreamThread#start should not busy-wait

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

Ramin Gharib edited comment on KAFKA-17100 at 8/19/24 8:33 AM:
---------------------------------------------------------------

Hello [~gharris1727] 
I have created a PR using CountDownLatch:
[https://github.com/apache/kafka/pull/16914]
I used `wait/notify`, but the implementation was a bit bulkier.


was (Author: JIRAUSER304722):
Hello [~gharris1727] 
I have created a PR using CountDownLatch:
[https://github.com/apache/kafka/pull/16914]
I used `wait/notify`, but the implementation is a bit bulkier.

> GlobalStreamThread#start should not busy-wait
> ---------------------------------------------
>
>                 Key: KAFKA-17100
>                 URL: https://issues.apache.org/jira/browse/KAFKA-17100
>             Project: Kafka
>          Issue Type: Task
>          Components: streams
>            Reporter: Greg Harris
>            Assignee: Ela Bhattacharya
>            Priority: Minor
>              Labels: newbie
>
> The current GlobalStreamThread#start implementation [https://github.com/apache/kafka/blob/25230b538841a5e7256b1b51725361dd59435901/streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStreamThread.java#L456-L461] is primarily a busy-wait loop, in which the thread repeatedly checks stillInitializing() and sleeps for 1ms on each iteration.
> This wastes CPU cycles, and instead some synchronizer should be used. This could be wait()/notify(), a Condition, a CountDownLatch, a Future, for some examples. I don't know which of these is best for this situation, since it appears that both stillInitializing == false and startupException != null are both conditions for exiting the loop.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)