-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feature-wip] (memory tracker) (step3) Switch TLS mem tracker to separate more detailed memory usage #8605
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
Conversation
| nullptr, "In TCMalloc Hook, " + _consume_err_call_back.action_type, mem_usage, st); | ||
| if (_consume_err_call_back.call_back_func != nullptr) { | ||
| _consume_err_call_back.call_back_func(); | ||
| nullptr, "In TCMalloc Hook, " + _consume_err_cb.cancel_msg, mem_usage, st); |
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.
| nullptr, "In TCMalloc Hook, " + _consume_err_cb.cancel_msg, mem_usage, st); | |
| nullptr, fmt::format("In TCMalloc Hook, {}", _consume_err_cb.cancel_msg), mem_usage, st); |
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.
fix~, for faster.
| } | ||
|
|
||
| void ShardedLRUCache::release(Handle* handle) { | ||
| SCOPED_SWITCH_THREAD_LOCAL_MEM_TRACKER(_mem_tracker); |
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.
Can we add a metric counter for this SWITCH operation?
I want to know how many SWITCH may be called.
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.
ok, I try to add.
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.
fix
33e77da to
b814868
Compare
| _shards[s] = new LRUCache(type); | ||
| _shards[s]->set_capacity(per_shard); | ||
| } | ||
| thread_local_ctx.get()->_thread_mem_tracker_mgr->clear_untracked_mems(); |
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.
Why clear untracked mem here?
you can add some comment.
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.
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.
0ac01eb to
eb818f8
Compare
morningman
left a comment
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.
LGTM
|
PR approved by at least one committer and no changes requested. |
|
PR approved by anyone and no changes requested. |
|
merge for quick test |
…rate more detailed memory usage (apache#8669) Based on apache#8605, Separate out the memory usage of each operator from the Query/Load/StorageEngine mem tracker.
…rate more detailed memory usage (apache#8669) Based on apache#8605, Separate out the memory usage of each operator from the Query/Load/StorageEngine mem tracker.
…rate more detailed memory usage (apache#8669) Based on apache#8605, Separate out the memory usage of each operator from the Query/Load/StorageEngine mem tracker.
Proposed changes
Issue Number: close #7196 (step 3.1/3)
Problem Summary:
In pr #8476, all memory usage of a process is recorded in the process mem tracker, and all memory usage of a query is recorded in the query mem tracker, and it is still necessary to manually call
transfer toto track the cached memory size.We hope to separate out more detailed memory usage based on Hook TCMalloc new/delete + TLS mem tracker.
In this pr, the more detailed mem tracker is switched to TLS, which automatically and accurately counts more detailed memory usage than before.
Checklist(Required)
Further comments
Statistical effect:
Initially (after BE restart)

Query is executing

After Query is over

Load is executing

Note: LoadChannelMgr consumption is 0, because this pr has not really called switch tls mem tracker, and the next pr will be modified in batches.
After Load is over

Note: If QueryPool and LoadPool are found to have negative values for a short time, this is normal, refer to the comments in
MemTrackerTaskPool::logout_task_mem_tracker.