Repository navigation
Split JoinOrderOptimizer - #116684
Split JoinOrderOptimizer#116684
JoinOrderOptimizer#116684Conversation
|
Workflow [PR], commit [5d287ac] Summary: ✅
AI ReviewSummaryThis PR splits Missing context / blind spots
Final Verdict✅ No review findings in the current patch. LLVM Coverage ReportMeasured on commit 5d287ac.
Changed lines: Changed C/C++ lines covered: 643/699 (91.99%) · Uncovered code |
Build profile diff (arm_release)Comparing Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/CMakeFiles/dbms.dir/Processors/QueryPlan/Optimizations/joinOrder.cpp.o |
656.93 KiB | 208.27 KiB | -448.66 KiB (-68.30%) |
src/CMakeFiles/dbms.dir/Processors/QueryPlan/Optimizations/joinOrderDPHyp.cpp.o |
new | 239.05 KiB | +239.05 KiB |
src/CMakeFiles/dbms.dir/Processors/QueryPlan/Optimizations/joinOrderGreedy.cpp.o |
new | 196.95 KiB | +196.95 KiB |
src/CMakeFiles/dbms.dir/Processors/QueryPlan/Optimizations/joinOrderDPSub.cpp.o |
new | 185.60 KiB | +185.60 KiB |
src/CMakeFiles/dbms.dir/Processors/QueryPlan/Optimizations/joinOrderDPSize.cpp.o |
new | 114.39 KiB | +114.39 KiB |
src/CMakeFiles/dbms.dir/Processors/QueryPlan/Optimizations/joinOrderDP.cpp.o |
new | 92.82 KiB | +92.82 KiB |
src/CMakeFiles/dbms.dir/Processors/QueryPlan/Optimizations/joinOrderBitSet.cpp.o |
new | 57.17 KiB | +57.17 KiB |
737 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
13 translation units recompiled, 30 s compile time in total, 7 of them have a recent master baseline.
|
@groeneai Please review CI failure https://github.com/ClickHouse/ClickHouse/actions/runs/33062631389/job/98492882909?pr=116684. I will trigger a re-run in the mean time. Thank you! |
|
Not caused by your PR. It is a known master defect that I already have a fix open for.
The aborting query is Root cause: On the re-run: the plain |
Manerone
left a comment
There was a problem hiding this comment.
The split looks good to me, I just left one nitpick, but feel free to ignore it.
| const BitSet & left, | ||
| const BitSet & right); | ||
|
|
||
| double computeSelectivity( |
There was a problem hiding this comment.
nitpick: we have computeSelectivity is other files as well. Since we are making the effort of cleaning JoinOrder.cpp doesn't it also make sense to scope the files (with namespaces) as well? This way we can get: JoinOrderBitSet::computeSelectivity and JoinOrderCommon::computeSelectivity
There was a problem hiding this comment.
Thank you! That's a good point. Let's do a follow up for this. I don't have a good overview how far sub namespacing is developed but in any case the name duplication is indeed not good.
There was a problem hiding this comment.
Sorry, I approved before running Claude, but it also complained that we end up exposing DB::connects. Which is a bit too generic to export in the DB namespace.
| /// Discard any partial state left by an earlier algorithm in the fallback chain | ||
| /// (e.g. `dphyp,greedy`) so cost-model lookups via `getColumnStats` only see | ||
| /// entries built by this run. `expression_selectivity` is cleared along with | ||
| /// `dp_table` because multi-relation predicates resolve NDV through it. |
| /// Populate DP table for components of size=1. | ||
| /// Also reset the per-edge selectivity cache so an earlier algorithm in the | ||
| /// fallback chain cannot leak cached `1.0` defaults from a partial `dp_table`. |
| /// Initialize dp_table with a leaf entry for each base relation. | ||
| /// Also reset the per-edge selectivity cache so this run is independent of any | ||
| /// earlier algorithm in the fallback chain. |
| /// DPsub uses the generic memo only for composite-expression statistics. Clear any | ||
| /// partial state left by an earlier algorithm in the fallback chain so this attempt | ||
| /// has the same cost model as a standalone DPsub run. |
CI-only change set at the moment.
Review is best performed commit by commit. The changes are mostly byte-identical code moves. Some former member functions were converted to free functions. Their call sites are adapted.
Summary
Previously, all join-order algorithms and their mutable state were contained in
joinOrder.cppand the privateJoinOrderOptimizerclass:joinOrder.cpp: 1,810 linesJoinOrderOptimizer: 29 declared member functions and 15 instance data members(Greedy relies on 7 member functions / 4 data members; DPsize: 9 / 8; DPhyp: 17 / 12; DPsub: 10 / 5)
After this change:
joinOrder.cpp: 377 linesJoinOrderOptimizer: remains as entry point and coordinator, with 2 member functions and 6 data membersJoinOrderOptimizercoordinatorBitSethelpersChanges
BitSetgraph helpers and shared DP candidate evaluation.JoinOrderOptimizerto ordered fallback dispatch and overall reporting.DPhyp attempt.
dphyp,dpsubanddpsize,dpsubfallback chains.-O2workaround to the extracted translation units and reused a cached optimizer logger.No existing test reference files are changed.
No functional changes (the DPsub partial state observation aside).
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Not for changelog
Workflow [PR]
Sync PR [sync-upstream/pr/116684]
Version info
26.9.1.476(included in26.9and later)