Repository navigation
Conversation
|
Workflow [PR], commit [4bd2e1c] Summary: ❌
AI ReviewSummaryPR #129089 executes Missing context / blind spots
Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/CMakeFiles/dbms.dir/Interpreters/HashJoin/RightHashJoinAntiMapsOne.cpp.o |
new | 1.27 MiB | +1.27 MiB |
src/CMakeFiles/dbms.dir/Interpreters/HashJoin/InnerHashJoinAnyMapsSet.cpp.o |
new | 1.13 MiB | +1.13 MiB |
src/CMakeFiles/dbms.dir/Planner/Planner.cpp.o |
397.54 KiB | 444.15 KiB | +46.61 KiB (+11.73%) |
src/CMakeFiles/dbms.dir/Storages/StorageJoin.cpp.o |
1.93 MiB | 1.97 MiB | +35.49 KiB (+1.79%) |
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
1854 translation units recompiled, 9134 s compile time in total, 1851 of them have a recent master baseline.
Translation units without a recent master baseline:
src/Interpreters/HashJoin/RightHashJoinAntiMapsOne.cpp: 7.7 ssrc/Interpreters/HashJoin/InnerHashJoinAnyMapsSet.cpp: 7.7 s
Symbol sizes
| Binary | Symbol | Master | PR | Δ |
|---|---|---|---|---|
programs/clickhouse |
unsigned long DB::HashJoinMethods<(DB::JoinKind)0, (DB::JoinStrictness)2, DB::HashJoin::MapsTemplat… |
new | 136.95 KiB | +136.95 KiB |
programs/clickhouse |
unsigned long DB::HashJoinMethods<(DB::JoinKind)2, (DB::JoinStrictness)6, DB::HashJoin::MapsTemplat… |
new | 131.44 KiB | +131.44 KiB |
3e13652 to
49b6645
Compare
a05cd3a to
b96db76
Compare
b96db76 to
3723a66
Compare
4226096 to
d75649d
Compare
harikrishnan94
left a comment
There was a problem hiding this comment.
Description and changelog:
- "4 to 13 times faster" is the 50M-row synthetic test. TPC-DS SF100 in the description is 1.0x to 3.0x. pls say which is which.
- pls add peak memory next to the times: 23 -> 399 MiB, 25 -> 402 MiB, 16 -> 852 MiB on the 3 duplicate-heavy queries of the perf test (amd). And say why this is a fair trade-off: the join spills by default, so its memory stays bounded. The old step can't spill: it keeps the hash set of the second arm in memory, and a large one runs out of memory.
- not mentioned: result order no longer follows the first arm (02004 needed
ORDER BY), and ordinaryINNER ANYjoins that select no right column now run on the key-only table. The text ofenable_join_key_only_hash_tablesstill lists onlyLEFT ANTIandLEFT SEMI. - "excluded from ... distributed execution": only parallel replicas and the broadcast join are excluded, 05443 runs with
make_distributed_plan = 1.
…nly right block only if it adds a key.
…layout, the plan of the distributed EXCEPT.
|
📊 Cloud Performance Report ✅ AI verdict: no significant changes detected. K_source=4 K_base=20 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
# Conflicts: # src/Processors/QueryPlan/JoinStepLogical.cpp # src/Processors/QueryPlan/Optimizations/Cascades/Rules/HashJoinImplementation.cpp
|
Regarding the regression in the CI for TPC-DS q37. The query runs in about 66 ms with existing IntersectOrExcept and 77 ms with join rewrite on ARM. The query runs a It only shows up when the inputs are tiny (see TPC-DS sf100 numbers above), and it costs a few milliseconds in absolute terms, so I think it's safe to accept. |
Agreed. That's fine. In general I'd accept every regression that comes out of the JOIN step or the planner's decisions, we're working on both anyway. Anything that can be expressed as a JOIN should be, regardless of regressions. When JOINs get faster, all of these queries get faster for free. We could also special-case the join planner to bring cases like this one back to parity, but that's ugly. The join planner's decisions should stay generic. The 13 µs vs 4 µs per-chunk build cost is worth a separate look though. Lots of small blocks going into the build is a general join problem, not something specific to this PR. |
yes, I agree as long as the regression does not affect larger data sizes in a meaningful way like in this case. Regarding the per chunk overhead on build size, one thing is that in parallel layout we squash chunks to get a minimum size, so this overhead is only apparent on serial layout. I will try to look into it the overhead better, but separately from this change. |
First part of: #115106
Related: #118230
Related: #114550
This change builds on some of the ideas in #118230, thanks to @raimannma.
Execute
INTERSECT DISTINCTandEXCEPT DISTINCTas a hash join on all columns instead of the single-threadedIntersectOrExceptstep.<=>, soNULLmatchesNULLas in the set operation.INTERSECT DISTINCTruns asINNER ANY, which emits each key once. The output columns are always taken form the probe side to keep the hash table a set without RowRefs.EXCEPT DISTINCTruns asLEFT ANTIfollowed byDISTINCT, or asRIGHT ANTIwhen the join order optimizer builds the left side.RIGHT ANTIhash table keeps one row per key, so it emits each key once as well.DISTINCTstep skips deduplication and only enforcesmax_rows_in_distinct.max_bytes_in_distinctis deliberately not enforced, because noDISTINCTset is built whose memory it could limit.Enforced join settings: a set-operation join ignores the join settings of the query, because they would change its result.
join_algorithmis alwayshash.max_rows_in_joinandmax_bytes_in_joinare ignored, as they would truncate the result.allow_dynamic_type_in_join_keysis enabled, soDynamicvalues match as in the set operation.Because
INTERSECTandEXCEPTnow run as joins, they share the same limitations of ordinary joins:WHEREcondition over the result can be pushed into both arms. An expression that throws for some rows, can then be evaluated on rows it never saw before.query_plan_optimize_join_order_algorithmset to onlydphypordpsize,EXCEPTfails withFailed to find a valid join order, because it becomes an anti join and these algorithms handle only inner joins.Changes to the join code that affect other joins:
Performance, the new performance test
intersect_except_distinct:On AMD EPYC 9R14 (32 vCPUs) and 64 GiB of RAM
Peak memory is about the same or lower for seven of the twelve queries. The join uses more for the other five: 1.4 and 1.7 times more for two of the EXCEPT queries, and 4.6 to 6 times more for the queries with many duplicates.
The extra memory is mostly needed by the join to keep the rows needed allow spilling. max_bytes_ratio_before_external_join = 0.5 makes it spill to disk when it reaches half of the memory limit. The old step cannot spill.
TPC-DS, scale 100 (
intersect_default_modeandexcept_default_modeset toDISTINCT):On AMD EPYC 9R14 (32 vCPUs) and 64 GiB of RAM.
query_08query_14aquery_14bquery_38query_87Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
INTERSECT DISTINCTandEXCEPT DISTINCTare now executed as a hash join, which makes them 8 to 24 times faster on synthetic benchmarks. TPC-DS queries that use these operations are up to 3 times faster. The previous execution can be restored with the settingrewrite_intersect_except_distinct_to_join = 0.Workflow [PR]
Sync PR [sync-upstream/pr/129089]