@@ -34,6 +34,8 @@ extern PikaServer* g_pika_server;
3434extern std::unique_ptr<PikaReplicaManager> g_pika_rm;
3535extern std::unique_ptr<PikaCmdTableManager> g_pika_cmd_table_manager;
3636extern std::unique_ptr<net::NetworkStatistic> g_network_statistic;
37+ // QUEUE_SIZE_THRESHOLD_PERCENTAGE is used to represent a percentage value and should be within the range of 0 to 100.
38+ const size_t QUEUE_SIZE_THRESHOLD_PERCENTAGE = 75 ;
3739
3840void DoPurgeDir (void * arg) {
3941 std::unique_ptr<std::string> path (static_cast <std::string*>(arg));
@@ -854,6 +856,13 @@ size_t PikaServer::ClientProcessorThreadPoolCurQueueSize() {
854856 return pika_client_processor_->ThreadPoolCurQueueSize ();
855857}
856858
859+ size_t PikaServer::ClientProcessorThreadPoolMaxQueueSize () {
860+ if (!pika_client_processor_) {
861+ return 0 ;
862+ }
863+ return pika_client_processor_->ThreadPoolMaxQueueSize ();
864+ }
865+
857866void PikaServer::BGSaveTaskSchedule (net::TaskFunc func, void * arg) {
858867 bgsave_thread_.StartThread ();
859868 bgsave_thread_.Schedule (func, arg);
@@ -1298,6 +1307,8 @@ void PikaServer::DoTimingTask() {
12981307 ResetLastSecQuerynum ();
12991308 // Auto update network instantaneous metric
13001309 AutoUpdateNetworkMetric ();
1310+ // Print the queue status periodically
1311+ PrintThreadPoolQueueStatus ();
13011312}
13021313
13031314void PikaServer::AutoCompactRange () {
@@ -1491,6 +1502,16 @@ void PikaServer::AutoUpdateNetworkMetric() {
14911502 current_time, factor);
14921503}
14931504
1505+ void PikaServer::PrintThreadPoolQueueStatus () {
1506+ // Print the current queue size if it exceeds QUEUE_SIZE_THRESHOLD_PERCENTAGE/100 of the maximum queue size.
1507+ size_t cur_size = ClientProcessorThreadPoolCurQueueSize ();
1508+ size_t max_size = ClientProcessorThreadPoolMaxQueueSize ();
1509+ size_t thread_hold = (max_size / 100 ) * QUEUE_SIZE_THRESHOLD_PERCENTAGE ;
1510+ if (cur_size > thread_hold) {
1511+ LOG (INFO ) << " The current queue size of the Pika Server's client thread processor thread pool: " << cur_size;
1512+ }
1513+ }
1514+
14941515void PikaServer::InitStorageOptions () {
14951516 std::lock_guard rwl (storage_options_rw_);
14961517
0 commit comments