]> err.no Git - varnish/commitdiff
Slightly change the criteria for starting new worker threads: Don't
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 14 Jun 2008 14:14:28 +0000 (14:14 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 14 Jun 2008 14:14:28 +0000 (14:14 +0000)
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

index ed53ca2fcf8feab6a4b220b6188314cf9d8f8eba..92daeb45423d1a076ba8a9b5f6ef17a5dadff32e 100644 (file)
@@ -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;
 }
 
 /*--------------------------------------------------------------------