transform: algorithmic improvements to optimizer CPU hotspots#35297
Closed
def- wants to merge 1 commit intoMaterializeInc:mainfrom
Closed
transform: algorithmic improvements to optimizer CPU hotspots#35297def- wants to merge 1 commit intoMaterializeInc:mainfrom
def- wants to merge 1 commit intoMaterializeInc:mainfrom
Conversation
|
Thanks for opening this PR! Here are a few tips to help make the review process smooth for everyone. PR title guidelines
Pre-merge checklist
|
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):
base = join_equivs + outer_equivsonce per Join, then clone per child, instead of cloning both separately N timescould_apply()guard to skip clone+reduce_expr+reduce+rollback for expressions the reducer's remap cannot affectminimize()afterpermute()in Join input setup, sincepermute()already callsminimize(None)internallyrelation.clone()for change detection with aCell<bool>flag set conservatively at mutation sitesEquivalenceClasses (analysis/equivalences.rs):
could_apply()method toExpressionReducertrait that walks the expression tree checking if any subexpression matches a remap keyminimize_once()for literals and column refsRedundantJoin (redundant_join.rs):