@@ -168,6 +168,19 @@ class PikaConf : public pstd::BaseConf {
168168 std::shared_lock l (rwlock_);
169169 return slow_cmd_pool_;
170170 }
171+ bool threadpool_borrow_enable () {
172+ std::shared_lock l (rwlock_);
173+ return threadpool_borrow_enable_;
174+ }
175+ int threadpool_borrow_threshold_percent () {
176+ std::shared_lock l (rwlock_);
177+ return threadpool_borrow_threshold_percent_;
178+ }
179+ int threadpool_idle_threshold_percent () {
180+ std::shared_lock l (rwlock_);
181+ return threadpool_idle_threshold_percent_;
182+ }
183+
171184 std::string server_id () {
172185 std::shared_lock l (rwlock_);
173186 return server_id_;
@@ -481,6 +494,71 @@ class PikaConf : public pstd::BaseConf {
481494 std::lock_guard l (rwlock_);
482495 admin_thread_pool_size_ = value;
483496 }
497+ void SetThreadPoolBorrowEnable (const bool value) {
498+ std::lock_guard l (rwlock_);
499+ threadpool_borrow_enable_ = value;
500+ }
501+
502+ void SetThreadPoolBorrowThresholdPercent (const int value) {
503+ std::lock_guard l (rwlock_);
504+ threadpool_borrow_threshold_percent_ = value;
505+ }
506+
507+ void SetThreadPoolIdleThresholdPercent (const int value) {
508+ std::lock_guard l (rwlock_);
509+ threadpool_idle_threshold_percent_ = value;
510+ }
511+
512+ // Getters for EMA configuration
513+ uint32_t threadpool_ema_alpha_numerator () {
514+ std::shared_lock l (rwlock_);
515+ return threadpool_ema_alpha_numerator_;
516+ }
517+ uint32_t threadpool_ema_alpha_denominator () {
518+ std::shared_lock l (rwlock_);
519+ return threadpool_ema_alpha_denominator_;
520+ }
521+ uint64_t threadpool_fast_busy_threshold () {
522+ std::shared_lock l (rwlock_);
523+ return threadpool_fast_busy_threshold_;
524+ }
525+ uint64_t threadpool_fast_idle_threshold () {
526+ std::shared_lock l (rwlock_);
527+ return threadpool_fast_idle_threshold_;
528+ }
529+ uint64_t threadpool_slow_busy_threshold () {
530+ std::shared_lock l (rwlock_);
531+ return threadpool_slow_busy_threshold_;
532+ }
533+ uint64_t threadpool_slow_idle_threshold () {
534+ std::shared_lock l (rwlock_);
535+ return threadpool_slow_idle_threshold_;
536+ }
537+
538+ // Setters for EMA configuration
539+ void SetThreadPoolEmaAlpha (uint32_t numerator, uint32_t denominator) {
540+ std::lock_guard l (rwlock_);
541+ if (denominator > 0 && numerator <= denominator) {
542+ threadpool_ema_alpha_numerator_ = numerator;
543+ threadpool_ema_alpha_denominator_ = denominator;
544+ }
545+ }
546+ void SetThreadPoolFastBusyThreshold (uint64_t value) {
547+ std::lock_guard l (rwlock_);
548+ threadpool_fast_busy_threshold_ = value;
549+ }
550+ void SetThreadPoolFastIdleThreshold (uint64_t value) {
551+ std::lock_guard l (rwlock_);
552+ threadpool_fast_idle_threshold_ = value;
553+ }
554+ void SetThreadPoolSlowBusyThreshold (uint64_t value) {
555+ std::lock_guard l (rwlock_);
556+ threadpool_slow_busy_threshold_ = value;
557+ }
558+ void SetThreadPoolSlowIdleThreshold (uint64_t value) {
559+ std::lock_guard l (rwlock_);
560+ threadpool_slow_idle_threshold_ = value;
561+ }
484562
485563 void SetSlaveof (const std::string& value) {
486564 std::lock_guard l (rwlock_);
@@ -961,6 +1039,19 @@ class PikaConf : public pstd::BaseConf {
9611039 std::string bgsave_prefix_;
9621040 std::string pidfile_;
9631041 std::atomic<bool > slow_cmd_pool_;
1042+
1043+ // Thread pool task borrowing configuration
1044+ bool threadpool_borrow_enable_ = true ;
1045+ int threadpool_borrow_threshold_percent_ = 80 ;
1046+ int threadpool_idle_threshold_percent_ = 20 ;
1047+
1048+ // EMA configuration
1049+ uint32_t threadpool_ema_alpha_numerator_{5 };
1050+ uint32_t threadpool_ema_alpha_denominator_{100 };
1051+ uint64_t threadpool_fast_busy_threshold_{2000 }; // us
1052+ uint64_t threadpool_fast_idle_threshold_{500 }; // us
1053+ uint64_t threadpool_slow_busy_threshold_{5000 }; // us
1054+ uint64_t threadpool_slow_idle_threshold_{1000 }; // us
9641055
9651056 std::string compression_;
9661057 std::string compression_per_level_;
0 commit comments