Log detail name for optimizers of RowExpressionRewriteRuleSet and StatsRecordingPlanOptimizer#22765
Conversation
5cb8f9e to
7df1923
Compare
|
This also happens for |
| else if (rule instanceof RowExpressionRewriteRuleSet.TableFinishRowExpressionRewrite) { | ||
| ruleName = ((RowExpressionRewriteRuleSet.TableFinishRowExpressionRewrite) rule).getOptimizerNameForLog(); | ||
| } | ||
| else if (rule instanceof RowExpressionRewriteRuleSet.TableWriterRowExpressionRewrite) { |
There was a problem hiding this comment.
On adding a new rule you will have to extend this, wondering if there was a better way
There was a problem hiding this comment.
Yeah, I was trying to find a better way to achieve this but cannot think of one. Open to suggestions if there are better ways.
There was a problem hiding this comment.
Would the following patch work for you @feilong-liu ? I think you can just extend the rule interface to add a method which does this, and extend all of the rules using the class with the method instead, and check if it is an instance of the abstract class e.g.
public abstract class RowExpressionRewriteRule<T> implements Rule<T> {
public String getOptimizerNameForLog() {
String rewriterName = rewriter.getClass().getName();
return format("%s:%s", rewriterName.substring(rewriterName.lastIndexOf('.') + 1), this.getClass().getSimpleName());
}
}
// rule definition
public final class ProjectRowExpressionRewrite
extends RowExpressionRewriteRule<ProjectNode>
...
// name check
if (rule instanceof RowExpressionRewriteRuleSet.RowExpressionRewriteRule) {
ruleName = ((RowExpressionRewriteRuleSet.RowExpressionRewriteRule) rule).getOptimizerNameForLog();
}There was a problem hiding this comment.
Good suggestion. Applied the change.
7df1923 to
88e4da7
Compare
This is not a big change, added in this PR too. |
88e4da7 to
23c42dd
Compare
presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/IterativeOptimizer.java
Outdated
Show resolved
Hide resolved
23c42dd to
40690b5
Compare
jaystarshot
left a comment
There was a problem hiding this comment.
Don't see an immediate solution to better log rules, maybe rules need to have a field with info about the optimizer which is using but this can be refactored if needed in future.
|
@ClarenceThreepwood Do you have any other ideas? |
40690b5 to
21483d7
Compare
Description
Currently optimizer log will record the class name of the optimizer, however this can be a problem for row expression optimizers, which extends RowExpressionRewriteRuleSet. All such optimizers will have the same name in the log, like "FilterRowExpressionRewrite", "ValuesRowExpressionRewrite" etc. These give no meaningful information on which optimizers are triggered.
This PR will log more verbose information for these optimizers, by including the rewriter class name.
For example instead of "ProjectRowExpressionRewrite" we will log RemoveMapCastRule$Rewriter:ProjectRowExpressionRewrite" now.
Similar for StatsRecordingPlanOptimizer, it's a wrapping optimizer, and it's the delegate optimizer within it doing the work. After the change, it will show as "StatsRecordingPlanOptimizer:HistoricalStatisticsEquivalentPlanMarkingOptimizer" instead of "StatsRecordingPlanOptimizer".
Motivation and Context
To make optimizer log more meaningful.
Impact
Improve optimizer log
Test Plan
Test locally end to end
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.