-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Avoid copying LogicalPlans / Exprs during OptimizerPasses #9708
Conversation
@@ -279,10 +294,10 @@ impl Optimizer { | |||
/// invoking observer function after each call | |||
pub fn optimize<F>( | |||
&self, | |||
plan: &LogicalPlan, | |||
plan: LogicalPlan, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rewriting the optimizer passes to take in owned LogicalPlan
is the key idea
I haven't plumbed it completely through yet, but the approach is looking promising
Update: I think this PR now works well enough to show this is a promising approach. Specifically, by just fixing SimplifyExprs to not copy plans around, the planning benchmark goes 25% faster. I am pretty sure if we fix common subexpr eliminate and a few other passes we could get the benchmark running 2x as fast
The code in this PR is atrocious, but I think works well enough to demonstrate the idea The core problem is that when the LogicalPasses work, they copy the LogicalPlans many times (e.g. each call to cc @sadboy who I think has observed this before as well |
Continuing in #9780, so closing this one |
Which issue does this PR close?
Related to #9637
Rationale for this change
@jayzhan211 @mustafasrepo and I have been discussing how to speed up planning by avoiding copying Exprs / LogicalPlans
What changes are included in this PR?
This PR is a prototype of a suggestion here #9637 (comment) to see if I can get a significant boost in Expr simplify
The theory is that if I can rerite the optimizer to take ownership of the plans they can be rewritten in place
If this works out, I'll turn this into an actual PR for review.
Update: this approach improves planning speed by 25%
Are these changes tested?
NA
Timings (main):
This branch
Are there any user-facing changes?