Repository navigation
Enable disk spill for TPC-H and TPC-DS functional tests - #107461
Conversation
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-2:20260614-230000 |
|
cc @alexey-milovidov - follow-up to #107441 as requested. |
|
Workflow [PR], commit [38c56c8] Summary: ✅ AI ReviewSummaryThis PR adds shared TPC-H/TPC-DS stateless test settings to spill Findings💡 Nits
Final VerdictStatus: ✅ Approve |
|
CI on 4a93325 is fully finished. The only red mark is not caused by this PR:
|
|
@groeneai, we must fix the stress test deadlock. You can do it in another PR. |
|
Acknowledged. The Hung-check is the chronic trunk deadlock (leaked local ThreadPool on GlobalThreadPool shutdown). Diagnostic PR #105905 is already collecting registry dumps on master to pin the leaker; the fix will go in a separate PR. |
There was a problem hiding this comment.
I'd keep max_bytes_before_external_group_by and _external_sort. @groeneai please confirm that each meaningfully lowers peak memory and drop any that doesn't move the needle.
For joins, let's not override join_algorithm. These tests should verify the default experience is correct. Remove grace-hash settings and instead set max_bytes_before_external_join s.t. we auto-spill if needed. Again, only do this if it moves the needle.
|
@rienath measured per-query peak (SF1, debug, 10 GiB cap, sort: dropping. group_by: keeping. It moves the needle: TPC-DS q23 1460 -> 663 MiB, TPC-H q13 1582 -> 739 MiB. join: the default-experience approach measurably fails.
ProfileEvents confirm the mechanism: on q88 the grace_hash join writes 192 spill parts and finishes at 499 MiB; the default algorithm writes 0 spill parts and OOMs at 9.4 GiB RSS. So "only if it moves the needle" actually argues for the override here: it is the Your call between:
I lean to (1) for the OOM safety this PR targets, but happy to do either. |
|
We probably misremembered that we have grace hash join by default. At least this was our intent. CC @antaljanosbenjamin @groeneai, Send another PR that enables grace hash join by default globally. |
I am not sure if I get what you mean. GraceHash is not by default. |
|
Confirmed: the default is I'll send the PR. Since |
@antaljanosbenjamin, the only point of grace hash join is to have it by default - for automatic spilling to disk. |
|
Understood, I will send a separate PR enabling grace hash join by default globally. Plan: change the I will cc antaljanosbenjamin on that PR for the final ordering. Once grace_hash is the global default, #107461 no longer needs its own |
|
Opened #107814 to enable grace hash join by default globally: |
|
Please don't enable it yet. We are working on it to make it default, but currently it is not there yet and it might cause issues and performance degradations because hash join can handle more cases and make more optimizations possible. |
|
@alexey-milovidov, antaljanosbenjamin (grace hash owner) asks to hold this: the team is already working on making grace hash the default properly, says it is not ready yet, and warns of performance degradations because hash join handles more cases and enables more optimizations. This matches what I found verifying #107814: with Given the owner says it is not ready, I propose closing #107814 and deferring to the team's in-progress work, unless you want me to instead teach the |
4a93325 to
079b905
Compare
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-1:20260618-060900 |
|
Thanks @antaljanosbenjamin. Done: I removed the Final settings (both 04033_tpc_ds.lib and 04040_tpc_h.lib): Per-setting peak memory, measured on current master (default algorithm):
Output is byte-identical with and without these settings for all 22 TPC-H queries and the verified TPC-DS subset. |
Lower peak memory of the TPC-H and TPC-DS functional tests and exercise the
external GROUP BY and disk-spilling join paths.
Settings live in the shared 04033_tpc_ds.lib / 04040_tpc_h.lib (not in
tests/benchmarks/tpc-{ds,h}/settings.json), because tests/performance/tpc{ds,h}.xml
read the same settings.json and the performance benchmarks must keep running
in memory.
Settings:
--max_bytes_before_external_group_by 314572800
--max_bytes_before_external_join 314572800
The join_algorithm is left at the default. SpillingHashJoin makes the default
algorithm spill to disk once max_bytes_before_external_join is reached, so no
grace_hash override is needed. max_bytes_before_external_sort was dropped after
measurement showed it did not change peak memory on any query.
Spilling to disk makes a query start slowly, so the test-env estimated-time
guard (max_estimated_execution_time=600) can false-positive with TOO_SLOW
(code 160) under the heavily-instrumented sanitizer builds: it linearly
extrapolates total runtime from the slow first phase and overshoots 600s.
These are plan/result tests, not performance tests, so the estimate is
disabled with --max_estimated_execution_time 0.
Output is byte-identical with and without these settings for all 22 TPC-H
queries and the verified TPC-DS subset.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
079b905 to
38c56c8
Compare
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-2:20260618-084300 |
| # Disk spill for GROUP BY and joins. Kept here (not in settings.json) on purpose: | ||
| # tests/performance/tpcds.xml reads the same settings.json and must stay in-memory. | ||
| SETTINGS+=( | ||
| --max_bytes_before_external_group_by 314572800 |
There was a problem hiding this comment.
💡 The code now only adds max_bytes_before_external_group_by, max_bytes_before_external_join, and max_estimated_execution_time = 0, but the PR description still lists the old max_bytes_before_external_sort, join_algorithm = 'grace_hash, hash', max_bytes_in_join, and grace_hash_join_initial_buckets settings. Please update the description so reviewers do not reason from the superseded behavior.
There was a problem hiding this comment.
Updated the description to match the current settings: max_bytes_before_external_group_by, max_bytes_before_external_join, and max_estimated_execution_time = 0 on the default join algorithm. Removed the superseded grace-hash override and sort settings, and refreshed the memory table with the post-SpillingHashJoin default-algorithm numbers.
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 342 line(s), 11 function(s) across 125 file(s) · Details Top files
|
The `odbc` and `jdbc` table functions infer the remote table structure
from the XDBC bridge during query analysis, in
`ITableFunctionXDBC::getActualTableStructure`. This request used the
default `ReadSettings`, so `http_max_tries` was `10`: when the bridge (or
the driver behind it) stopped responding mid-request, it retried up to
ten times, each attempt blocking for up to `http_receive_timeout`.
Because this runs during analysis, before any pipeline executor exists,
it cannot observe query cancellation (`KILL QUERY`, `max_execution_time`),
so a cancelled query stayed in the processlist for minutes and tripped
the stress-test hung check ("possible deadlock found").
`startBridgeIfNot` has already verified the bridge responds, so the
metadata request talks to a known-alive local subprocess. Make a single
attempt (`http_max_tries` = 1) and let the error propagate instead of
retrying.
Added an integration test that points the JDBC bridge at a mock which
answers the ping handshake but never responds to `columns_info`, and
asserts the query fails promptly instead of retrying for minutes.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107461&sha=4a93325d05f03a26c28369c7fe7de652a5f2f155&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29
Related: #107461
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…uilds The previous change only added `no-sanitizers`, but the post-#107461 disk-spill timeouts also occur on non-sanitizer slow builds: - `04033_tpc_ds_q04` times out *only* in `Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel)` (5 rows, 2026-06-19..2026-06-25), never on sanitizers, so `no-sanitizers` did nothing for it. - `04033_tpc_ds_q72` also times out on `amd_debug` and `amd_llvm_coverage`. - `04033_tpc_ds_q37` also times out once on `amd_debug`. In `tests/clickhouse-test`, `no-sanitizers` only matches ASan/MSan/TSan/UBSan (`BuildFlags.SANITIZERS`), so the coverage and debug builds were left exposed. Since the disk spill enabled by #107461 is slow on every instrumented/slow build, skip the six heaviest queries on debug and coverage as well via `no-debug` and `no-llvm-coverage`. `no-llvm-coverage` reroutes these tests to the `amd_binary_excluded_from_llvm` job, which runs them once on a regular (non-instrumented) binary, so their plan/result correctness is still verified without the timeout. The lighter TPC queries keep exercising the spill code paths on instrumented builds. CI report: #108341 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
PR ClickHouse#107461 enabled disk spill (`max_bytes_before_external_group_by` and `max_bytes_before_external_join`) for the TPC-DS and TPC-H functional tests to lower peak memory and exercise the external `GROUP BY` / spilling-join paths. Under sanitizer builds (especially TSan and MSan) the spilling path is so slow that the heaviest queries overrun the 600s per-test timeout. The timeout cluster (`04033_tpc_ds_q10`, `04033_tpc_ds_q72`, `04033_tpc_ds_q04`, `04033_tpc_ds_q37`, `04033_tpc_ds_q39`, `04040_tpc_h_q08`) started within hours of that PR merging into master and hits exactly ~600s only on `amd_tsan` (`amd_msan` reaches ~508s). Before the PR these tests ran in memory and passed on sanitizer builds for months. These are plan/result correctness tests, not performance tests, so run them in memory on sanitizer builds (detected via `system.build_options`), which preserves correctness coverage there without the timeouts, while keeping disk spill on the non-sanitizer builds where it is cheap. Failures (last 90 days), via: https://play.clickhouse.com/play?user=play#V0lUSAogICAgOTAgQVMgaW50ZXJ2YWxfZGF5cwpTRUxFQ1QKICAgIGNoZWNrX3N0YXJ0X3RpbWUgQVMgZGF5LAogICAgcHVsbF9yZXF1ZXN0X251bWJlciBBUyBwciwKICAgIHJlcG9ydF91cmwKRlJPTSBjaGVja3MKV0hFUkUgKG5vdygpIC0gdG9JbnRlcnZhbERheShpbnRlcnZhbF9kYXlzKSkgPD0gY2hlY2tfc3RhcnRfdGltZQogICAgQU5EIHRlc3RfbmFtZSA9ICcwNDAzM190cGNfZHNfcTEwJwogICAgQU5EIHRlc3Rfc3RhdHVzIElOICgnRkFJTCcsICdFUlJPUicpCiAgICBBTkQgKHB1bGxfcmVxdWVzdF9udW1iZXIgPSAwIE9SIGJhc2VfcmVmIElOICgnbWFzdGVyJykpCiAgICBBTkQgdGVzdF9jb250ZXh0X3JhdyBMSUtFICclVGltZW91dCUnCk9SREVSIEJZIGNoZWNrX3N0YXJ0X3RpbWUgREVTQwo= Caused by: ClickHouse#107461 Co-Authored-By: Claude Opus 4.8 <[email protected]>
PR ClickHouse#107461 enabled disk spill (`max_bytes_before_external_group_by` and `max_bytes_before_external_join`) for the TPC-DS and TPC-H functional tests to lower peak memory and exercise the external `GROUP BY` / spilling-join paths. Under sanitizer builds (especially TSan and MSan) the spilling path is so slow that the heaviest queries overrun the 600s per-test timeout. The timeout cluster (`04033_tpc_ds_q10`, `04033_tpc_ds_q72`, `04033_tpc_ds_q04`, `04033_tpc_ds_q37`, `04033_tpc_ds_q39`, `04040_tpc_h_q08`) started within hours of that PR merging into master and hits exactly ~600s only on `amd_tsan` (`amd_msan` reaches ~508s). Before the PR these tests ran in memory and passed on sanitizer builds for months. These are plan/result correctness tests, not performance tests, so run them in memory on sanitizer builds (detected via `system.build_options`), which preserves correctness coverage there without the timeouts, while keeping disk spill on the non-sanitizer builds where it is cheap. Failures (last 90 days), via: https://play.clickhouse.com/play?user=play#V0lUSAogICAgOTAgQVMgaW50ZXJ2YWxfZGF5cwpTRUxFQ1QKICAgIGNoZWNrX3N0YXJ0X3RpbWUgQVMgZGF5LAogICAgcHVsbF9yZXF1ZXN0X251bWJlciBBUyBwciwKICAgIHJlcG9ydF91cmwKRlJPTSBjaGVja3MKV0hFUkUgKG5vdygpIC0gdG9JbnRlcnZhbERheShpbnRlcnZhbF9kYXlzKSkgPD0gY2hlY2tfc3RhcnRfdGltZQogICAgQU5EIHRlc3RfbmFtZSA9ICcwNDAzM190cGNfZHNfcTEwJwogICAgQU5EIHRlc3Rfc3RhdHVzIElOICgnRkFJTCcsICdFUlJPUicpCiAgICBBTkQgKHB1bGxfcmVxdWVzdF9udW1iZXIgPSAwIE9SIGJhc2VfcmVmIElOICgnbWFzdGVyJykpCiAgICBBTkQgdGVzdF9jb250ZXh0X3JhdyBMSUtFICclVGltZW91dCUnCk9SREVSIEJZIGNoZWNrX3N0YXJ0X3RpbWUgREVTQwo= Caused by: ClickHouse#107461 Co-Authored-By: Claude Opus 4.8 <[email protected]>
…uilds The previous change only added `no-sanitizers`, but the post-ClickHouse#107461 disk-spill timeouts also occur on non-sanitizer slow builds: - `04033_tpc_ds_q04` times out *only* in `Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel)` (5 rows, 2026-06-19..2026-06-25), never on sanitizers, so `no-sanitizers` did nothing for it. - `04033_tpc_ds_q72` also times out on `amd_debug` and `amd_llvm_coverage`. - `04033_tpc_ds_q37` also times out once on `amd_debug`. In `tests/clickhouse-test`, `no-sanitizers` only matches ASan/MSan/TSan/UBSan (`BuildFlags.SANITIZERS`), so the coverage and debug builds were left exposed. Since the disk spill enabled by ClickHouse#107461 is slow on every instrumented/slow build, skip the six heaviest queries on debug and coverage as well via `no-debug` and `no-llvm-coverage`. `no-llvm-coverage` reroutes these tests to the `amd_binary_excluded_from_llvm` job, which runs them once on a regular (non-instrumented) binary, so their plan/result correctness is still verified without the timeout. The lighter TPC queries keep exercising the spill code paths on instrumented builds. CI report: ClickHouse#108341 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Follow-up to #107441 (requested by alexey-milovidov): enable disk spill in the TPC-H and TPC-DS functional tests to lower their peak memory and exercise the external aggregation / external join code paths.
The settings are added to the shared
04033_tpc_ds.liband04040_tpc_h.lib, consumed by the04033_tpc_ds_*and04040_tpc_h_*stateless tests:They are placed in the
.lib, not intests/benchmarks/tpc-{ds,h}/settings.json, becausetests/performance/tpc{ds,h}.xmlread the samesettings.jsonand the performance benchmarks must keep running in memory.The join spill uses the default
join_algorithm(no override).max_bytes_before_external_joinnow spills on the default algorithm viaSpillingHashJoin(recently on master), so the tests keep verifying the default join experience while still capping peak memory.max_estimated_execution_time = 0disables the test-env estimated-time guard, which false-positives withTOO_SLOWon the deliberately slower-starting spilling queries under sanitizer builds (same class as #107444).Measured peak memory on SF1 (debug build, default
join_algorithm), baseline then with spill, in MiB:max_bytes_before_external_joinis the main mover (TPC-H q5 -87%, TPC-DS q50 -74%);max_bytes_before_external_group_byhelps the aggregation-heavy queries (TPC-DS q23 -56%).max_bytes_before_external_sortwas measured as a no-op on every query and is not included.Output is byte-identical with and without spill for all 22 TPC-H queries and the verified TPC-DS subset.