Close the usage of OB_TSC_TIMESTAMP.current_time()
This commit is contained in:
@ -14,6 +14,7 @@
|
|||||||
#define OCEANBASE_ALLOCATOR_OB_BLOCK_ALLOC_MGR_H_
|
#define OCEANBASE_ALLOCATOR_OB_BLOCK_ALLOC_MGR_H_
|
||||||
|
|
||||||
#include "lib/allocator/ob_malloc.h"
|
#include "lib/allocator/ob_malloc.h"
|
||||||
|
#include "common/ob_clock_generator.h"
|
||||||
|
|
||||||
namespace oceanbase
|
namespace oceanbase
|
||||||
{
|
{
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include "lib/thread_local/ob_tsi_utils.h"
|
#include "lib/thread_local/ob_tsi_utils.h"
|
||||||
#include "lib/time/ob_time_utility.h"
|
#include "lib/time/ob_time_utility.h"
|
||||||
#include "lib/oblog/ob_log.h"
|
#include "lib/oblog/ob_log.h"
|
||||||
|
#include "common/ob_clock_generator.h"
|
||||||
|
|
||||||
namespace oceanbase
|
namespace oceanbase
|
||||||
{
|
{
|
||||||
|
|||||||
@ -201,7 +201,7 @@ public:
|
|||||||
int64_t itid = get_itid();
|
int64_t itid = get_itid();
|
||||||
int64_t aid = itid % arena_num_;
|
int64_t aid = itid % arena_num_;
|
||||||
ObPoolArenaHead &arena = arena_[aid];
|
ObPoolArenaHead &arena = arena_[aid];
|
||||||
int64_t cur_ts = OB_TSC_TIMESTAMP.current_time();
|
int64_t cur_ts = ObClockGenerator::getClock();
|
||||||
{ // Enter the critical area of the arena, the timestamp is obtained outside the lock, and minimize the length of the critical area
|
{ // Enter the critical area of the arena, the timestamp is obtained outside the lock, and minimize the length of the critical area
|
||||||
ObLatchWGuard lock_guard(arena.lock, ObLatchIds::SERVER_OBJECT_POOL_ARENA_LOCK);
|
ObLatchWGuard lock_guard(arena.lock, ObLatchIds::SERVER_OBJECT_POOL_ARENA_LOCK);
|
||||||
cmeta = static_cast<Meta*>(arena.next);
|
cmeta = static_cast<Meta*>(arena.next);
|
||||||
@ -251,7 +251,7 @@ public:
|
|||||||
if (aid >= 0) {
|
if (aid >= 0) {
|
||||||
x->reset();
|
x->reset();
|
||||||
ObPoolArenaHead &arena = arena_[aid];
|
ObPoolArenaHead &arena = arena_[aid];
|
||||||
int64_t cur_ts = OB_TSC_TIMESTAMP.current_time();
|
int64_t cur_ts = ObClockGenerator::getClock();
|
||||||
{ // Enter the critical area of the arena, the timestamp is obtained outside the lock, and minimize the length of the critical area
|
{ // Enter the critical area of the arena, the timestamp is obtained outside the lock, and minimize the length of the critical area
|
||||||
ObLatchWGuard lock_guard(arena.lock, ObLatchIds::SERVER_OBJECT_POOL_ARENA_LOCK);
|
ObLatchWGuard lock_guard(arena.lock, ObLatchIds::SERVER_OBJECT_POOL_ARENA_LOCK);
|
||||||
cmeta->next = static_cast<Meta*>(arena.next);
|
cmeta->next = static_cast<Meta*>(arena.next);
|
||||||
@ -265,7 +265,7 @@ public:
|
|||||||
x->~T();
|
x->~T();
|
||||||
ob_free(cmeta);
|
ob_free(cmeta);
|
||||||
ObPoolArenaHead &arena = arena_[-(aid + 1)];
|
ObPoolArenaHead &arena = arena_[-(aid + 1)];
|
||||||
int64_t cur_ts = OB_TSC_TIMESTAMP.current_time();
|
int64_t cur_ts = ObClockGenerator::getClock();
|
||||||
{ // Enter the critical area of the arena, the timestamp is obtained outside the lock, and minimize the length of the critical area
|
{ // Enter the critical area of the arena, the timestamp is obtained outside the lock, and minimize the length of the critical area
|
||||||
ObLatchWGuard lock_guard(arena.lock, ObLatchIds::SERVER_OBJECT_POOL_ARENA_LOCK);
|
ObLatchWGuard lock_guard(arena.lock, ObLatchIds::SERVER_OBJECT_POOL_ARENA_LOCK);
|
||||||
arena.miss_return_cnt++;
|
arena.miss_return_cnt++;
|
||||||
|
|||||||
24
deps/oblib/src/lib/time/ob_time_utility.h
vendored
24
deps/oblib/src/lib/time/ob_time_utility.h
vendored
@ -112,28 +112,4 @@ public:
|
|||||||
} //common
|
} //common
|
||||||
} //oceanbase
|
} //oceanbase
|
||||||
|
|
||||||
#define TC_REACH_TIME_INTERVAL(i) \
|
|
||||||
({ \
|
|
||||||
bool bret = false; \
|
|
||||||
static thread_local int64_t last_time = 0; \
|
|
||||||
int64_t cur_time = OB_TSC_TIMESTAMP.current_time(); \
|
|
||||||
if (OB_UNLIKELY((i + last_time) < cur_time)) \
|
|
||||||
{ \
|
|
||||||
last_time = cur_time; \
|
|
||||||
bret = true; \
|
|
||||||
} \
|
|
||||||
bret; \
|
|
||||||
})
|
|
||||||
|
|
||||||
#define TC_REACH_COUNT_INTERVAL(i) \
|
|
||||||
({ \
|
|
||||||
bool bret = false; \
|
|
||||||
static thread_local int64_t count = 0; \
|
|
||||||
if (0 == (++count % i)) \
|
|
||||||
{ \
|
|
||||||
bret = true; \
|
|
||||||
} \
|
|
||||||
bret; \
|
|
||||||
})
|
|
||||||
|
|
||||||
#endif //_OCEANBASE_COMMON_OB_TIME_UTILITY_H_
|
#endif //_OCEANBASE_COMMON_OB_TIME_UTILITY_H_
|
||||||
|
|||||||
19
deps/oblib/src/lib/time/ob_tsc_timestamp.cpp
vendored
19
deps/oblib/src/lib/time/ob_tsc_timestamp.cpp
vendored
@ -67,20 +67,13 @@ int ObTscTimestamp::init()
|
|||||||
int64_t ObTscTimestamp::current_time()
|
int64_t ObTscTimestamp::current_time()
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
int64_t result_time = 0;
|
// init failed, use system call.
|
||||||
if (OB_UNLIKELY(!is_init_)) {
|
struct timeval tv;
|
||||||
// init failed, use system call.
|
if (gettimeofday(&tv, NULL) < 0) {
|
||||||
struct timeval tv;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
if (gettimeofday(&tv, NULL) < 0) {
|
LIB_LOG(WARN, "sys gettimeofday unexpected", K(ret));
|
||||||
ret = OB_ERR_UNEXPECTED;
|
|
||||||
LIB_LOG(WARN, "sys gettimeofday unexpected", K(ret));
|
|
||||||
}
|
|
||||||
result_time = (static_cast<int64_t>(tv.tv_sec) * static_cast<int64_t>(1000000) + static_cast<int64_t>(tv.tv_usec));
|
|
||||||
} else {
|
|
||||||
const uint64_t current_tsc = rdtsc();
|
|
||||||
result_time = ((current_tsc - tsc_count_) * scale_ >> 20) + start_us_;
|
|
||||||
}
|
}
|
||||||
return result_time;
|
return (static_cast<int64_t>(tv.tv_sec) * static_cast<int64_t>(1000000) + static_cast<int64_t>(tv.tv_usec));
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t ObTscTimestamp::current_monotonic_time()
|
int64_t ObTscTimestamp::current_monotonic_time()
|
||||||
|
|||||||
35
deps/oblib/src/lib/utility/ob_macro_utils.h
vendored
35
deps/oblib/src/lib/utility/ob_macro_utils.h
vendored
@ -603,11 +603,36 @@ for (__typeof__((c).at(0)) *it = ((extra_condition) && (c).count() > 0 ? &(c).at
|
|||||||
#define ob_assert(x) ob_release_assert(x)
|
#define ob_assert(x) ob_release_assert(x)
|
||||||
////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////
|
||||||
// interval
|
// interval
|
||||||
|
|
||||||
|
#define TC_REACH_TIME_INTERVAL(i) \
|
||||||
|
({ \
|
||||||
|
bool bret = false; \
|
||||||
|
static thread_local int64_t last_time = 0; \
|
||||||
|
int64_t cur_time = common::ObClockGenerator::getClock(); \
|
||||||
|
if (OB_UNLIKELY((i + last_time) < cur_time)) \
|
||||||
|
{ \
|
||||||
|
last_time = cur_time; \
|
||||||
|
bret = true; \
|
||||||
|
} \
|
||||||
|
bret; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define TC_REACH_COUNT_INTERVAL(i) \
|
||||||
|
({ \
|
||||||
|
bool bret = false; \
|
||||||
|
static thread_local int64_t count = 0; \
|
||||||
|
if (0 == (++count % i)) \
|
||||||
|
{ \
|
||||||
|
bret = true; \
|
||||||
|
} \
|
||||||
|
bret; \
|
||||||
|
})
|
||||||
|
|
||||||
#define REACH_TIME_INTERVAL(i) \
|
#define REACH_TIME_INTERVAL(i) \
|
||||||
({ \
|
({ \
|
||||||
bool bret = false; \
|
bool bret = false; \
|
||||||
static volatile int64_t last_time = 0; \
|
static volatile int64_t last_time = 0; \
|
||||||
int64_t cur_time = OB_TSC_TIMESTAMP.current_time(); \
|
int64_t cur_time = ObClockGenerator::getClock(); \
|
||||||
int64_t old_time = last_time; \
|
int64_t old_time = last_time; \
|
||||||
if (OB_UNLIKELY((i + last_time) < cur_time) \
|
if (OB_UNLIKELY((i + last_time) < cur_time) \
|
||||||
&& old_time == ATOMIC_CAS(&last_time, old_time, cur_time)) \
|
&& old_time == ATOMIC_CAS(&last_time, old_time, cur_time)) \
|
||||||
@ -639,7 +664,7 @@ for (__typeof__((c).at(0)) *it = ((extra_condition) && (c).count() > 0 ? &(c).at
|
|||||||
types::uint128_t next; \
|
types::uint128_t next; \
|
||||||
static const uint64_t ONE_SECOND = 1 * 1000 *1000; \
|
static const uint64_t ONE_SECOND = 1 * 1000 *1000; \
|
||||||
static types::uint128_t last; \
|
static types::uint128_t last; \
|
||||||
const int64_t cur_time = OB_TSC_TIMESTAMP.current_time(); \
|
const int64_t cur_time = common::ObClockGenerator::getClock(); \
|
||||||
while(true) { \
|
while(true) { \
|
||||||
LOAD128(tmp, &last); \
|
LOAD128(tmp, &last); \
|
||||||
if (tmp.lo + ONE_SECOND > (uint64_t)cur_time) { \
|
if (tmp.lo + ONE_SECOND > (uint64_t)cur_time) { \
|
||||||
@ -662,8 +687,8 @@ for (__typeof__((c).at(0)) *it = ((extra_condition) && (c).count() > 0 ? &(c).at
|
|||||||
#define REACH_TIME_INTERVAL_RANGE(i, j) \
|
#define REACH_TIME_INTERVAL_RANGE(i, j) \
|
||||||
({ \
|
({ \
|
||||||
bool bret = false; \
|
bool bret = false; \
|
||||||
static volatile int64_t last_time = OB_TSC_TIMESTAMP.current_time(); \
|
static volatile int64_t last_time = common::ObClockGenerator::getClock(); \
|
||||||
int64_t cur_time = OB_TSC_TIMESTAMP.current_time(); \
|
int64_t cur_time = common::ObClockGenerator::getClock(); \
|
||||||
int64_t old_time = last_time; \
|
int64_t old_time = last_time; \
|
||||||
if ((j + last_time) < cur_time) \
|
if ((j + last_time) < cur_time) \
|
||||||
{ \
|
{ \
|
||||||
@ -696,7 +721,7 @@ for (__typeof__((c).at(0)) *it = ((extra_condition) && (c).count() > 0 ? &(c).at
|
|||||||
types::uint128_t next; \
|
types::uint128_t next; \
|
||||||
static const uint64_t ONE_SECOND = 1 * 1000 * 1000; \
|
static const uint64_t ONE_SECOND = 1 * 1000 * 1000; \
|
||||||
static types::uint128_t last; \
|
static types::uint128_t last; \
|
||||||
const int64_t cur_time = OB_TSC_TIMESTAMP.current_time(); \
|
const int64_t cur_time = common::ObClockGenerator::getClock(); \
|
||||||
while(true) { \
|
while(true) { \
|
||||||
LOAD128(tmp, &last); \
|
LOAD128(tmp, &last); \
|
||||||
if (tmp.lo + ONE_SECOND < (uint64_t)cur_time) { \
|
if (tmp.lo + ONE_SECOND < (uint64_t)cur_time) { \
|
||||||
|
|||||||
1
deps/oblib/src/lib/utility/ob_tracepoint.h
vendored
1
deps/oblib/src/lib/utility/ob_tracepoint.h
vendored
@ -26,6 +26,7 @@
|
|||||||
#include "lib/list/ob_dlist.h"
|
#include "lib/list/ob_dlist.h"
|
||||||
#include "lib/coro/co_var.h"
|
#include "lib/coro/co_var.h"
|
||||||
#include "lib/time/ob_tsc_timestamp.h"
|
#include "lib/time/ob_tsc_timestamp.h"
|
||||||
|
#include "common/ob_clock_generator.h"
|
||||||
#include "lib/utility/ob_macro_utils.h"
|
#include "lib/utility/ob_macro_utils.h"
|
||||||
|
|
||||||
#define TP_COMMA(x) ,
|
#define TP_COMMA(x) ,
|
||||||
|
|||||||
1
deps/oblib/src/lib/utility/utility.h
vendored
1
deps/oblib/src/lib/utility/utility.h
vendored
@ -25,6 +25,7 @@
|
|||||||
#include "lib/utility/ob_backtrace.h"
|
#include "lib/utility/ob_backtrace.h"
|
||||||
#include "lib/oblog/ob_trace_log.h"
|
#include "lib/oblog/ob_trace_log.h"
|
||||||
#include "lib/container/ob_iarray.h"
|
#include "lib/container/ob_iarray.h"
|
||||||
|
#include "common/ob_clock_generator.h"
|
||||||
|
|
||||||
#define FALSE_IT(stmt) ({ (stmt); false; })
|
#define FALSE_IT(stmt) ({ (stmt); false; })
|
||||||
#define OB_FALSE_IT(stmt) ({ (stmt); false; })
|
#define OB_FALSE_IT(stmt) ({ (stmt); false; })
|
||||||
|
|||||||
@ -26,7 +26,7 @@ namespace logservice
|
|||||||
({ \
|
({ \
|
||||||
bool bret = false; \
|
bool bret = false; \
|
||||||
static thread_local volatile int64_t last_time = 0; \
|
static thread_local volatile int64_t last_time = 0; \
|
||||||
int64_t cur_time = OB_TSC_TIMESTAMP.current_time(); \
|
int64_t cur_time = common::ObClockGenerator::getClock(); \
|
||||||
int64_t old_time = last_time; \
|
int64_t old_time = last_time; \
|
||||||
if (OB_UNLIKELY((i + last_time) < cur_time) \
|
if (OB_UNLIKELY((i + last_time) < cur_time) \
|
||||||
&& old_time == ATOMIC_CAS(&last_time, old_time, cur_time)) \
|
&& old_time == ATOMIC_CAS(&last_time, old_time, cur_time)) \
|
||||||
|
|||||||
@ -173,7 +173,7 @@ void ObDataDictService::runTimerTask()
|
|||||||
if (IS_INIT) {
|
if (IS_INIT) {
|
||||||
refresh_config_();
|
refresh_config_();
|
||||||
bool is_leader = ATOMIC_LOAD(&is_leader_);
|
bool is_leader = ATOMIC_LOAD(&is_leader_);
|
||||||
const int64_t start_time = OB_TSC_TIMESTAMP.current_time();
|
const int64_t start_time = ObClockGenerator::getClock();
|
||||||
const bool is_reach_time_interval = (start_time >= ATOMIC_LOAD(&last_dump_succ_time_) + ATOMIC_LOAD(&dump_interval_));
|
const bool is_reach_time_interval = (start_time >= ATOMIC_LOAD(&last_dump_succ_time_) + ATOMIC_LOAD(&dump_interval_));
|
||||||
const bool force_need_dump = ATOMIC_LOAD(&force_need_dump_);
|
const bool force_need_dump = ATOMIC_LOAD(&force_need_dump_);
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ void ObDataDictService::runTimerTask()
|
|||||||
DDLOG(WARN, "dump_data_dict_ failed", KR(ret), K_(tenant_id), K(force_need_dump));
|
DDLOG(WARN, "dump_data_dict_ failed", KR(ret), K_(tenant_id), K(force_need_dump));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const int64_t end_time = OB_TSC_TIMESTAMP.current_time();
|
const int64_t end_time = ObClockGenerator::getClock();
|
||||||
ATOMIC_SET(&last_dump_succ_time_, end_time);
|
ATOMIC_SET(&last_dump_succ_time_, end_time);
|
||||||
|
|
||||||
if (force_need_dump) {
|
if (force_need_dump) {
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "lib/string/ob_string.h" // ObString
|
#include "lib/string/ob_string.h" // ObString
|
||||||
#include "lib/time/ob_time_utility.h" // ObTimeUtility
|
#include "lib/time/ob_time_utility.h" // ObTimeUtility
|
||||||
|
#include "common/ob_clock_generator.h"
|
||||||
#include "share/ob_define.h"
|
#include "share/ob_define.h"
|
||||||
|
|
||||||
namespace oceanbase
|
namespace oceanbase
|
||||||
@ -33,7 +34,7 @@ namespace datadict
|
|||||||
({ \
|
({ \
|
||||||
bool bret = false; \
|
bool bret = false; \
|
||||||
static thread_local volatile int64_t last_time = 0; \
|
static thread_local volatile int64_t last_time = 0; \
|
||||||
int64_t cur_time = OB_TSC_TIMESTAMP.current_time(); \
|
int64_t cur_time = common::ObClockGenerator::getClock(); \
|
||||||
int64_t old_time = last_time; \
|
int64_t old_time = last_time; \
|
||||||
if (OB_UNLIKELY((i + last_time) < cur_time) \
|
if (OB_UNLIKELY((i + last_time) < cur_time) \
|
||||||
&& old_time == ATOMIC_CAS(&last_time, old_time, cur_time)) \
|
&& old_time == ATOMIC_CAS(&last_time, old_time, cur_time)) \
|
||||||
|
|||||||
@ -13,6 +13,7 @@
|
|||||||
#define USING_LOG_PREFIX SQL_CG
|
#define USING_LOG_PREFIX SQL_CG
|
||||||
|
|
||||||
#include "core/ob_jit_allocator.h"
|
#include "core/ob_jit_allocator.h"
|
||||||
|
#include "common/ob_clock_generator.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
using namespace oceanbase::common;
|
using namespace oceanbase::common;
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
#include "observer/omt/ob_tenant.h"
|
#include "observer/omt/ob_tenant.h"
|
||||||
#include "observer/omt/ob_multi_tenant.h"
|
#include "observer/omt/ob_multi_tenant.h"
|
||||||
#include "rpc/obmysql/ob_mysql_packet.h"
|
#include "rpc/obmysql/ob_mysql_packet.h"
|
||||||
|
#include "common/ob_clock_generator.h"
|
||||||
|
|
||||||
using namespace oceanbase::common;
|
using namespace oceanbase::common;
|
||||||
|
|
||||||
|
|||||||
@ -871,7 +871,7 @@ int ObTenantFreezer::get_tenant_memstore_cond(
|
|||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
int64_t unused = 0;
|
int64_t unused = 0;
|
||||||
int64_t current_time = OB_TSC_TIMESTAMP.current_time();
|
int64_t current_time = ObClockGenerator::getClock();
|
||||||
RLOCAL_INIT(int64_t, last_refresh_timestamp, 0);
|
RLOCAL_INIT(int64_t, last_refresh_timestamp, 0);
|
||||||
RLOCAL(int64_t, last_active_memstore_used);
|
RLOCAL(int64_t, last_active_memstore_used);
|
||||||
RLOCAL(int64_t, last_total_memstore_used);
|
RLOCAL(int64_t, last_total_memstore_used);
|
||||||
@ -1053,7 +1053,7 @@ int ObTenantFreezer::check_tenant_out_of_memstore_limit(bool &is_out_of_mem)
|
|||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
RLOCAL(int64_t, last_check_timestamp);
|
RLOCAL(int64_t, last_check_timestamp);
|
||||||
RLOCAL(bool, last_result);
|
RLOCAL(bool, last_result);
|
||||||
int64_t current_time = OB_TSC_TIMESTAMP.current_time();
|
int64_t current_time = ObClockGenerator::getClock();
|
||||||
ObTenantFreezeCtx ctx;
|
ObTenantFreezeCtx ctx;
|
||||||
if (!is_inited_) {
|
if (!is_inited_) {
|
||||||
ret = OB_NOT_INIT;
|
ret = OB_NOT_INIT;
|
||||||
|
|||||||
@ -23,6 +23,7 @@
|
|||||||
#include "share/ob_local_device.h"
|
#include "share/ob_local_device.h"
|
||||||
#include "lib/thread/thread_pool.h"
|
#include "lib/thread/thread_pool.h"
|
||||||
#include "lib/file/file_directory_utils.h"
|
#include "lib/file/file_directory_utils.h"
|
||||||
|
#include "common/ob_clock_generator.h"
|
||||||
|
|
||||||
#define ASSERT_SUCC(ret) ASSERT_EQ((ret), ::oceanbase::common::OB_SUCCESS)
|
#define ASSERT_SUCC(ret) ASSERT_EQ((ret), ::oceanbase::common::OB_SUCCESS)
|
||||||
#define ASSERT_FAIL(ret) ASSERT_NE((ret), ::oceanbase::common::OB_SUCCESS)
|
#define ASSERT_FAIL(ret) ASSERT_NE((ret), ::oceanbase::common::OB_SUCCESS)
|
||||||
@ -1737,7 +1738,7 @@ int IOPerfRunner::do_perf_rolling()
|
|||||||
}
|
}
|
||||||
int64_t pos = 0;
|
int64_t pos = 0;
|
||||||
while (!has_set_stop() && OB_SUCC(ret)) {
|
while (!has_set_stop() && OB_SUCC(ret)) {
|
||||||
if (TC_REACH_TIME_INTERVAL(1000L * 1000L)) {
|
if (REACH_TIME_INTERVAL(1000L * 1000L)) {
|
||||||
ATOMIC_FAA(&io_count_, local_io_count);
|
ATOMIC_FAA(&io_count_, local_io_count);
|
||||||
ATOMIC_FAA(&total_io_count_, local_io_count);
|
ATOMIC_FAA(&total_io_count_, local_io_count);
|
||||||
local_io_count = 0;
|
local_io_count = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user