r3028 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Fri Jul 25 21:23:35 CEST 2008


Author: phk
Date: 2008-07-25 21:23:35 +0200 (Fri, 25 Jul 2008)
New Revision: 3028

Modified:
   trunk/varnish-cache/bin/varnishd/cache_pool.c
   trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
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.



Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2008-07-25 18:20:35 UTC (rev 3027)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2008-07-25 19:23:35 UTC (rev 3028)
@@ -91,7 +91,6 @@
 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 @@
 {
 	struct worker *w;
 
-	if (qp->nthr <= nthr_min)
+	if (qp->nthr <= params->wthread_min)
 		return;
 
 	LOCK(&qp->mtx);
@@ -454,14 +453,10 @@
 			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 @@
 	 * 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 @@
 			/*
 			 * 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

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-07-25 18:20:35 UTC (rev 3027)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2008-07-25 19:23:35 UTC (rev 3028)
@@ -274,9 +274,8 @@
 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 @@
 		"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"




More information about the varnish-commit mailing list