This is an automated email from the git hooks/post-receive script.
nsoffer pushed a commit to annotated tag shrink-pool-v1
in repository sanlock.
commit 19a937183a92b61e0519f4e6d3d83bc24e718991
Author: Nir Soffer <nsoffer(a)redhat.com>
AuthorDate: Tue Dec 1 14:52:55 2020 +0200
sanlock: Shrink thread pool when there is no work
When the thread pool has no work to do, and we have enough free workers,
other worker threads will terminate.
Without this change, when using large number of worker threads, the
thread pool grows to max_worker_threads workers, and never shrink down.
With this change, the pool quickly shrinks down, but we always have
enough free worker threads for serving new requests.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
src/main.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/main.c b/src/main.c
index 63d8cff..622dc8e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -932,6 +932,9 @@ static void *thread_pool_worker(void *data)
while (1) {
while (!pool.quit && list_empty(&pool.work_data)) {
+ if (pool.free_workers >= DEFAULT_MIN_WORKER_THREADS)
+ goto out;
+
pool.free_workers++;
pthread_cond_wait(&pool.cond, &pool.mutex);
pool.free_workers--;
@@ -952,6 +955,7 @@ static void *thread_pool_worker(void *data)
break;
}
+out:
pool.num_workers--;
if (!pool.num_workers)
pthread_cond_signal(&pool.quit_wait);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.