From 7002f934e6664daa995ca0629c0ea3bae1c6bddf Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Mon, 9 Feb 2015 17:41:19 -0800 Subject: [PATCH] ShardedThreadPool: make wait timeout on empty queue configurable Fixes: 10818 Backport: giant Signed-off-by: Samuel Just --- src/common/WorkQueue.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/common/WorkQueue.cc b/src/common/WorkQueue.cc index 9d38f08e5388..00666faca334 100644 --- a/src/common/WorkQueue.cc +++ b/src/common/WorkQueue.cc @@ -306,8 +306,12 @@ void ShardedThreadPool::shardedthreadpool_worker(uint32_t thread_index) ++num_paused; wait_cond.Signal(); while(pause_threads.read()) { - cct->get_heartbeat_map()->reset_timeout(hb, 4, 0); - shardedpool_cond.WaitInterval(cct, shardedpool_lock, utime_t(2, 0)); + cct->get_heartbeat_map()->reset_timeout( + hb, + wq->timeout_interval, wq->suicide_interval); + shardedpool_cond.WaitInterval(cct, shardedpool_lock, + utime_t( + cct->_conf->threadpool_empty_queue_max_wait, 0)); } --num_paused; shardedpool_lock.Unlock(); @@ -318,14 +322,21 @@ void ShardedThreadPool::shardedthreadpool_worker(uint32_t thread_index) ++num_drained; wait_cond.Signal(); while (drain_threads.read()) { - cct->get_heartbeat_map()->reset_timeout(hb, 4, 0); - shardedpool_cond.WaitInterval(cct, shardedpool_lock, utime_t(2, 0)); + cct->get_heartbeat_map()->reset_timeout( + hb, + wq->timeout_interval, wq->suicide_interval); + shardedpool_cond.WaitInterval(cct, shardedpool_lock, + utime_t( + cct->_conf->threadpool_empty_queue_max_wait, 0)); } --num_drained; } shardedpool_lock.Unlock(); } + cct->get_heartbeat_map()->reset_timeout( + hb, + wq->timeout_interval, wq->suicide_interval); wq->_process(thread_index, hb); } -- 2.47.3