Improve latency for HBO optimizer#21297
Conversation
947f845 to
ed5640c
Compare
There was a problem hiding this comment.
cache only is set to false, as this is during registration of plan, hence we are supposed to have nothing in cache and populate the cache for future use.
There was a problem hiding this comment.
Only return hash when it's present, the returned hash can be empty if the "planCanonicalInfoProvider.hash" timeout.
There was a problem hiding this comment.
This is within "getStatistics" function which is called when reading estimates from HBO, and we set cacheOnly to true here, as we are supposed to already have cache here, and we do not want to calculate on the fly if cache miss during cost based planning.
There was a problem hiding this comment.
Similarly set to cacheOnly to true as it's within getStatistics function.
There was a problem hiding this comment.
If cacheOnly set to true, return whatever got from cache. This field will be false during registration call in HBO optimizer, so that all data is calculated and cached during registration, and later usage will only read form cache.
There was a problem hiding this comment.
Return early if timeout
There was a problem hiding this comment.
This function is called at the end to collect the HBO information, hence cacheOnly set to true.
|
Please improve the release note message (see guidelines). Suggestion:
|
presto-main/src/main/java/com/facebook/presto/cost/HistoryBasedPlanStatisticsCalculator.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/cost/HistoryBasedPlanStatisticsCalculator.java
Outdated
Show resolved
Hide resolved
ed5640c to
797b59e
Compare
1. Check timeout for plan canonicalization, plan hash and return empty when timeout 2. Add a flag to specify whether to fetch HBO related data from cache only. It's false when register the query, and true when getting statistics 3. Add verbose run time stats for plan hash, plan canonicalization and meta data read
797b59e to
6e30e08
Compare
Description
Part of #20355
This PR optimizes the latency for HBO optimizer from the following aspects:
Previously it only checks timeout for meta data access, and do not return immediately when timeout. However, we found that plan canonicalization and hash can also be time consuming. And we need to check for these two, and also return immediately when timeout.
In the design of HBO, all HBO related stats are fetched and cached during query registration in
HistoricalStatisticsEquivalentPlanMarkingOptimizeroptimizer, and following fetch of stats will access from cache. This PR adds a new parametercacheOnlyto corresponding methods to enforce this behavior.This is only enabled when verbose runtime flag is set to true, and will help to debug HBO timeout.
Motivation and Context
This is to reduce the latency of HBO optimizer.
Impact
Tested with a few production queries, see significant drop of latency for HBO optimizer.
Test Plan
Add unit tests. Also tested locally end to end to verify that HBO optimizer latency decreased. In tests, queries which takes minutes to have HBO optimizer timeout now timeouts within specified timeout limit, i.e. 20seconds.
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.