dataroaring commented on a change in pull request #8476:
URL: https://github.com/apache/incubator-doris/pull/8476#discussion_r827541095
##########
File path: be/src/runtime/thread_context.h
##########
@@ -50,27 +56,65 @@ class ThreadContext {
};
public:
- ThreadContext() : _thread_id(std::this_thread::get_id()),
_type(TaskType::UNKNOWN) {}
+ ThreadContext() : _thread_id(std::this_thread::get_id()),
_type(TaskType::UNKNOWN) {
+ _thread_mem_tracker_mgr.reset(new ThreadMemTrackerMgr());
+ }
void attach(const TaskType& type, const std::string& task_id,
- const TUniqueId& fragment_instance_id) {
+ const TUniqueId& fragment_instance_id,
+ const std::shared_ptr<MemTracker>& mem_tracker) {
DCHECK(_type == TaskType::UNKNOWN && _task_id == "");
_type = type;
_task_id = task_id;
_fragment_instance_id = fragment_instance_id;
+ _thread_mem_tracker_mgr->attach_task(task_type_string(_type), task_id,
fragment_instance_id,
+ mem_tracker);
}
void detach() {
_type = TaskType::UNKNOWN;
_task_id = "";
_fragment_instance_id = TUniqueId();
+ _thread_mem_tracker_mgr->detach_task();
}
- const std::string type() const;
const std::string& task_id() const { return _task_id; }
const std::thread::id& thread_id() const { return _thread_id; }
const TUniqueId& fragment_instance_id() const { return
_fragment_instance_id; }
+ inline static const std::string task_type_string(ThreadContext::TaskType
type) {
+ switch (type) {
+ case ThreadContext::TaskType::QUERY:
+ return "QUERY";
+ case ThreadContext::TaskType::LOAD:
+ return "LOAD";
+ case ThreadContext::TaskType::COMPACTION:
+ return "COMPACTION";
+ default:
+ return "UNKNOWN";
+ }
Review comment:
We can use array instead of switch case.
##########
File path: be/src/olap/task/engine_alter_tablet_task.cpp
##########
@@ -25,7 +25,14 @@ namespace doris {
using std::to_string;
EngineAlterTabletTask::EngineAlterTabletTask(const TAlterTabletReqV2& request)
- : _alter_tablet_req(request) {}
+ : _alter_tablet_req(request) {
+ _mem_tracker = MemTracker::create_tracker(
+ config::memory_limitation_per_thread_for_schema_change * 1024 *
1024 * 1024,
Review comment:
we should put unit in config name, e.g.
memory_limitation_per_thread_for_schema_change_gb
##########
File path: be/src/runtime/thread_context.h
##########
@@ -50,27 +56,65 @@ class ThreadContext {
};
public:
- ThreadContext() : _thread_id(std::this_thread::get_id()),
_type(TaskType::UNKNOWN) {}
+ ThreadContext() : _thread_id(std::this_thread::get_id()),
_type(TaskType::UNKNOWN) {
+ _thread_mem_tracker_mgr.reset(new ThreadMemTrackerMgr());
+ }
void attach(const TaskType& type, const std::string& task_id,
- const TUniqueId& fragment_instance_id) {
+ const TUniqueId& fragment_instance_id,
+ const std::shared_ptr<MemTracker>& mem_tracker) {
DCHECK(_type == TaskType::UNKNOWN && _task_id == "");
_type = type;
_task_id = task_id;
_fragment_instance_id = fragment_instance_id;
+ _thread_mem_tracker_mgr->attach_task(task_type_string(_type), task_id,
fragment_instance_id,
+ mem_tracker);
}
void detach() {
_type = TaskType::UNKNOWN;
_task_id = "";
_fragment_instance_id = TUniqueId();
+ _thread_mem_tracker_mgr->detach_task();
}
- const std::string type() const;
const std::string& task_id() const { return _task_id; }
const std::thread::id& thread_id() const { return _thread_id; }
const TUniqueId& fragment_instance_id() const { return
_fragment_instance_id; }
+ inline static const std::string task_type_string(ThreadContext::TaskType
type) {
+ switch (type) {
+ case ThreadContext::TaskType::QUERY:
+ return "QUERY";
+ case ThreadContext::TaskType::LOAD:
+ return "LOAD";
+ case ThreadContext::TaskType::COMPACTION:
+ return "COMPACTION";
+ default:
+ return "UNKNOWN";
+ }
+ }
+
+ void consume_mem(int64_t size) {
+ if (thread_mem_tracker_mgr_init == true) {
Review comment:
I would like use if (thread_mem_tracker_mgr_init) for bool type.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]