Repository navigation
clickhouse-benchmark: do not ping the connection before every query - #110054
alexey-milovidov wants to merge 4 commits into
Conversation
`clickhouse-benchmark` fetched its connection from the pool with the single-argument `ConnectionPool::get`, which unconditionally calls `forceConnected` and therefore sends a `Ping` and waits for `Pong` before every query. For a hot, already-established pooled connection this Ping-Pong round trip is pure overhead: with `--client-side-time` it roughly doubles the reported latency of small queries, because the stopwatch (started before the connection is acquired) measures the ping round trip in addition to the query round trip. Use the `force_connected = false` overload instead, so the connection is reused as-is. A stale connection is now surfaced by the query itself failing, which is handled the same way as any other query error - this matches how the failover path (`ConnectionPoolWithFailover`) already works. Since the benchmark keeps connections hot, they do not idle out between queries, and `--reconnect` still forces periodic reconnection when requested. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [8d4622e] Summary: ❌
AI ReviewSummaryThis PR removes the pre-query Findings
Tests
Final VerdictStatus: |
| /// Ping-Pong round trip only doubles the measured latency of small queries. A stale | ||
| /// connection is handled by the query itself failing, which is treated as a normal error. | ||
| ConnectionPool::Entry entry = connections[connection_index]->get( | ||
| ConnectionTimeouts::getTCPTimeoutsWithoutFailover(settings), settings, /*force_connected=*/false); |
There was a problem hiding this comment.
This changes more than the timing window. ConnectionPool::get used to guarantee a live pooled entry by pinging or reconnecting stale sockets, while Connection::sendQuery only reconnects when the entry is already marked disconnected. With force_connected = false, a half-closed pooled socket now turns into a failed benchmark query instead of a transparent reconnect.
That is user-visible here because the default error path in programs/benchmark/Benchmark.cpp:695-698 aborts the whole benchmark on the first failure. In long-lived or multi-host / low-concurrency runs, a pool entry can sit idle behind server or proxy keep-alive timeouts and now kill the benchmark even though the previous code would have revalidated it.
If the goal is only to stop charging the Ping against --client-side-time, I think the safer fix is to keep the old ConnectionPool::get(timeouts) behavior and move Stopwatch watch; below connection acquisition instead. That narrows the measured interval without weakening stale-connection handling.
There was a problem hiding this comment.
No. We should eliminate ping from connections.
Pulls in the fix for `04401_distributed_with_fill_const_to_scalar` (#110044), which failed in this PR's CI for a reason unrelated to this change. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110054&sha=23a2c8531223fb3e39c904bffdcd10c229cabeef
…k-drop-force-connected
…k-drop-force-connected
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 3/4 (75.00%) · Uncovered code |
|
🕵 Closing this as superseded by #110068 ("remove-force-connected-ping"), which is already merged into
As a result, Related: #110068 |
clickhouse-benchmarkacquired its connection from the pool with the single-argumentConnectionPool::get, which unconditionally callsforceConnectedand therefore sends aPingand waits forPongbefore every query.For a hot, already-established pooled connection this Ping-Pong round trip is pure overhead. With
--client-side-timeit roughly doubles the reported latency of small queries: the stopwatch is started before the connection is acquired, so it measures the ping round trip in addition to the query round trip (~2x RTT). The default server-side timing (progress.elapsed_ns) hides it because that number is the server's own processing time, so the ping only becomes visible under--client-side-time.This changes the benchmark to use the
force_connected = falseoverload, so the connection is reused as-is. A stale connection is surfaced by the query itself failing, which is handled like any other query error - matching how the failover path (ConnectionPoolWithFailover) already works. The benchmark keeps connections hot so they do not idle out between queries, and--reconnectstill forces periodic reconnection when requested.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
clickhouse-benchmarkno longer sends aPingbefore every query, which previously roughly doubled the latency reported with--client-side-timefor small queries.Documentation entry for user-facing changes