[CP] disable ObBasicTimeGuard::tl_time_guard at pl_debug_thread

This commit is contained in:
tushicheng
2024-03-06 07:45:28 +00:00
committed by ob-robot
parent 9a207cc604
commit b4a87d87af
2 changed files with 19 additions and 9 deletions

View File

@ -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
{

View File

@ -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 (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;
}
start_ts_ = get_cur_ts();
last_ts_ = start_ts_;
click_count_ = 0;
@ -92,18 +97,20 @@ public:
}
~ObBasicTimeGuard()
{
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()
{
return tl_time_guard;
}
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_;