From: phk Date: Fri, 25 Jul 2008 19:23:35 +0000 (+0000) Subject: Change param thread_pool_min to be the minimum number of threads per X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90b2de1dc6c57fddb975dfc7779257e6f88ea1df;p=varnish Change param thread_pool_min to be the minimum number of threads per pool, and don't be so stingy with them: default to five. Make sure we really do create the minimum complement of threads. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3028 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 5de2848a..912a6472 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -91,7 +91,6 @@ static struct wq **wq; static unsigned nwq; static unsigned ovfl_max; static unsigned nthr_max; -static unsigned nthr_min; static pthread_cond_t herder_cond; static MTX herder_mtx; @@ -401,7 +400,7 @@ wrk_decimate_flock(struct wq *qp, double t_idle, struct varnish_stats *vs) { struct worker *w; - if (qp->nthr <= nthr_min) + if (qp->nthr <= params->wthread_min) return; LOCK(&qp->mtx); @@ -454,14 +453,10 @@ wrk_herdtimer_thread(void *priv) wrk_addpools(u); /* Scale parameters */ - u = params->wthread_min / nwq; - if (u < 1) - u = 1; - nthr_min = u; u = params->wthread_max / nwq; - if (u < nthr_min) - u = nthr_min; + if (u < params->wthread_min) + u = params->wthread_min; nthr_max = u; ovfl_max = (nthr_max * params->overflow_max) / 100; @@ -497,7 +492,7 @@ wrk_breed_flock(struct wq *qp) * If we need more threads, and have space, create * one more thread. */ - if (qp->nthr < nthr_min || /* Not enough threads yet */ + if (qp->nthr < params->wthread_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) { @@ -541,10 +536,9 @@ wrk_herder_thread(void *priv) /* * Make sure all pools have their minimum complement */ - for (w = 0 ; w < nwq; w++) { - if (wq[w]->nthr < nthr_min) + for (w = 0 ; w < nwq; w++) + while (wq[w]->nthr < params->wthread_min) wrk_breed_flock(wq[w]); - } /* * We cannot avoid getting a mutex, so we have a * bogo mutex just for POSIX_STUPIDITY diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index 6b4c9711..4e7615fd 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -274,9 +274,8 @@ static void tweak_thread_pool_min(struct cli *cli, const struct parspec *par, const char *arg) { - (void)par; tweak_generic_uint(cli, &master.wthread_min, arg, - 0, master.wthread_max); + par->umin, master.wthread_max); } /*--------------------------------------------------------------------*/ @@ -500,15 +499,15 @@ static const struct parspec parspec[] = { "in the way of getting work done.\n", EXPERIMENTAL | DELAYED_EFFECT, "500", "threads" }, - { "thread_pool_min", tweak_thread_pool_min, NULL, 1, 0, - "The minimum number of threads in all worker pools combined.\n" + { "thread_pool_min", tweak_thread_pool_min, NULL, 2, 0, + "The minimum number of threads in each worker pool.\n" "\n" "Increasing this may help ramp up faster from low load " "situations where threads have expired.\n" "\n" - "Minimum is 1 thread.", + "Minimum is 2 threads.", EXPERIMENTAL | DELAYED_EFFECT, - "1", "threads" }, + "5", "threads" }, { "thread_pool_timeout", tweak_timeout, &master.wthread_timeout, 1, 0, "Thread idle threshold.\n" "\n"