From 71883dce54726e42792c3155d09b0bf84c3febeb Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 14 Jun 2008 14:14:28 +0000 Subject: [PATCH] Slightly change the criteria for starting new worker threads: Don't do it if the number of queued threads dropped since last inspection. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2664 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_pool.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index ed53ca2f..92daeb45 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -82,6 +82,7 @@ struct wq { VTAILQ_HEAD(, workreq) overflow; unsigned nthr; unsigned nqueue; + unsigned lqueue; uintmax_t ndrop; uintmax_t noverflow; }; @@ -494,8 +495,9 @@ wrk_breed_flock(struct wq *qp) * If we need more threads, and have space, create * one more thread. */ - if (qp->nqueue > params->wthread_add_threshold || - qp->nthr < nthr_min) { + if (qp->nthr < nthr_min || /* Not enough threads yet */ + (qp->nqueue > params->wthread_add_threshold && /* more needed */ + qp->nqueue > qp->lqueue)) { /* not getting better since last */ if (qp->nthr >= nthr_max) { VSL_stats->n_wrk_max++; } else if (pthread_create(&tp, NULL, wrk_thread, qp)) { @@ -509,6 +511,7 @@ wrk_breed_flock(struct wq *qp) (void)usleep(params->wthread_add_delay * 1000); } } + qp->lqueue = qp->nqueue; } /*-------------------------------------------------------------------- -- 2.39.5