]> err.no Git - varnish/commitdiff
Change param thread_pool_min to be the minimum number of threads per
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 25 Jul 2008 19:23:35 +0000 (19:23 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 25 Jul 2008 19:23:35 +0000 (19:23 +0000)
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

varnish-cache/bin/varnishd/cache_pool.c
varnish-cache/bin/varnishd/mgt_param.c

index 5de2848ab28c8579405fc4ed864aab7cb096e6cb..912a6472c7ff082170105f989a4f7a826a492fe5 100644 (file)
@@ -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
index 6b4c971116a21e53eba07cc4eee0b43f7359a89c..4e7615fd275693ad7784cc2c23767fba37dc2647 100644 (file)
@@ -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"