-
Notifications
You must be signed in to change notification settings - Fork 5.5k
misc: Refactor TaskManager init and clean up QueryContextManager #26711
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
base: master
Are you sure you want to change the base?
Conversation
Reviewer's GuideRefactors TaskManager to accept an optional externally-provided QueryContextManager and tightens QueryContextCache implementation details, including explicit constructor, safer initialization, and a corrected LRU eviction loop. Class diagram for TaskManager and QueryContextManager refactorclassDiagram
class TaskManager {
+TaskManager(folly::Executor* driverExecutor, folly::Executor* httpSrvExecutor, folly::Executor* spillerExecutor, std::unique_ptr<QueryContextManager> queryContextManager)
-std::unique_ptr<QueryContextManager> queryContextManager_
-velox::exec::OutputBufferManager& bufferManager_
-folly::Executor* httpSrvCpuExecutor_
-uint64_t lastNotOverloadedTimeInSecs_
#void shutdown()
}
class QueryContextManager {
+QueryContextManager(folly::Executor* driverExecutor, folly::Executor* spillerExecutor)
-QueryContextCache queryContextCache_
}
class QueryContextCache {
+explicit QueryContextCache(size_t initial_capacity)
+size_t capacity() const
+std::shared_ptr<velox::core::QueryCtx> insert(protocol::QueryId queryId, std::shared_ptr<velox::core::QueryCtx> queryCtx)
+void setActive(protocol::QueryId queryId)
+void setTasksStarted(protocol::QueryId queryId)
-void evict()
-size_t capacity_
-std::list<protocol::QueryId> queryIds_
-QueryCtxMap queryCtxs_
}
class QueryCtxCacheValue {
+std::weak_ptr<velox::core::QueryCtx> queryCtx
+std::list<protocol::QueryId>::iterator idListIterator
+bool hasStartedTasks
}
TaskManager --> QueryContextManager : owns
QueryContextManager --> QueryContextCache : owns
QueryContextCache --> "*" QueryCtxCacheValue : stores
Flow diagram for TaskManager constructor QueryContextManager injectionflowchart TD
A["TaskManager constructor called"] --> B{"queryContextManager parameter is null"}
B -- "Yes" --> C["Create new QueryContextManager(driverExecutor, spillerExecutor)"]
B -- "No" --> D["Move provided queryContextManager into queryContextManager_"]
C --> E["Assign new QueryContextManager to queryContextManager_"]
D --> E
E --> F["Initialize bufferManager_ from OutputBufferManager::getInstanceRef()"]
F --> G["Store httpSrvCpuExecutor_ and initialize lastNotOverloadedTimeInSecs_"]
G --> H["TaskManager construction complete"]
Flow diagram for updated QueryContextCache LRU evictionflowchart TD
A["evict() called"] --> B["Set victim to queryIds_.rbegin()"]
B --> C{"victim != queryIds_.rend()"}
C -- "No" --> H["No eviction performed"]
C -- "Yes" --> D["Find iter = queryCtxs_.find(*victim)"]
D --> E{"iter != queryCtxs_.end() and iter->second.queryCtx.lock() is empty"}
E -- "Yes" --> F["Erase iter from queryCtxs_"]
F --> G["Erase std::next(victim).base() from queryIds_"]
G --> I["Return from evict()"]
E -- "No" --> J["Increment victim (move towards rend)"]
J --> C
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey there - I've reviewed your changes and found some issues that need to be addressed.
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `presto-native-execution/presto_cpp/main/TaskManager.h:40-39` </location>
<code_context>
virtual ~TaskManager() = default;
- /// Invoked by Presto server shutdown to wait for all the tasks to complete
+ protected:
+
+ /// Invoked by Presto server shutdown to wait for all the tasks to complete
/// and cleanup the completed tasks.
void shutdown();
</code_context>
<issue_to_address>
**issue (bug_risk):** Changing the access specifier here may unintentionally make all following TaskManager methods protected.
Placing `protected:` here changes the visibility of `shutdown()` and all following members until the next access specifier. If no later `public:` is declared, this will hide the existing TaskManager public API and change the class interface. If you only intend `shutdown()` to be protected, move `protected:` immediately before `shutdown()` and add `public:` again afterward (or adjust only `shutdown()`’s declaration).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| std::unique_ptr<QueryContextManager> queryContextManager = nullptr); | ||
|
|
||
| virtual ~TaskManager() = default; | ||
|
|
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.
issue (bug_risk): Changing the access specifier here may unintentionally make all following TaskManager methods protected.
Placing protected: here changes the visibility of shutdown() and all following members until the next access specifier. If no later public: is declared, this will hide the existing TaskManager public API and change the class interface. If you only intend shutdown() to be protected, move protected: immediately before shutdown() and add public: again afterward (or adjust only shutdown()’s declaration).
…stodb#26711) Summary: as title Differential Revision: D87955845
c829ae9 to
39e679f
Compare
…stodb#26711) Summary: as title Differential Revision: D87955845
39e679f to
b450fb8
Compare
Summary: as title
Differential Revision: D87955845