-
Notifications
You must be signed in to change notification settings - Fork 597
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
feat(optimizer): improve inline now proc time #13609
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #13609 +/- ##
=======================================
Coverage 68.06% 68.07%
=======================================
Files 1516 1516
Lines 261570 261595 +25
=======================================
+ Hits 178049 178082 +33
+ Misses 83521 83513 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -487,10 +491,16 @@ impl LogicalOptimizer { | |||
} | |||
|
|||
pub fn inline_now_proc_time(plan: PlanRef, ctx: &OptimizerContextRef) -> PlanRef { | |||
// TODO: if there's no `NOW()` or `PROCTIME()`, we don't need to acquire snapshot. | |||
let mut v = InlineNowProcTime::new(Epoch(INVALID_EPOCH)); | |||
plan.visit_exprs_recursive(&mut v); |
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.
Maybe better to add doc comment on visit_exprs_recursive
and rewrite_exprs_recursive
, mentioning such usage is for performance.
Actually I'm wondering why this could improve the performance. It appears that a no-op call of I'm considering whether it's possible to reduce the overhead of
Take this for an example, a more efficient version should be... for expr in self.exprs.iter_mut() {
*expr = r.rewrite_expr(std::mem::replace(expr, ExprImpl::Dummy));
} where no allocation will be done if there's no actual rewriting. |
@@ -55,7 +50,7 @@ | |||
"stages": { | |||
"0": { | |||
"root": { | |||
"plan_node_id": 10016, | |||
"plan_node_id": 10013, |
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.
It somehow becomes a indicator about how many plan node has been generated during the optimization 😆
src/frontend/src/expr/now.rs
Outdated
@@ -81,3 +91,21 @@ impl ExprRewriter for InlineNowProcTime { | |||
FunctionCall::new_unchecked(func_type, inputs, ret).into() | |||
} | |||
} | |||
|
|||
impl ExprVisitor for InlineNowProcTime { |
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.
I would suggest defining a new visitor type since its behavior is strictly orthogonal to the rewriter.
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.
This PR LGTM to achieve goal #13459.
I agree with Bugen, so wait for his approval instead
I guess we can achieve it with passing the Arc use std::rc::Rc;
pub trait ExprRewritable {
fn rewrite_exprs(self: Rc<Self>) -> Rc<dyn ExprRewritable>;
}
struct Proj {
a: i32
}
impl ExprRewritable for Proj {
fn rewrite_exprs(self: Rc<Self>) -> Rc<dyn ExprRewritable> {
if self.a == 1 {
return Rc::new(Proj{ a: 2});
} else {
return self
}
}
} |
Good idea. Maybe we can refactor it in the future if necessary.
I think letting developers make sure they're identical in our cases seems trivial. It is not too painful to work with it at this moment. |
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
InlineNowProcTime
for plan nodes if there are no now() and proctime().Checklist
./risedev check
(or alias,./risedev c
)Documentation
Release note
If this PR includes changes that directly affect users or other significant modifications relevant to the community, kindly draft a release note to provide a concise summary of these changes. Please prioritize highlighting the impact these changes will have on users.