Optimize cpu consumption for arb server.
This commit is contained in:
parent
e5bfe02e4d
commit
570fde52a0
2
deps/oblib/src/rpc/pnio/io/time_wheel.h
vendored
2
deps/oblib/src/rpc/pnio/io/time_wheel.h
vendored
@ -1,5 +1,5 @@
|
||||
#define TIME_WHEEL_SLOT_NUM (1<<16)
|
||||
#define TIME_WHEEL_SLOT_INTERVAL 1024
|
||||
#define TIME_WHEEL_SLOT_INTERVAL 8192
|
||||
typedef struct time_wheel_t time_wheel_t;
|
||||
typedef void (timer_cb_t)(time_wheel_t* tw, dlink_t* l);
|
||||
typedef struct time_wheel_t {
|
||||
|
@ -93,7 +93,8 @@ const int64_t PALF_LEADER_RECONFIRM_SYNC_TIMEOUT_US = 10 * 1000 * 1000L; //
|
||||
const int64_t PREPARE_LOG_BUFFER_SIZE = 2048;
|
||||
const int64_t PALF_LEADER_ACTIVE_SYNC_TIMEOUT_US = 10 * 1000 * 1000L; // 10s
|
||||
const int32_t PALF_MAX_REPLAY_TIMEOUT = 500 * 1000;
|
||||
const int32_t PALF_LOG_LOOP_INTERVAL_US = 1 * 1000; // 1ms
|
||||
const int32_t DEFAULT_PALF_LOG_LOOP_INTERVAL_US = 1 * 1000; // 1ms
|
||||
const int32_t PALF_LOG_LOOP_INTERVAL_US_UPPER_BOUND = 100 * 1000; // 100ms
|
||||
const int64_t PALF_SLIDING_WINDOW_SIZE = 1 << 11; // must be 2^n(n>0), default 2^11 = 2048
|
||||
const int64_t PALF_MAX_LEADER_SUBMIT_LOG_COUNT = PALF_SLIDING_WINDOW_SIZE / 2; // max number of concurrent submitting group log in leader
|
||||
const int64_t PALF_RESEND_MSLOG_INTERVAL_US = 500 * 1000L; // 500 ms
|
||||
|
@ -105,7 +105,6 @@ void LogIOTaskCbThreadPool::destroy()
|
||||
wait();
|
||||
is_inited_ = false;
|
||||
if (-1 != tg_id_) {
|
||||
MTL_UNREGISTER_THREAD_DYNAMIC(tg_id_);
|
||||
TG_DESTROY(tg_id_);
|
||||
}
|
||||
tg_id_ = -1;
|
||||
|
@ -22,6 +22,7 @@ namespace palf
|
||||
{
|
||||
LogLoopThread::LogLoopThread()
|
||||
: palf_env_impl_(NULL),
|
||||
run_interval_(DEFAULT_PALF_LOG_LOOP_INTERVAL_US),
|
||||
is_inited_(false)
|
||||
{
|
||||
}
|
||||
@ -31,7 +32,7 @@ LogLoopThread::~LogLoopThread()
|
||||
destroy();
|
||||
}
|
||||
|
||||
int LogLoopThread::init(IPalfEnvImpl *palf_env_impl)
|
||||
int LogLoopThread::init(const bool is_normal_mode, IPalfEnvImpl *palf_env_impl)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(is_inited_)) {
|
||||
@ -43,6 +44,9 @@ int LogLoopThread::init(IPalfEnvImpl *palf_env_impl)
|
||||
} else {
|
||||
palf_env_impl_ = palf_env_impl;
|
||||
share::ObThreadPool::set_run_wrapper(MTL_CTX());
|
||||
if (false == is_normal_mode) {
|
||||
run_interval_ = PALF_LOG_LOOP_INTERVAL_US_UPPER_BOUND;
|
||||
}
|
||||
is_inited_ = true;
|
||||
}
|
||||
|
||||
@ -108,13 +112,13 @@ void LogLoopThread::log_loop_()
|
||||
}
|
||||
|
||||
const int64_t round_cost_time = ObTimeUtility::current_time() - start_ts;
|
||||
int32_t sleep_ts = PALF_LOG_LOOP_INTERVAL_US - static_cast<const int32_t>(round_cost_time);
|
||||
int32_t sleep_ts = run_interval_ - static_cast<const int32_t>(round_cost_time);
|
||||
if (sleep_ts < 0) {
|
||||
sleep_ts = 0;
|
||||
}
|
||||
ob_usleep(sleep_ts);
|
||||
|
||||
if (REACH_TIME_INTERVAL(5 * 1000 * 1000)) {
|
||||
if (REACH_TENANT_TIME_INTERVAL(5 * 1000 * 1000)) {
|
||||
PALF_LOG(INFO, "LogLoopThread round_cost_time", K(round_cost_time));
|
||||
}
|
||||
}
|
||||
|
@ -27,13 +27,14 @@ public:
|
||||
LogLoopThread();
|
||||
virtual ~LogLoopThread();
|
||||
public:
|
||||
int init(IPalfEnvImpl *palf_env_impl);
|
||||
int init(const bool is_normal_mode, IPalfEnvImpl *palf_env_impl);
|
||||
void destroy();
|
||||
void run1();
|
||||
private:
|
||||
void log_loop_();
|
||||
private:
|
||||
IPalfEnvImpl *palf_env_impl_;
|
||||
int64_t run_interval_;
|
||||
bool is_inited_;
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(LogLoopThread);
|
||||
|
@ -207,7 +207,7 @@ int PalfEnvImpl::init(
|
||||
PALF_LOG(ERROR, "construct log path failed", K(ret), K(pret));
|
||||
} else if (OB_FAIL(palf_handle_impl_map_.init("LOG_HASH_MAP", tenant_id))) {
|
||||
PALF_LOG(ERROR, "palf_handle_impl_map_ init failed", K(ret));
|
||||
} else if (OB_FAIL(log_loop_thread_.init(this))) {
|
||||
} else if (OB_FAIL(log_loop_thread_.init(true, this))) {
|
||||
PALF_LOG(ERROR, "log_loop_thread_ init failed", K(ret));
|
||||
} else if (OB_FAIL(
|
||||
election_timer_.init_and_start(1, 1_ms, "ElectTimer"))) { // just one worker thread
|
||||
|
Loading…
x
Reference in New Issue
Block a user