Commit 61a4f7de authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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: http://www.varnish-cache.org/svn/trunk/varnish-cache@3028 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 714e0ef6
......@@ -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
......
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment