-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
planner: add optimizer trace framework for logicalOptimize #29559
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
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.
rest LGTM
@@ -179,25 +179,25 @@ func wrapCastFunction(ctx sessionctx.Context, arg expression.Expression, targetT | |||
return expression.BuildCastFunction(ctx, arg, targetTp) | |||
} | |||
|
|||
func (a *aggregationEliminator) optimize(ctx context.Context, p LogicalPlan) (LogicalPlan, error) { | |||
func (a *aggregationEliminator) optimize(ctx context.Context, p LogicalPlan, opts ...logicalOptimizeOption) (*logicalOptimizeReturn, error) { | |||
newChildren := make([]LogicalPlan, 0, len(p.Children())) | |||
for _, child := range p.Children() { | |||
newChild, err := a.optimize(ctx, child) |
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.
Do we need to add opts
here?
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.
currently we only implement framework for rule.optimize. In future we will implement specific logical code for each rule during optimize. Thus no need to add opts
here for now.
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.
Rest LGTM
planner/core/plan.go
Outdated
@@ -377,6 +381,15 @@ func (p *baseLogicalPlan) ExplainInfo() string { | |||
return "" | |||
} | |||
|
|||
// buildLogicalPlanTrace implements LogicalPlan | |||
func (p *baseLogicalPlan) buildLogicalPlanTrace() tracing.LogicalPlanTrace { |
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.
need pointer here? func (p *baseLogicalPlan) buildLogicalPlanTrace() *tracing.LogicalPlanTrace
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.
updated.
planner/core/plan.go
Outdated
@@ -377,6 +381,15 @@ func (p *baseLogicalPlan) ExplainInfo() string { | |||
return "" | |||
} | |||
|
|||
// buildLogicalPlanTrace implements LogicalPlan | |||
func (p *baseLogicalPlan) buildLogicalPlanTrace() tracing.LogicalPlanTrace { | |||
planTrace := tracing.LogicalPlanTrace{ID: p.ID(), TP: p.TP()} |
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.
explainInfo will be filled next?
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.
yes, explainInfo
will be implemented by specific logical operator.
125d053
to
7a7aaa2
Compare
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 7a7aaa242575391a7b8892f1e1a3dc2691c3962d
|
/merge |
/hold |
// The order of flags is same as the order of optRule in the list. | ||
// We use a bitmask to record which opt rules should be used. If the i-th bit is 1, it means we should | ||
// apply i-th optimizing rule. | ||
if flag&(1<<uint(i)) == 0 || isLogicalRuleDisabled(rule) { |
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 part is duplicated with the original one, you can align. Please think about minimizing changes to original codes to make tracer work.
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.
updated.
planner/core/optimizer.go
Outdated
// logicalOptRule means a logical optimizing rule, which contains decorrelate, ppd, column pruning, etc. | ||
type logicalOptRule interface { | ||
optimize(context.Context, LogicalPlan) (LogicalPlan, error) | ||
optimize(context.Context, LogicalPlan, ...logicalOptimizeOption) (*logicalOptimizeReturn, error) |
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.
Please add one rule implementation to show how this framework works.
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.
updated in aggregationEliminateChecker
.
@chrysan: Request changes is only allowed for the reviewers in list. In response to this: Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
/hold |
8632757
to
4340387
Compare
Signed-off-by: yisaer <[email protected]>
/hold cancel |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: dbb28ee
|
planner/core/optimizer.go
Outdated
return op | ||
} | ||
|
||
func (op *logicalOptimizeOp) appendRuleTracerBeforeRuleOptimize(name string, before 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.
If you want logicalOptimizeOp to be generic not only for tracer, you'd better set the func name more generic without word "tracer".
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.
updated.
/hold |
Signed-off-by: yisaer <[email protected]>
3cff75f
to
10ae26b
Compare
/hold cancel |
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 10ae26b
|
@Yisaer: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
/run_check_dev_2 |
/run_check_dev |
/run_all_tests |
/run-all-tests |
/run-check_dev_2 |
1 similar comment
/run-check_dev_2 |
What problem does this PR solve?
ref #29661
Add optimize trace framework for logicalOptimize. In this pr, we do the following work.
Issue Number: close #xxx
Problem Summary:
What is changed and how it works?
Check List
Tests
Release note