[master] 74c119c88 param: Fold mgt_pool.c into mgt_param_tweak.c

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Oct 21 17:24:13 UTC 2020


commit 74c119c88d77636843d0416c23060fd80d0cbf24
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Wed Oct 21 18:50:52 2020 +0200

    param: Fold mgt_pool.c into mgt_param_tweak.c
    
    Refs #3250

diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index 3b87ddfe6..edc6a3ff3 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -88,7 +88,6 @@ varnishd_SOURCES = \
 	mgt/mgt_param_tbl.c \
 	mgt/mgt_param_tcp.c \
 	mgt/mgt_param_tweak.c \
-	mgt/mgt_pool.c \
 	mgt/mgt_shmem.c \
 	mgt/mgt_symtab.c \
 	mgt/mgt_util.c \
diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c
index a947fd52b..fe06f1ce5 100644
--- a/bin/varnishd/mgt/mgt_param_tweak.c
+++ b/bin/varnishd/mgt/mgt_param_tweak.c
@@ -449,3 +449,37 @@ tweak_poolparam(struct vsb *vsb, const struct parspec *par, const char *arg)
 	}
 	return (retval);
 }
+
+/*--------------------------------------------------------------------
+ * Thread pool tweaks.
+ *
+ * The min/max values automatically update the opposites appropriate
+ * limit, so they don't end up crossing.
+ */
+
+int
+tweak_thread_pool_min(struct vsb *vsb, const struct parspec *par,
+    const char *arg)
+{
+	if (tweak_uint(vsb, par, arg))
+		return (-1);
+
+	MCF_ParamConf(MCF_MINIMUM, "thread_pool_max",
+	    "%u", mgt_param.wthread_min);
+	MCF_ParamConf(MCF_MAXIMUM, "thread_pool_reserve",
+	    "%u", mgt_param.wthread_min * 950 / 1000);
+	return (0);
+}
+
+int
+tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par,
+    const char *arg)
+{
+
+	if (tweak_uint(vsb, par, arg))
+		return (-1);
+
+	MCF_ParamConf(MCF_MAXIMUM, "thread_pool_min",
+	    "%u", mgt_param.wthread_max);
+	return (0);
+}
diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c
deleted file mode 100644
index 02606bcc0..000000000
--- a/bin/varnishd/mgt/mgt_pool.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*-
- * Copyright (c) 2006 Verdens Gang AS
- * Copyright (c) 2006-2011 Varnish Software AS
- * All rights reserved.
- *
- * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
- *
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * We maintain a number of worker thread pools, to spread lock contention.
- *
- * Pools can be added on the fly, as a means to mitigate lock contention,
- * but can only be removed again by a restart. (XXX: we could fix that)
- *
- * Two threads herd the pools, one eliminates idle threads and aggregates
- * statistics for all the pools, the other thread creates new threads
- * on demand, subject to various numerical constraints.
- *
- * The algorithm for when to create threads needs to be reactive enough
- * to handle startup spikes, but sufficiently attenuated to not cause
- * thread pileups.  This remains subject for improvement.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-
-#include "mgt/mgt.h"
-
-#include "mgt/mgt_param.h"
-
-/*--------------------------------------------------------------------
- * The min/max values automatically update the opposites appropriate
- * limit, so they don't end up crossing.
- */
-
-int
-tweak_thread_pool_min(struct vsb *vsb, const struct parspec *par,
-    const char *arg)
-{
-	if (tweak_uint(vsb, par, arg))
-		return (-1);
-
-	MCF_ParamConf(MCF_MINIMUM, "thread_pool_max",
-	    "%u", mgt_param.wthread_min);
-	MCF_ParamConf(MCF_MAXIMUM, "thread_pool_reserve",
-	    "%u", mgt_param.wthread_min * 950 / 1000);
-	return (0);
-}
-
-int
-tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par,
-    const char *arg)
-{
-
-	if (tweak_uint(vsb, par, arg))
-		return (-1);
-
-	MCF_ParamConf(MCF_MAXIMUM, "thread_pool_min",
-	    "%u", mgt_param.wthread_max);
-	return (0);
-}


More information about the varnish-commit mailing list