From b4a87d87afc3795f9f5b43af314a9dda2add493b Mon Sep 17 00:00:00 2001 From: tushicheng <18829573815@163.com> Date: Wed, 6 Mar 2024 07:45:28 +0000 Subject: [PATCH] [CP] disable ObBasicTimeGuard::tl_time_guard at pl_debug_thread --- deps/oblib/src/common/ob_common_utility.cpp | 2 +- deps/oblib/src/common/ob_common_utility.h | 26 ++++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/deps/oblib/src/common/ob_common_utility.cpp b/deps/oblib/src/common/ob_common_utility.cpp index e9e5447e4f..07472899b4 100644 --- a/deps/oblib/src/common/ob_common_utility.cpp +++ b/deps/oblib/src/common/ob_common_utility.cpp @@ -162,7 +162,7 @@ int64_t ObFatalErrExtraInfoGuard::to_string(char* buf, const int64_t buf_len) co J_OBJ_END(); return pos; } - +__thread bool ObBasicTimeGuard::tl_enable_time_guard = true; __thread ObBasicTimeGuard *ObBasicTimeGuard::tl_time_guard = NULL; int64_t ObBasicTimeGuard::to_string(char *buf, const int64_t buf_len) const { diff --git a/deps/oblib/src/common/ob_common_utility.h b/deps/oblib/src/common/ob_common_utility.h index 5e4c24f101..91f48f755b 100644 --- a/deps/oblib/src/common/ob_common_utility.h +++ b/deps/oblib/src/common/ob_common_utility.h @@ -79,12 +79,17 @@ public: const char* mod_; }; explicit ObBasicTimeGuard(const char *owner, const char *start, const char *end) - : last_time_guard_(tl_time_guard), owner_(owner), start_(start), end_(end) + : enable_(tl_enable_time_guard), owner_(owner), start_(start), end_(end) { - if (NULL != tl_time_guard) { - tl_time_guard->click(start_); + if (OB_LIKELY(enable_)) { + last_time_guard_ = tl_time_guard; + if (NULL != tl_time_guard) { + tl_time_guard->click(start_); + } + tl_time_guard = this; + } else { + last_time_guard_ = NULL; } - tl_time_guard = this; start_ts_ = get_cur_ts(); last_ts_ = start_ts_; click_count_ = 0; @@ -92,9 +97,11 @@ public: } ~ObBasicTimeGuard() { - tl_time_guard = last_time_guard_; - if (NULL != tl_time_guard) { - tl_time_guard->click(end_); + if (OB_LIKELY(enable_)) { + tl_time_guard = last_time_guard_; + if (NULL != tl_time_guard) { + tl_time_guard->click(end_); + } } } static ObBasicTimeGuard *get_tl_time_guard() @@ -103,7 +110,7 @@ public: } static void time_guard_click(const char *mod) { - if (NULL != tl_time_guard) { + if (OB_LIKELY(tl_enable_time_guard) && NULL != tl_time_guard) { tl_time_guard->click(mod); } } @@ -142,10 +149,13 @@ private: click_infos_[index].mod_ = mod; } } +public: + static __thread bool tl_enable_time_guard; protected: static const int64_t MAX_CLICK_COUNT = 16; static __thread ObBasicTimeGuard *tl_time_guard; private: + const bool enable_; ObBasicTimeGuard *last_time_guard_; int64_t start_ts_; int64_t last_ts_;