Repository navigation
Add setting join_runtime_filter_min_probe_rows - #104860
Conversation
20db9a1 to
2d23cbe
Compare
|
Workflow [PR], commit [7347be7] Summary: ❌
AI ReviewSummaryThis PR adds Findings
Final VerdictChanges requested. |
| /// Planning and pipeline overhead outweighs any saving on a tiny probe. | ||
| if (optimization_settings.join_runtime_filter_min_probe_rows > 0) | ||
| { | ||
| auto probe_size = join_step->getInputRowsEstimation(JoinTableSide::Left); |
There was a problem hiding this comment.
join_runtime_filter_min_probe_rows currently depends on join_step->getInputRowsEstimation(JoinTableSide::Left), but this estimation is often unset (for example when query_plan_optimize_join_order_limit = 0, or other non-reorderable joins where optimizeJoinLogicalImpl calls setOptimized without row estimates).
In those paths this check never triggers, so the new setting silently becomes a no-op and runtime filters are still installed for tiny probes. Could we add a fallback estimate path (for example from the left child) or populate left/right estimates before setOptimized on the non-reorder path?
There was a problem hiding this comment.
Still seeing this in current HEAD.
joinRuntimeFilter.cpp now gates on join_step->getInputRowsEstimation(JoinTableSide::Left), but optimizeJoinLogicalImpl still has early-return paths that call join_step->setOptimized() without left/right estimates (e.g. query_plan_optimize_join_order_limit = 0, non-reorderable join shapes, and the use_parallel_replicas path that forces join-order limit to 0 in QueryPlanOptimizationSettings).
In those cases probe_size stays empty, so join_runtime_filter_min_probe_rows never applies and runtime filters are always installed even for tiny probes.
Could we populate left_rows_estimation/right_rows_estimation in the non-reorder path (for example via estimateReadRowsCount on both children) so the setting remains effective outside join-reorder runs as well?
There was a problem hiding this comment.
It's ok to miss estimation in some cases for now
There was a problem hiding this comment.
This still looks live in current HEAD.
join_runtime_filter_min_probe_rows only works when join_step->left_rows_estimation is populated, but optimizeJoinLogicalImpl still takes several non-reorder paths that call join_step->setOptimized without left/right estimates (for example when query_plan_optimize_join_order_limit = 0; this is also forced under parallel replicas in QueryPlanOptimizationSettings).
Then joinRuntimeFilter.cpp reads an empty probe estimate at this check, so the new setting silently becomes a no-op and runtime filters are still installed for tiny probes.
Could we populate left_rows_estimation / right_rows_estimation on the non-reorder path (e.g. from child estimateReadRowsCount) so the setting works consistently outside join-reorder runs too?
There was a problem hiding this comment.
I rechecked this on current HEAD and the gap is still in the code path.
joinRuntimeFilter.cpp now uses join_step->getInputRowsEstimation(JoinTableSide::Left) at tryAddJoinRuntimeFilter (line 160), but optimizeJoinLogicalImpl still has multiple early-return paths that call join_step->setOptimized() without row estimates (lines 1305-1313 and 1328-1333 in optimizeJoin.cpp).
Also, QueryPlanOptimizationSettings still forces query_plan_optimize_join_order_limit = 0 when parallel replicas are enabled (lines 156-157 in QueryPlanOptimizationSettings.cpp), which sends this through the no-estimate path.
So in those cases the probe estimate remains empty and join_runtime_filter_min_probe_rows is skipped, even for very small probes. I still think this setting should be effective outside join-reorder runs too.
5f70379 to
3697d7f
Compare
3697d7f to
b121448
Compare
The flaky check's `Shell.run(timeout=...)` is the only wall-clock guard: `clickhouse-test` itself never knows about the budget, so it keeps running until the wrapper SIGTERMs it. That kill can land mid-query — e.g. the post-test `system.trace_log` aggregate on a debug build with a huge accumulated `trace_log` — failing a run where every test actually passed. Seen on PR #104860 (touches ~32 stateless tests; flaky check ran them all 50x); job timed out at 2180s with `clickhouse-test exited with code -15`, even though `All tests have finished.` printed 69 s earlier and every iteration passed. Two changes: 1. `tests/clickhouse-test`: cap the post-`All tests have finished.` diagnostics with `SETTINGS max_execution_time` and matching HTTP timeouts — the `MemoryAllocatedWithoutCheck` aggregate, the `SYSTEM FLUSH LOGS system.trace_log`, and the per-test-coverage queries. If the server is overloaded they are skipped with a logged exception instead of blocking shutdown. 2. `ci/jobs/functional_tests.py`: forward `--global_time_limit` to `clickhouse-test` (budget minus 180 s of shutdown headroom). `clickhouse-test` stops scheduling new test iterations gracefully and has time to run the hung-check + (now-bounded) diagnostics before the outer `Shell.run` SIGTERM fires. The outer timeout stays as a last-resort kill. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104860&sha=0bd90393d11807d0090b718e119cb03889f31fd7&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29 PR: #104860 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Seems like flaky check could not finish due to many changed tests while each individual test succeed, let's try to address it in #105405 |
| If the number of set bits in a runtime bloom filter exceeds this ratio the filter is completely disabled to reduce the overhead. | ||
| )", EXPERIMENTAL) \ | ||
| DECLARE(UInt64, join_runtime_filter_min_probe_rows, 1000, R"( | ||
| Minimum number of rows to install a JOIN runtime filter. Skip filter installation for tiny probes to reduce overhead. Set to 0 to always install. |
There was a problem hiding this comment.
The reader is a bit confused:
- the setting name says the setting is about the probe size size, also the description says "probes".
- the description also says "installation" which translates to building a runtime filter on the build side, and that's what users would also intuitively expect as it doesn't make sense to build the RT filter but then not use it during probe.
EDIT: I read the rest of the PR ... I think we can just say that the decision is made at optimization time based on the estimated probe side size.
| /// Planning and pipeline overhead outweighs any saving on a tiny probe. | ||
| if (optimization_settings.join_runtime_filter_min_probe_rows > 0) | ||
| { | ||
| auto probe_size = join_step->getInputRowsEstimation(JoinTableSide::Left); |
There was a problem hiding this comment.
(unrelated: maybe we can rename Left/Right in enum JoinTableSide to Probe/Build?)
…26.7 to 26.8 The 26.7 release has been cut (master is 26.8), so this setting first ships in 26.8; the Upgrade check flags a new setting whose history entry is not newer than the old (26.7 release) binary. Also move the `join_runtime_filter_min_probe_rows` entry (from #104860, merged after the 26.8 version bump) the same way, matching the pending fix in #111671. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107667&sha=23d8ad1774ba1cc0fa12661c6fd61152ed4e0c00&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 PR: #107667 Co-Authored-By: Claude Fable 5 <[email protected]>
…6.7 to 26.8 The setting join_runtime_filter_min_probe_rows was added in ClickHouse#104860 with its SettingsChangesHistory.cpp entry placed in the 26.7 version section. Master is now 26.8.1.1, so the entry belongs in the 26.8 section. The Upgrade check counts a setting as documented only when its history-entry version is strictly greater than the previous release version (upgrade_runner.sh: (major*100 + minor) > old_version). The previous release is now v26.7.1.1315-stable, so old_version = 2607. With the entry in 26.7, 2607 > 2607 is false, so the check reports the setting as an undocumented new/changed setting and Upgrade check (amd_release) fails on every PR. Moving it to 26.8 gives 2608 > 2607 = true and the check passes. Same-day precedent: bce71f1 moved another straggler 26.7 -> 26.8 for the same reason; ClickHouse#104860 merged after that move. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ilter effects ClickHouse#104860 added the setting `join_runtime_filter_min_probe_rows` (default 1000) and randomizes it in `clickhouse-test` between 0 and 10000. Tests that assert side effects of the runtime filter being built — `BuildRuntimeFilter` in `EXPLAIN` output or `RuntimeFilterGranules*`/index-analysis counters — over probe sides of only tens to a few thousand rows now fail whenever the randomized threshold exceeds the probe size, because the filter is skipped. Pin `join_runtime_filter_min_probe_rows = 0` in those tests, restoring the behavior they were written against. Observed failing in CI: `03394_distributed_shuffle_join_with_filter`, `_with_in`, `_with_aggregation` and `04612_join_runtime_filters_index_analysis_multi_key_anti` (https://d1k2gkhrlfqv31.cloudfront.net/clickhouse-test-reports-private/json.html?PR=65003&sha=a867fe9e119f88fd563055ae403e90120a26e374&name_0=PR); the remaining tests assert the same effects with sub-threshold probe sizes. Co-Authored-By: Claude Fable 5 <[email protected]>
…ime-filter-for-small-probe Add setting join_runtime_filter_min_probe_rows
…6.7 to 26.8 The setting join_runtime_filter_min_probe_rows was added in ClickHouse#104860 with its SettingsChangesHistory.cpp entry placed in the 26.7 version section. Master is now 26.8.1.1, so the entry belongs in the 26.8 section. The Upgrade check counts a setting as documented only when its history-entry version is strictly greater than the previous release version (upgrade_runner.sh: (major*100 + minor) > old_version). The previous release is now v26.7.1.1315-stable, so old_version = 2607. With the entry in 26.7, 2607 > 2607 is false, so the check reports the setting as an undocumented new/changed setting and Upgrade check (amd_release) fails on every PR. Moving it to 26.8 gives 2608 > 2607 = true and the check passes. Same-day precedent: bce71f1 moved another straggler 26.7 -> 26.8 for the same reason; ClickHouse#104860 merged after that move. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The flaky check's `Shell.run(timeout=...)` is the only wall-clock guard: `clickhouse-test` itself never knows about the budget, so it keeps running until the wrapper SIGTERMs it. That kill can land mid-query — e.g. the post-test `system.trace_log` aggregate on a debug build with a huge accumulated `trace_log` — failing a run where every test actually passed. Seen on PR ClickHouse#104860 (touches ~32 stateless tests; flaky check ran them all 50x); job timed out at 2180s with `clickhouse-test exited with code -15`, even though `All tests have finished.` printed 69 s earlier and every iteration passed. Two changes: 1. `tests/clickhouse-test`: cap the post-`All tests have finished.` diagnostics with `SETTINGS max_execution_time` and matching HTTP timeouts — the `MemoryAllocatedWithoutCheck` aggregate, the `SYSTEM FLUSH LOGS system.trace_log`, and the per-test-coverage queries. If the server is overloaded they are skipped with a logged exception instead of blocking shutdown. 2. `ci/jobs/functional_tests.py`: forward `--global_time_limit` to `clickhouse-test` (budget minus 180 s of shutdown headroom). `clickhouse-test` stops scheduling new test iterations gracefully and has time to run the hung-check + (now-bounded) diagnostics before the outer `Shell.run` SIGTERM fires. The outer timeout stays as a last-resort kill. Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104860&sha=0bd90393d11807d0090b718e119cb03889f31fd7&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20flaky%20check%29 PR: ClickHouse#104860 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Two stateless tests from ClickHouse#113291 cannot run on 26.6 as cherry-picked, so they fail before any assertion executes. 04672: join_runtime_filter_min_probe_rows does not exist on 26.6 (added by ClickHouse#104860, settings history 26.8), so the SET at line 21 aborts the test with UNKNOWN_SETTING. Dropping that one clause makes the line identical to the merged 26.7 backport. max_bytes_ratio_before_external_join does exist here, so it stays and 04029 needs no change. 04695: the t_utc block was removed from this branch but the trailing DROP TABLE t_utc and the three matching reference lines were left behind, so the test dies with UNKNOWN_TABLE. Both files: EXPLAIN PLAN defaults to actions=1, compact=1, pretty=1 only from 26.7 via explain_query_plan_default, which does not exist on 26.6, so the references written for master do not match. Pinning the three options explicitly restores the byte-exact output. All three are needed: compact and pretty without actions collapse the plan and hide the sort description rows. Verified with clickhouse local on stock 26.6.3.30 and on a master build. On 26.6 both tests now run to completion and every remaining difference is the defect ClickHouse#113291 fixes. On master the same files match the references byte for byte, so the pinning loses no coverage.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
join_runtime_filter_min_probe_rows(default1000) controls the thresholdFor cases like in https://github.com/ClickHouse/ClickHouse/blob/master/tests/performance/one_thousand_joins.xml runtime filters may add significant overhead