ClickHouse / ClickHouse/clickhouse-java
Block in NonBlockingInputStream
- 主要语言
- Java
- 星标
- 1.6k
- 派生
- 636
- 平均合并
- 2 天 23 小时
- 30 天内合并 PR
- 29
描述


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.
贡献指南
调研方向
首先阅读 clickhouse-data/src/main/java/com/clickhouse/data/stream/NonBlockingInputStream.java,重点关注等待服务器数据的 busy loop 以及与 AdaptiveQueue 的交互。在保持该类非阻塞行为的同时,对比短暂 sleep 和可配置的等待策略。完成的标准是:stream 在等待数据时不再消耗过多 CPU。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- performance
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 55/100