[feature-wip] (memory tracker) (step6, End) Fix some details (#9301)

1. Fix LoadTask, ChunkAllocator, TabletMeta, Brpc, the accuracy of memory track.
2. Modified some MemTracker names, deleted some unnecessary trackers, and improved readability.
3. More powerful MemTracker debugging capabilities.
4. Avoid creating TabletColumn temporary objects and improve BE startup time by 8%.
5. Fix some other details.
This commit is contained in:
Xinyi Zou
2022-05-10 18:17:09 +08:00
committed by GitHub
parent 99b8e08a5f
commit b34ed43ec9
35 changed files with 170 additions and 123 deletions

View File

@ -92,7 +92,8 @@ SwitchThreadMemTracker<Existed>::SwitchThreadMemTracker(
DCHECK(mem_tracker);
// The thread tracker must be switched after the attach task, otherwise switching
// in the main thread will cause the cached tracker not be cleaned up in time.
DCHECK(in_task == false || tls_ctx()->_thread_mem_tracker_mgr->is_attach_task());
DCHECK(in_task == false || tls_ctx()->type() != ThreadContext::TaskType::UNKNOWN)
<< ",tls ctx type=" << tls_ctx()->type();
if (Existed) {
_old_tracker_id = tls_ctx()->_thread_mem_tracker_mgr->update_tracker<true>(mem_tracker);
} else {
@ -128,7 +129,9 @@ SwitchThreadMemTrackerErrCallBack::SwitchThreadMemTrackerErrCallBack(
SwitchThreadMemTrackerErrCallBack::~SwitchThreadMemTrackerErrCallBack() {
tls_ctx()->_thread_mem_tracker_mgr->update_consume_err_cb(_old_tracker_cb);
#ifndef NDEBUG
DorisMetrics::instance()->switch_thread_mem_tracker_err_cb_count->increment(1);
#endif
}
SwitchBthread::SwitchBthread() {
@ -137,17 +140,21 @@ SwitchBthread::SwitchBthread() {
if (tls == nullptr) {
// Create thread-local data on demand.
tls = new ThreadContext;
tls->_thread_mem_tracker_mgr->init_bthread();
// set the data so that next time bthread_getspecific in the thread returns the data.
CHECK_EQ(0, bthread_setspecific(btls_key, tls));
} else {
tls->_thread_mem_tracker_mgr->init_bthread();
DCHECK(tls->type() == ThreadContext::TaskType::UNKNOWN);
tls->_thread_mem_tracker_mgr->clear_untracked_mems();
}
tls->_thread_mem_tracker_mgr->init();
tls->set_type(ThreadContext::TaskType::BRPC);
}
SwitchBthread::~SwitchBthread() {
DCHECK(tls != nullptr);
tls->_thread_mem_tracker_mgr->clear_untracked_mems();
tls->_thread_mem_tracker_mgr->init();
tls->set_type(ThreadContext::TaskType::UNKNOWN);
#ifndef NDEBUG
DorisMetrics::instance()->switch_bthread_count->increment(1);
#endif