[enhancement](memtracker) Print query memory usage log every second when memory_verbose_track is enabled (#13302)

This commit is contained in:
Xinyi Zou
2022-10-13 09:11:23 +08:00
committed by GitHub
parent d430aec3ae
commit c494ca0ed4
4 changed files with 13 additions and 1 deletions

View File

@ -108,6 +108,9 @@ void MemTrackerTaskPool::logout_task_mem_tracker() {
PrettyPrinter::print(it->second->consumption(), TUnit::BYTES),
PrettyPrinter::print(it->second->peak_consumption(), TUnit::BYTES));
expired_task_ids.emplace_back(it->first);
} else if (config::memory_verbose_track) {
it->second->print_log_usage("query routine");
it->second->enable_print_log_usage();
}
}
for (auto tid : expired_task_ids) {

View File

@ -96,6 +96,7 @@ public:
return _limiter_tracker_raw;
}
bool check_limit() { return _check_limit; }
void set_check_limit(bool check_limit) { _check_limit = check_limit; }
void set_check_attach(bool check_attach) { _check_attach = check_attach; }

View File

@ -241,12 +241,16 @@ private:
class StopCheckThreadMemTrackerLimit {
public:
explicit StopCheckThreadMemTrackerLimit() {
_pre = thread_context()->_thread_mem_tracker_mgr->check_limit();
thread_context()->_thread_mem_tracker_mgr->set_check_limit(false);
}
~StopCheckThreadMemTrackerLimit() {
thread_context()->_thread_mem_tracker_mgr->set_check_limit(true);
thread_context()->_thread_mem_tracker_mgr->set_check_limit(_pre);
}
private:
bool _pre;
};
// The following macros are used to fix the tracking accuracy of caches etc.

View File

@ -513,6 +513,10 @@ int main(int argc, char** argv) {
// The process tracker print log usage interval is 1s to avoid a large number of tasks being
// canceled when the process exceeds the mem limit, resulting in too many duplicate logs.
doris::ExecEnv::GetInstance()->process_mem_tracker()->enable_print_log_usage();
if (doris::config::memory_verbose_track) {
doris::ExecEnv::GetInstance()->process_mem_tracker()->print_log_usage("main routine");
doris::ExecEnv::GetInstance()->process_mem_tracker()->enable_print_log_usage();
}
sleep(1);
}