yangzhg commented on a change in pull request #7198:
URL: https://github.com/apache/incubator-doris/pull/7198#discussion_r762685844
##########
File path: be/src/runtime/mem_tracker.cpp
##########
@@ -233,41 +260,71 @@ int64_t MemTracker::GetPoolMemReserved() {
// Make sure we don't overflow if the query limits are set to
ridiculous values.
mem_reserved += std::min(child_limit, MemInfo::physical_mem());
} else {
- DCHECK(child_limit == -1)
- << child->LogUsage(UNLIMITED_DEPTH);
+ DCHECK(child_limit == -1) << child->LogUsage(UNLIMITED_DEPTH);
mem_reserved += child->consumption();
}
}
}
return mem_reserved;
}
-std::shared_ptr<MemTracker> PoolMemTrackerRegistry::GetRequestPoolMemTracker(
- const string& pool_name, bool create_if_not_present) {
- DCHECK(!pool_name.empty());
- lock_guard<SpinLock> l(pool_to_mem_trackers_lock_);
- PoolTrackersMap::iterator it = pool_to_mem_trackers_.find(pool_name);
- if (it != pool_to_mem_trackers_.end()) {
- MemTracker* tracker = it->second.get();
- DCHECK(pool_name == tracker->pool_name_);
- return it->second;
+std::shared_ptr<MemTracker> QueryMemTrackerRegistry::RegisterQueryMemTracker(
+ const std::string& query_id, int64_t mem_limit) {
+ DCHECK(!query_id.empty());
+ VLOG(2) << "Register query memory tracker, query id: " << query_id
+ << " limit: " << PrettyPrinter::print(mem_limit, TUnit::BYTES);
+
+ // First time this query_id registered, make a new object, otherwise do
nothing.
+ // Combine CreateTracker and emplace into one operation to avoid the use
of locks
+ _query_mem_trackers.try_emplace_l(
+ query_id, [](std::shared_ptr<MemTracker>) {},
+ MemTracker::CreateTracker(mem_limit,
+
strings::Substitute(QUERY_MEM_TRACKER_LABEL_FORMAT, query_id),
+
ExecEnv::GetInstance()->all_query_mem_tracker(), false, false,
Review comment:
better use fmt instead of gutils
--
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]