Skip to content

Block in NonBlockingInputStream #2297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vad0 opened this issue Apr 9, 2025 · 1 comment
Open

Block in NonBlockingInputStream #2297

vad0 opened this issue Apr 9, 2025 · 1 comment
Labels
bug client-v1 issues applicable only for an old client enhancement

Comments

@vad0
Copy link

vad0 commented Apr 9, 2025

Image

Image

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.

@chernser chernser added bug client-v1 issues applicable only for an old client labels Apr 11, 2025
@chernser
Copy link
Contributor

Good day, @vad0 !
Thank you for reporting the issue!
I assume you are working with the V1 version of the client that we are going to deprecate. However thank you for pointing to the issue.

Regarding the problem would you please add more details:

  1. Client version
  2. Client configuration
  3. Sample code showing how write is organized (do you pass and input stream or using a writer)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug client-v1 issues applicable only for an old client enhancement
Projects
None yet
Development

No branches or pull requests

2 participants