This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master in repository sanlock.
The following commit(s) were added to refs/heads/master by this push: new 0ff9c1a sanlock: Shrink thread pool when there is no work 0ff9c1a is described below
commit 0ff9c1ab8852bec846822ee2af55ebcb7e5f5967 Author: Nir Soffer nirsof@gmail.com AuthorDate: Tue Dec 1 15:45:03 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@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);
sanlock-devel@lists.fedorahosted.org