influxdata / influxdata/influxdb-client-python
Performance bottleneck in FluxCsvParser when parsing large CSV payloads (10MB+)
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 793
- フォーク
- 186
- 平均マージ
- 3時間 2分
- マージ済み PR(30日)
- 1
説明
### Specifications
* Client Version: 1.48.0
* InfluxDB Version: 2.7
* Platform: macos
### Code sample to reproduce problem
```python
```
import influxdb_client
client = influxdb_client.InfluxDBClient(
url="http://localhost:8086",
token="TOKEN",
org="organization",
)
query_api = client.query_api()
query = 'from(bucket: "sensors") |> range(start: 2025-04-13T14:18:11.036Z, stop: 2025-04-13T14:33:11.036Z)'
result = query_api.query(org="matna", query=query)
### Expected behavior
runtime of this query must be same as ui influx
### Actual behavior
runtime this code is not same order
### Additional info
Hi InfluxDB team,
I've encountered a significant performance bottleneck in the FluxCsvParser class within the InfluxDB Python client when working with larger datasets.
🐞 Issue Description
When querying data (~10MB in size), the network call returns results in under 20 ms, which is excellent. However, the CSV parsing step takes over 5 seconds to complete. This introduces an unacceptable latency for high-throughput or low-latency use cases.
In contrast, using the Go client for the same query and dataset, the full query—including parsing—is completed in under 200 ms. This makes the Python client around 25x slower just in the parsing stage.
📈 Performance Benchmark
Data size: ~10MB (Flux CSV)
Query response time (network): < 20 ms
Parsing time (Python client): > 5000 ms
Parsing time (Go client): < 200 ms
🔍 Root Cause
Profiling indicates that the performance degradation is centered in the FluxCsvParser implementation. The current parsing logic in Python seems to be inefficient for large responses due to overhead in string parsing, tokenization, and possibly memory management.
💡 Suggested Improvement
To address this, I suggest reviewing the implementation of FluxCsvParser—specifically around how it handles tokenization, buffering, and line-by-line parsing. Additionally, performance could be dramatically improved by offloading the CSV parsing to a C extension (e.g., using cffi, cython, or ctypes) or integrating an existing optimized parser like libcsv or simdjson.
This would help close the gap with the Go client's performance while maintaining compatibility with the current interface.
✅ Request
Could the maintainers review the FluxCsvParser code path, especially in generate function?
Is there openness to rewriting this part as a performance-critical native extension, or at least modularizing it for optional native acceleration?
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず FluxCsvParser の実装とその generate 関数を見つけ、約 10MB の Flux CSV レスポンスを使って、ネットワークリクエストとは分けてパースをプロファイリングします。Python のパース時間を報告されている Go-client の結果と比較し、トークン化、バッファリング、または行処理にかかるコストを特定します。現在のクライアントインターフェースを維持したまま、パースの改善を測定し、パフォーマンス比較を文書化できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- performance
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100