Add log for canonicalized plans in HBO#22306
Conversation
c7fae5f to
efd39b0
Compare
| profileStartTime = System.nanoTime(); | ||
| } | ||
| planNodesWithHash.addAll(getPlanNodeHashes(plan, session, false).values()); | ||
| planNodesWithHash.addAll(getPlanNodeHashes(plan, session, false, plan == root).values()); |
There was a problem hiding this comment.
Record the stats equivalent plan and canonicalized plan only 1) when registering the plan, i.e. hash generation was first calculated as following calls will hit cache 2) only for root node, the serialized plan will cover the whole plan tree
|
|
||
| PlanNode plan = resolveGroupReferences(planNode, lookup); | ||
| Map<PlanCanonicalizationStrategy, PlanNodeWithHash> allHashes = getPlanNodeHashes(plan, session, true); | ||
| Map<PlanCanonicalizationStrategy, PlanNodeWithHash> allHashes = getPlanNodeHashes(plan, session, true, false); |
There was a problem hiding this comment.
Do not record plan when getting statistics
| if (recordPlan) { | ||
| Optional<String> statsEquivalentPlanString = serializeStatsEquivalentPlan(statsEquivalentPlanNode); | ||
| if (statsEquivalentPlanString.isPresent()) { | ||
| historyBasedStatisticsCacheManager.setStatsEquivalentPlan(session.getQueryId(), statsEquivalentPlanString.get()); |
There was a problem hiding this comment.
Record stats equivalent plan
presto-main/src/main/java/com/facebook/presto/sql/analyzer/FeaturesConfig.java
Outdated
Show resolved
Hide resolved
efd39b0 to
81ff8ce
Compare
81ff8ce to
9c30696
Compare
|
"This feature is controlled by session property Suggest adding doc for the session property. Would http://prestodb.io/docs/current/plugin/redis-hbo-provider.html or http://prestodb.io/docs/current/admin/properties.html#optimizer-properties be the correct place for it? |
9c30696 to
b71ef34
Compare
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff 8b8c9e4...89ed79c.
|
steveburnett
left a comment
There was a problem hiding this comment.
Thanks for the doc! One tiny nit suggestion for readability.
| * **Type:** ``boolean`` | ||
| * **Default value:** ``false`` | ||
|
|
||
| Log stats equivalent plan and canonicalized plans used in history based optimization. |
There was a problem hiding this comment.
| Log stats equivalent plan and canonicalized plans used in history based optimization. | |
| Log the stats equivalent plan and canonicalized plans used in history based optimization. |
"Log stats equivalent plan" seems a little hard to parse. Suggestion of "the" taken from the Description of the PR makes it easier to understand.
steveburnett
left a comment
There was a problem hiding this comment.
Thanks for the quick response! Two small nits.
b71ef34 to
f7f89c4
Compare
steveburnett
left a comment
There was a problem hiding this comment.
LGTM! (docs)
Pull updated branch, new local build,looks good. Thanks for the rapid response!
f7f89c4 to
280e466
Compare
| import static com.facebook.presto.SystemSessionProperties.getHistoryBasedOptimizerTimeoutLimit; | ||
| import static com.facebook.presto.SystemSessionProperties.getHistoryInputTableStatisticsMatchingThreshold; | ||
| import static com.facebook.presto.SystemSessionProperties.isVerboseRuntimeStatsEnabled; | ||
| import static com.facebook.presto.SystemSessionProperties.logQueryPlansUsedInHBO; |
There was a problem hiding this comment.
Some places we use HBO, but some places we exapnd to historybasedoptimizer in session props/configs/func names. Lets keep it consistent
There was a problem hiding this comment.
Changed to logQueryPlansUsedInHistoryBasedOptimizer
|
|
||
| @Override | ||
| public Optional<String> hash(Session session, PlanNode planNode, PlanCanonicalizationStrategy strategy, boolean cacheOnly) | ||
| public Optional<String> hash(Session session, PlanNode planNode, PlanCanonicalizationStrategy strategy, boolean cacheOnly, boolean recordPlan) |
There was a problem hiding this comment.
Do we really need this boolean here. Putting it in hash api seems weird. Can we always record it, and choose to log it based on configs above this API.
There was a problem hiding this comment.
Removed the record argument.
280e466 to
3fa5d45
Compare
It will help to debug the root cause when the same query produces different plan hash.
3fa5d45 to
89ed79c
Compare
Description
Log the stats equivalent query plan and the canonicalized plan from HBO.
Motivation and Context
This is to help debug plan hash of HBO.
In HBO, a query will get a snapshot of the plan which we call stats equivalent plan. This plan is then canonicalized to get a new canonicalized plan, which later gets hashed to get a string. This hash string is used as map key to store and retrieve history.
However, one problem observed is that, for the same query, it can have different hash string. This is hard to debug, as it cannot be deterministically reproduced. In this PR, I log the stats equivalent and canonicalized plan, so as to help compare and debug such cases.
Impact
Will help debug HBO hash generation.
Test Plan
Tested locally end to end.
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.