r2664 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Sat Jun 14 16:14:28 CEST 2008


Author: phk
Date: 2008-06-14 16:14:28 +0200 (Sat, 14 Jun 2008)
New Revision: 2664

Modified:
   trunk/varnish-cache/bin/varnishd/cache_pool.c
Log:
Slightly change the criteria for starting new worker threads:  Don't
do it if the number of queued threads dropped since last inspection.


Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2008-06-11 21:12:26 UTC (rev 2663)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2008-06-14 14:14:28 UTC (rev 2664)
@@ -82,6 +82,7 @@
 	VTAILQ_HEAD(, workreq)	overflow;
 	unsigned		nthr;
 	unsigned		nqueue;
+	unsigned		lqueue;
 	uintmax_t		ndrop;
 	uintmax_t		noverflow;
 };
@@ -494,8 +495,9 @@
 	 * 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 @@
 			(void)usleep(params->wthread_add_delay * 1000);
 		}
 	}
+	qp->lqueue = qp->nqueue;
 }
 
 /*--------------------------------------------------------------------




More information about the varnish-commit mailing list