ClickHouse / ClickHouse/clickhouse-java

Block in NonBlockingInputStream

オープン
#2,297 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug client-v1 enhancement
主要言語
Java
スター
1.6k
フォーク
636
平均マージ
2日 23時間
マージ済み PR(30日)
29

説明

![Image](https://github.com/user-attachments/assets/4f8a9c5d-5ab7-4b99-84b4-0d02281d623b)

![Image](https://github.com/user-attachments/assets/dd02be80-b7ec-4789-b138-bb695248f8ba)

https://github.com/ClickHouse/clickhouse-java/blob/5758ec51f944dc1daaac4a85084346ee5f8e93bb/clickhouse-data/src/main/java/com/clickhouse/data/stream/NonBlockingInputStream.java

NonBlockingInputStream has a busy loop in it, which consumes 100% CPU while it waits for data from server. Not only does it block the NonBlockingInputStream, but also it does it in a resource intensive way.

### Describe the solution you'd like
Either add Thread.sleep(1) there or a more configurable wait strategy.

### Describe the alternatives you've considered
One can also change queue implementation from AdaptiveQueue to some other queue which supports blocking waiting. But it contradicts the expected non blocking behavior of this class anyway.

### Additional context
I am attaching a profile of my application collected by async profiler. One can see that about 86% of cpu time is spent in this place.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。