xinyiZzz commented on a change in pull request #8605:
URL: https://github.com/apache/incubator-doris/pull/8605#discussion_r833892321
##########
File path: be/src/olap/lru_cache.cpp
##########
@@ -449,11 +443,13 @@ ShardedLRUCache::ShardedLRUCache(const std::string& name,
size_t total_capacity,
: _name(name),
_last_id(1),
_mem_tracker(MemTracker::create_tracker(-1, name, nullptr,
MemTrackerLevel::OVERVIEW)) {
+ SCOPED_SWITCH_THREAD_LOCAL_MEM_TRACKER(_mem_tracker);
const size_t per_shard = (total_capacity + (kNumShards - 1)) / kNumShards;
for (int s = 0; s < kNumShards; s++) {
_shards[s] = new LRUCache(type);
_shards[s]->set_capacity(per_shard);
}
+ thread_local_ctx.get()->_thread_mem_tracker_mgr->clear_untracked_mems();
Review comment:
After the lru cache is created in the main thread, the main thread will
not switch the lru cache mem tracker again.
After the non-query thread switches the mem tracker, if the thread will not
switch the mem tracker again in the short term, can consider manually
clear_untracked_mems.
The query thread will automatically clear_untracked_mems when detach_task.
--
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]