Uh oh!
There was an error while loading. Please reload this page.
reduce clones of LogicalPlan in planner - #7775
Conversation
doki23
commented
Oct 9, 2023
I draft this pr because it seems that we need more thread stack space -- tpcds_physical_q54 meet the problem of thread stack overflow. |
crepererum
left a comment
There was a problem hiding this comment.
Looking through the changes, I wonder if we should wrap LogicalPlan into an Arc similar to the physical version (even though it's not dyn-dispatch). That would safe stack space and makes cloning very cheap. I think this should also be done for all "child" plans in LogicalPlan that are currently Boxed.
alamb
commented
Oct 10, 2023
One of the tensions is that if we wrapped the plan in Arc it is harder to match plan {LogicalPlan::Scan(..) => {..}LogicalPlan::Project(..) => {..}
...
} |
crepererum
commented
Oct 10, 2023
Depends on how you want to match. You can use |
doki23
commented
Oct 11, 2023
There are some functions taking borrow of plan and return a new plan like: pubfnoptimize(&self,plan:&LogicalPlan) -> Result<LogicalPlan>If we wrap plan with |
crepererum
commented
Oct 11, 2023
I think pubfnoptimize(&self,plan:Arc<LogicalPlan>) -> Result<Arc<LogicalPlan>>If the plan stays the same, you can just pass through the |
alamb
commented
Oct 11, 2023
I think pubfnoptimize(&self,plan:Arc<LogicalPlan>) -> Result<Arc<LogicalPlan>>I agree that sounds like a more sensible plan. |
alamb
commented
Oct 11, 2023
fyi @sadboy, @schulte-lukas and @wolfram-s |
sadboy
commented
Dec 14, 2023
Hi, just saw this thread. FWIW we (SDF) recently changed all our internal use of What did turn out to have a huge perf impact on our workloads, was the asymptotic behavior of the logical plan constructors. Specifically, many methods in Anyway, tl;dr is that
|
alamb
commented
Dec 14, 2023
Thank you @sadboy this is great feedback. I wonder if we could / should make "don't error check" type constructors for this kind of optimization Perhaps something like implProjectionExec{// Creates a new projection exec without any error checking. Use this only// if you know the correct argumentspubfntry_new_unchecked(expr:Vec<(Arc<dynPhysicalExpr>,String)>,input:Arc<dynExecutionPlan>) -> Result<ProjectionExec,DataFusionError>{
...}} |
sadboy
commented
Dec 14, 2023
As a quick and simple solution, that's what I would recommend, yes. More fundamentally, I think the contention arises from the de-facto "dual
As things currently stand, the constructor methods in Ideally, however, I believe these two use cases are different enough that it
Anyway, that's just my $0.02 🙂 (and as I just realized, probably way off topic for |
alamb
commented
Dec 15, 2023
I think it is a great discussion to have -- I filed #8556 to get it out of this thread (on a closed ticket) into a new issue for hopefully wider discussions |
Rationale for this change
To reduce clone of the logical plan. This pr may have some relation with #5637
And the clone of input plan will be reduced after #4628 closed.
What changes are included in this PR?
Speedup the planner but make some tests slower than before because of some more clones.
Are these changes tested?
yes.
Are there any user-facing changes?
no.