Commit 74c119c8 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

param: Fold mgt_pool.c into mgt_param_tweak.c

Refs #3250
parent fa681397
......@@ -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 \
......
......@@ -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);
}
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2011 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@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);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment