Commit f6efad8
transform: algorithmic improvements to optimizer CPU hotspots
Profiling shows EquivalencePropagation alone consuming ~24% of total
optimizer CPU. This commit makes several algorithmic improvements to
reduce cloning, redundant work, and fixpoint iterations:
**EquivalencePropagation (equivalence_propagation.rs):**
- Precompute `base = join_equivs + outer_equivs` once per Join, then
clone per child, instead of cloning both separately N times
- Add `could_apply()` guard to skip clone+reduce_expr+reduce+rollback
for expressions the reducer's remap cannot affect
- Remove redundant `minimize()` after `permute()` in Join input setup,
since `permute()` already calls `minimize(None)` internally
- Replace full `relation.clone()` for change detection with a
`Cell<bool>` flag set conservatively at mutation sites
**EquivalenceClasses (analysis/equivalences.rs):**
- Add `could_apply()` method to `ExpressionReducer` trait that walks
the expression tree checking if any subexpression matches a remap key
- Skip clone+reduce in `minimize_once()` for literals and column refs
**RedundantJoin (redundant_join.rs):**
- Remove all redundant join inputs in one pass instead of one per
fixpoint iteration, avoiding costly re-runs of all transforms for
each removal
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent ee7b07a commit f6efad8
File tree
3 files changed
+228
-100
lines changed- src/transform/src
- analysis
3 files changed
+228
-100
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
845 | 845 | | |
846 | 846 | | |
847 | 847 | | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
848 | 852 | | |
849 | 853 | | |
850 | 854 | | |
| |||
1136 | 1140 | | |
1137 | 1141 | | |
1138 | 1142 | | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
1139 | 1149 | | |
1140 | 1150 | | |
1141 | 1151 | | |
| |||
1197 | 1207 | | |
1198 | 1208 | | |
1199 | 1209 | | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
1200 | 1234 | | |
1201 | 1235 | | |
1202 | 1236 | | |
| |||
0 commit comments