[master] a6de126 Use tweak_bytes() for wthread params.

Poul-Henning Kamp phk at varnish-cache.org
Mon Feb 20 12:01:04 CET 2012


commit a6de1269903d07c0550ebf1cf465d0760ff849f1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 20 11:00:37 2012 +0000

    Use tweak_bytes() for wthread params.
    
    Reduce stacksize to 32k.

diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h
index 916fad8..5c65f6e 100644
--- a/bin/varnishd/common/params.h
+++ b/bin/varnishd/common/params.h
@@ -69,7 +69,7 @@ struct params {
 	unsigned		wthread_fail_delay;
 	unsigned		wthread_purge_delay;
 	unsigned		wthread_stats_rate;
-	unsigned		wthread_stacksize;
+	ssize_t			wthread_stacksize;
 
 	unsigned		queue_max;
 
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index a74fd17..97ac5da 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -406,22 +406,19 @@ main(int argc, char * const *argv)
 		 * Adjust default parameters for 32 bit systems to conserve
 		 * VM space.
 		 */
-		MCF_ParamSet(cli, "workspace_client", "16384");
+		MCF_ParamSet(cli, "workspace_client", "16k");
 		cli_check(cli);
 
-		MCF_ParamSet(cli, "workspace_backend", "16384");
+		MCF_ParamSet(cli, "workspace_backend", "16k");
 		cli_check(cli);
 
-		MCF_ParamSet(cli, "http_resp_size", "8192");
+		MCF_ParamSet(cli, "http_resp_size", "8k");
 		cli_check(cli);
 
-		MCF_ParamSet(cli, "http_req_size", "12288");
+		MCF_ParamSet(cli, "http_req_size", "12k");
 		cli_check(cli);
 
-		MCF_ParamSet(cli, "thread_pool_stack", "32bit");
-		cli_check(cli);
-
-		MCF_ParamSet(cli, "gzip_buffer", "4096");
+		MCF_ParamSet(cli, "gzip_buffer", "4k");
 		cli_check(cli);
 	}
 
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 255a3ef..9e42e06 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -350,7 +350,7 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg,
 
 /*--------------------------------------------------------------------*/
 
-static void
+void
 tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg)
 {
 	volatile ssize_t *dest;
diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h
index 275dfe6..a5d4d75 100644
--- a/bin/varnishd/mgt/mgt_param.h
+++ b/bin/varnishd/mgt/mgt_param.h
@@ -54,6 +54,7 @@ int tweak_generic_uint(struct cli *cli,
 void tweak_uint(struct cli *cli, const struct parspec *par, const char *arg);
 void tweak_timeout(struct cli *cli,
     const struct parspec *par, const char *arg);
+void tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg);
 
 /* mgt_pool.c */
 extern const struct parspec WRK_parspec[];
diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c
index a6f020c..e5d5cd0 100644
--- a/bin/varnishd/mgt/mgt_pool.c
+++ b/bin/varnishd/mgt/mgt_pool.c
@@ -73,21 +73,13 @@ static void
 tweak_stack_size(struct cli *cli, const struct parspec *par,
     const char *arg)
 {
-	unsigned low, u;
-	char buf[12];
+	ssize_t low;
 
 	low = sysconf(_SC_THREAD_STACK_MIN);
 
-	if (arg != NULL && !strcmp(arg, "32bit")) {
-		u = 65536;
-		if (u < low)
-			u = low;
-		sprintf(buf, "%u", u);
-		arg = buf;
-	}
-
-	(void)tweak_generic_uint(cli, &mgt_param.wthread_stacksize, arg,
-	    low, (uint)par->max);
+	tweak_bytes(cli, par, arg);
+	if (mgt_param.wthread_stacksize < low)
+		mgt_param.wthread_stacksize = low;
 }
 
 /*--------------------------------------------------------------------*/
@@ -221,9 +213,8 @@ const struct parspec WRK_parspec[] = {
 		tweak_stack_size, &mgt_param.wthread_stacksize, 0, UINT_MAX,
 		"Worker thread stack size.\n"
 		"This is likely rounded up to a multiple of 4k by the kernel.\n"
-		"On 32bit systems you may need to tweak this down to fit "
-		"many threads into the limited address space.\n",
+		"The kernel/OS has a lower limit which will be enforced.\n",
 		EXPERIMENTAL,
-		"-1", "bytes" },
+		"32k", "bytes" },
 	{ NULL, NULL, NULL }
 };



More information about the varnish-commit mailing list