Commit da279c2e authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Move def and units fields up in struct parspec

It's a bit weird that the default value and the unit is separated from
the min and max. This aligns struct parspec field order with the PARAM()
macro for these two fields.

In static parspec definitions, the flags field can now be omitted if
there are no flags, and the parameter is not subject to dynamic bounds.
parent f3bbf042
...@@ -43,6 +43,8 @@ struct parspec { ...@@ -43,6 +43,8 @@ struct parspec {
volatile void *priv; volatile void *priv;
const char *min; const char *min;
const char *max; const char *max;
const char *def;
const char *units;
const char *descr; const char *descr;
int flags; int flags;
#define DELAYED_EFFECT (1<<0) #define DELAYED_EFFECT (1<<0)
...@@ -55,9 +57,6 @@ struct parspec { ...@@ -55,9 +57,6 @@ struct parspec {
#define ONLY_ROOT (1<<7) #define ONLY_ROOT (1<<7)
#define NOT_IMPLEMENTED (1<<8) #define NOT_IMPLEMENTED (1<<8)
const char *def;
const char *units;
const char *dyn_min_reason; const char *dyn_min_reason;
const char *dyn_max_reason; const char *dyn_max_reason;
char *dyn_min; char *dyn_min;
......
...@@ -252,27 +252,32 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg) ...@@ -252,27 +252,32 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg)
*/ */
struct parspec VSL_parspec[] = { struct parspec VSL_parspec[] = {
{ "vsl_mask", tweak_vsl_mask, NULL, NULL, NULL, { "vsl_mask", tweak_vsl_mask, NULL,
NULL, NULL, "default",
NULL,
"Mask individual VSL messages from being logged.\n" "Mask individual VSL messages from being logged.\n"
"\tdefault\tSet default value\n" "\tdefault\tSet default value\n"
"\nUse +/- prefix in front of VSL tag name to unmask/mask " "\nUse +/- prefix in front of VSL tag name to unmask/mask "
"individual VSL messages.", "individual VSL messages." },
0, "default", "" }, { "debug", tweak_debug, NULL,
{ "debug", tweak_debug, NULL, NULL, NULL, NULL, NULL, "none",
NULL,
"Enable/Disable various kinds of debugging.\n" "Enable/Disable various kinds of debugging.\n"
"\tnone\tDisable all debugging\n\n" "\tnone\tDisable all debugging\n\n"
"Use +/- prefix to set/reset individual bits:" "Use +/- prefix to set/reset individual bits:"
#define DEBUG_BIT(U, l, d) "\n\t" #l "\t" d #define DEBUG_BIT(U, l, d) "\n\t" #l "\t" d
#include "tbl/debug_bits.h" #include "tbl/debug_bits.h"
#undef DEBUG_BIT #undef DEBUG_BIT
, 0, "none", "" }, },
{ "feature", tweak_feature, NULL, NULL, NULL, { "feature", tweak_feature, NULL,
NULL, NULL, "none",
NULL,
"Enable/Disable various minor features.\n" "Enable/Disable various minor features.\n"
"\tnone\tDisable all features.\n\n" "\tnone\tDisable all features.\n\n"
"Use +/- prefix to enable/disable individual feature:" "Use +/- prefix to enable/disable individual feature:"
#define FEATURE_BIT(U, l, d, ld) "\n\t" #l "\t" d #define FEATURE_BIT(U, l, d, ld) "\n\t" #l "\t" d
#include "tbl/feature_bits.h" #include "tbl/feature_bits.h"
#undef FEATURE_BIT #undef FEATURE_BIT
, 0, "none", "" }, },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
...@@ -46,66 +46,59 @@ ...@@ -46,66 +46,59 @@
struct parspec mgt_parspec[] = { struct parspec mgt_parspec[] = {
#define PARAM(nm, ty, mi, ma, de, un, fl, st, ...) \ #define PARAM(nm, ty, mi, ma, de, un, fl, st, ...) \
{ #nm, tweak_##ty, &mgt_param.nm, mi, ma, st, fl, de, un, \ { #nm, tweak_##ty, &mgt_param.nm, mi, ma, de, un, st, fl, \
__VA_ARGS__ }, __VA_ARGS__ },
#include "tbl/params.h" #include "tbl/params.h"
{ "cc_command", tweak_string, &mgt_cc_cmd, { "cc_command", tweak_string, &mgt_cc_cmd,
NULL, NULL, NULL, NULL, VCC_CC,
NULL,
"Command used for compiling the C source code to a " "Command used for compiling the C source code to a "
"dlopen(3) loadable object. Any occurrence of %s in " "dlopen(3) loadable object. Any occurrence of %s in "
"the string will be replaced with the source file name, " "the string will be replaced with the source file name, "
"and %o will be replaced with the output file name.", "and %o will be replaced with the output file name.",
MUST_RELOAD, MUST_RELOAD },
VCC_CC , NULL },
{ "vcl_path", tweak_string, &mgt_vcl_path, { "vcl_path", tweak_string, &mgt_vcl_path,
NULL, NULL, NULL, NULL, VARNISH_VCL_DIR,
NULL,
"Directory (or colon separated list of directories) " "Directory (or colon separated list of directories) "
"from which relative VCL filenames (vcl.load and " "from which relative VCL filenames (vcl.load and "
"include) are to be found. By default Varnish searches " "include) are to be found. By default Varnish searches "
"VCL files in both the system configuration and shared " "VCL files in both the system configuration and shared "
"data directories to allow packages to drop their VCL " "data directories to allow packages to drop their VCL "
"files in a standard location where relative includes " "files in a standard location where relative includes "
"would work.", "would work." },
0,
VARNISH_VCL_DIR,
NULL },
{ "vmod_path", tweak_string, &mgt_vmod_path, { "vmod_path", tweak_string, &mgt_vmod_path,
NULL, NULL, NULL, NULL, VARNISH_VMOD_DIR,
NULL,
"Directory (or colon separated list of directories) " "Directory (or colon separated list of directories) "
"where VMODs are to be found.", "where VMODs are to be found." },
0,
VARNISH_VMOD_DIR,
NULL },
{ "vcc_err_unref", tweak_bool, &mgt_vcc_err_unref, { "vcc_err_unref", tweak_bool, &mgt_vcc_err_unref,
NULL, NULL, NULL, NULL, "on",
"Unreferenced VCL objects result in error.", "bool",
0, "Unreferenced VCL objects result in error." },
"on", "bool" },
{ "vcc_allow_inline_c", tweak_bool, &mgt_vcc_allow_inline_c, { "vcc_allow_inline_c", tweak_bool, &mgt_vcc_allow_inline_c,
NULL, NULL, NULL, NULL, "off",
"Allow inline C code in VCL.", "bool",
0, "Allow inline C code in VCL." },
"off", "bool" },
{ "vcc_unsafe_path", tweak_bool, &mgt_vcc_unsafe_path, { "vcc_unsafe_path", tweak_bool, &mgt_vcc_unsafe_path,
NULL, NULL, NULL, NULL, "on",
"bool",
"Allow '/' in vmod & include paths.\n" "Allow '/' in vmod & include paths.\n"
"Allow 'import ... from ...'.", "Allow 'import ... from ...'." },
0,
"on", "bool" },
{ "pcre_match_limit", tweak_uint, { "pcre_match_limit", tweak_uint,
&mgt_param.vre_limits.match, &mgt_param.vre_limits.match,
"1", NULL, "1", NULL, "10000",
NULL,
"The limit for the number of calls to the internal match()" "The limit for the number of calls to the internal match()"
" function in pcre_exec().\n\n" " function in pcre_exec().\n\n"
"(See: PCRE_EXTRA_MATCH_LIMIT in pcre docs.)\n\n" "(See: PCRE_EXTRA_MATCH_LIMIT in pcre docs.)\n\n"
"This parameter limits how much CPU time" "This parameter limits how much CPU time"
" regular expression matching can soak up.", " regular expression matching can soak up." },
0,
"10000", ""},
{ "pcre_match_limit_recursion", tweak_uint, { "pcre_match_limit_recursion", tweak_uint,
&mgt_param.vre_limits.match_recursion, &mgt_param.vre_limits.match_recursion,
"1", NULL, "1", NULL, "20",
NULL,
"The recursion depth-limit for the internal match() function" "The recursion depth-limit for the internal match() function"
" in a pcre_exec().\n\n" " in a pcre_exec().\n\n"
"(See: PCRE_EXTRA_MATCH_LIMIT_RECURSION in pcre docs.)\n\n" "(See: PCRE_EXTRA_MATCH_LIMIT_RECURSION in pcre docs.)\n\n"
...@@ -116,27 +109,22 @@ struct parspec mgt_parspec[] = { ...@@ -116,27 +109,22 @@ struct parspec mgt_parspec[] = {
" matching failures.\n\n" " matching failures.\n\n"
"Matching failures will show up in the log as VCL_Error" "Matching failures will show up in the log as VCL_Error"
" messages with regexp errors -27 or -21.\n\n" " messages with regexp errors -27 or -21.\n\n"
"Testcase r01576 can be useful when tuning this parameter.", "Testcase r01576 can be useful when tuning this parameter." },
0,
"20", ""},
{ "pool_req", tweak_poolparam, &mgt_param.req_pool, { "pool_req", tweak_poolparam, &mgt_param.req_pool,
NULL, NULL, NULL, NULL, "10,100,10",
NULL,
"Parameters for per worker pool request memory pool.\n\n" "Parameters for per worker pool request memory pool.\n\n"
MEMPOOL_TEXT, MEMPOOL_TEXT },
0,
"10,100,10", ""},
{ "pool_sess", tweak_poolparam, &mgt_param.sess_pool, { "pool_sess", tweak_poolparam, &mgt_param.sess_pool,
NULL, NULL, NULL, NULL, "10,100,10",
NULL,
"Parameters for per worker pool session memory pool.\n\n" "Parameters for per worker pool session memory pool.\n\n"
MEMPOOL_TEXT, MEMPOOL_TEXT },
0,
"10,100,10", ""},
{ "pool_vbo", tweak_poolparam, &mgt_param.vbo_pool, { "pool_vbo", tweak_poolparam, &mgt_param.vbo_pool,
NULL, NULL, NULL, NULL, "10,100,10",
NULL,
"Parameters for backend object fetch memory pool.\n\n" "Parameters for backend object fetch memory pool.\n\n"
MEMPOOL_TEXT, MEMPOOL_TEXT },
0,
"10,100,10", ""},
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
...@@ -89,7 +89,8 @@ tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par, ...@@ -89,7 +89,8 @@ tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par,
struct parspec WRK_parspec[] = { struct parspec WRK_parspec[] = {
{ "thread_pools", tweak_uint, &mgt_param.wthread_pools, { "thread_pools", tweak_uint, &mgt_param.wthread_pools,
"1", NULL, "1", NULL, "2",
"pools",
"Number of worker thread pools.\n" "Number of worker thread pools.\n"
"\n" "\n"
"Increasing the number of worker pools decreases lock " "Increasing the number of worker pools decreases lock "
...@@ -103,21 +104,20 @@ struct parspec WRK_parspec[] = { ...@@ -103,21 +104,20 @@ struct parspec WRK_parspec[] = {
"\n" "\n"
"Can be increased on the fly, but decreases require a " "Can be increased on the fly, but decreases require a "
"restart to take effect.", "restart to take effect.",
EXPERIMENTAL | DELAYED_EFFECT, EXPERIMENTAL | DELAYED_EFFECT },
"2", "pools" },
{ "thread_pool_max", tweak_thread_pool_max, &mgt_param.wthread_max, { "thread_pool_max", tweak_thread_pool_max, &mgt_param.wthread_max,
NULL, NULL, NULL, NULL, "5000",
"threads",
"The maximum number of worker threads in each pool.\n" "The maximum number of worker threads in each pool.\n"
"\n" "\n"
"Do not set this higher than you have to, since excess " "Do not set this higher than you have to, since excess "
"worker threads soak up RAM and CPU and generally just get " "worker threads soak up RAM and CPU and generally just get "
"in the way of getting work done.", "in the way of getting work done.",
DELAYED_EFFECT, DELAYED_EFFECT,
"5000", "threads",
"thread_pool_min" }, "thread_pool_min" },
{ "thread_pool_min", tweak_thread_pool_min, &mgt_param.wthread_min, { "thread_pool_min", tweak_thread_pool_min, &mgt_param.wthread_min,
"5", // TASK_QUEUE__END "5" /* TASK_QUEUE__END */, NULL, "100",
NULL, "threads",
"The minimum number of worker threads in each pool.\n" "The minimum number of worker threads in each pool.\n"
"\n" "\n"
"Increasing this may help ramp up faster from low load " "Increasing this may help ramp up faster from low load "
...@@ -127,11 +127,11 @@ struct parspec WRK_parspec[] = { ...@@ -127,11 +127,11 @@ struct parspec WRK_parspec[] = {
"but this parameter is strongly recommended to be " "but this parameter is strongly recommended to be "
"at least 10", // 2 * TASK_QUEUE__END "at least 10", // 2 * TASK_QUEUE__END
DELAYED_EFFECT, DELAYED_EFFECT,
"100", "threads",
NULL, "thread_pool_max" }, NULL, "thread_pool_max" },
{ "thread_pool_reserve", tweak_uint, { "thread_pool_reserve", tweak_uint,
&mgt_param.wthread_reserve, &mgt_param.wthread_reserve,
NULL, NULL, NULL, NULL, "0",
"threads",
"The number of worker threads reserved for vital tasks " "The number of worker threads reserved for vital tasks "
"in each pool.\n" "in each pool.\n"
"\n" "\n"
...@@ -147,37 +147,37 @@ struct parspec WRK_parspec[] = { ...@@ -147,37 +147,37 @@ struct parspec WRK_parspec[] = {
"Default is 0 to auto-tune (5% of thread_pool_min).\n" "Default is 0 to auto-tune (5% of thread_pool_min).\n"
"Minimum is 1 otherwise, maximum is 95% of thread_pool_min.", "Minimum is 1 otherwise, maximum is 95% of thread_pool_min.",
DELAYED_EFFECT, DELAYED_EFFECT,
"0", "threads",
NULL, "95% of thread_pool_min" }, NULL, "95% of thread_pool_min" },
{ "thread_pool_timeout", { "thread_pool_timeout",
tweak_timeout, &mgt_param.wthread_timeout, tweak_timeout, &mgt_param.wthread_timeout,
"10", NULL, "10", NULL, "300",
"seconds",
"Thread idle threshold.\n" "Thread idle threshold.\n"
"\n" "\n"
"Threads in excess of thread_pool_min, which have been idle " "Threads in excess of thread_pool_min, which have been idle "
"for at least this long, will be destroyed.", "for at least this long, will be destroyed.",
EXPERIMENTAL | DELAYED_EFFECT, EXPERIMENTAL | DELAYED_EFFECT },
"300", "seconds" },
{ "thread_pool_watchdog", { "thread_pool_watchdog",
tweak_timeout, &mgt_param.wthread_watchdog, tweak_timeout, &mgt_param.wthread_watchdog,
"0.1", NULL, "0.1", NULL, "60",
"seconds",
"Thread queue stuck watchdog.\n" "Thread queue stuck watchdog.\n"
"\n" "\n"
"If no queued work have been released for this long," "If no queued work have been released for this long,"
" the worker process panics itself.", " the worker process panics itself.",
EXPERIMENTAL, EXPERIMENTAL },
"60", "seconds" },
{ "thread_pool_destroy_delay", { "thread_pool_destroy_delay",
tweak_timeout, &mgt_param.wthread_destroy_delay, tweak_timeout, &mgt_param.wthread_destroy_delay,
"0.01", NULL, "0.01", NULL, "1",
"seconds",
"Wait this long after destroying a thread.\n" "Wait this long after destroying a thread.\n"
"\n" "\n"
"This controls the decay of thread pools when idle(-ish).", "This controls the decay of thread pools when idle(-ish).",
EXPERIMENTAL | DELAYED_EFFECT, EXPERIMENTAL | DELAYED_EFFECT },
"1", "seconds" },
{ "thread_pool_add_delay", { "thread_pool_add_delay",
tweak_timeout, &mgt_param.wthread_add_delay, tweak_timeout, &mgt_param.wthread_add_delay,
"0", NULL, "0", NULL, "0",
"seconds",
"Wait at least this long after creating a thread.\n" "Wait at least this long after creating a thread.\n"
"\n" "\n"
"Some (buggy) systems may need a short (sub-second) " "Some (buggy) systems may need a short (sub-second) "
...@@ -186,11 +186,11 @@ struct parspec WRK_parspec[] = { ...@@ -186,11 +186,11 @@ struct parspec WRK_parspec[] = {
"'threads_failed' counter grow too much.\n" "'threads_failed' counter grow too much.\n"
"\n" "\n"
"Setting this too high results in insufficient worker threads.", "Setting this too high results in insufficient worker threads.",
EXPERIMENTAL, EXPERIMENTAL },
"0", "seconds" },
{ "thread_pool_fail_delay", { "thread_pool_fail_delay",
tweak_timeout, &mgt_param.wthread_fail_delay, tweak_timeout, &mgt_param.wthread_fail_delay,
"10e-3", NULL, "10e-3", NULL, "0.2",
"seconds",
"Wait at least this long after a failed thread creation " "Wait at least this long after a failed thread creation "
"before trying to create another thread.\n" "before trying to create another thread.\n"
"\n" "\n"
...@@ -205,31 +205,31 @@ struct parspec WRK_parspec[] = { ...@@ -205,31 +205,31 @@ struct parspec WRK_parspec[] = {
"It may also help to increase thread_pool_timeout and " "It may also help to increase thread_pool_timeout and "
"thread_pool_min, to reduce the rate at which treads are " "thread_pool_min, to reduce the rate at which treads are "
"destroyed and later recreated.", "destroyed and later recreated.",
EXPERIMENTAL, EXPERIMENTAL },
"0.2", "seconds" },
{ "thread_stats_rate", { "thread_stats_rate",
tweak_uint, &mgt_param.wthread_stats_rate, tweak_uint, &mgt_param.wthread_stats_rate,
"0", NULL, "0", NULL, "10",
"requests",
"Worker threads accumulate statistics, and dump these into " "Worker threads accumulate statistics, and dump these into "
"the global stats counters if the lock is free when they " "the global stats counters if the lock is free when they "
"finish a job (request/fetch etc.)\n" "finish a job (request/fetch etc.)\n"
"This parameters defines the maximum number of jobs " "This parameters defines the maximum number of jobs "
"a worker thread may handle, before it is forced to dump " "a worker thread may handle, before it is forced to dump "
"its accumulated stats into the global counters.", "its accumulated stats into the global counters.",
EXPERIMENTAL, EXPERIMENTAL },
"10", "requests" },
{ "thread_queue_limit", tweak_uint, &mgt_param.wthread_queue_limit, { "thread_queue_limit", tweak_uint, &mgt_param.wthread_queue_limit,
"0", NULL, "0", NULL, "20",
NULL,
"Permitted request queue length per thread-pool.\n" "Permitted request queue length per thread-pool.\n"
"\n" "\n"
"This sets the number of requests we will queue, waiting " "This sets the number of requests we will queue, waiting "
"for an available thread. Above this limit sessions will " "for an available thread. Above this limit sessions will "
"be dropped instead of queued.", "be dropped instead of queued.",
EXPERIMENTAL, EXPERIMENTAL },
"20", "" },
{ "thread_pool_stack", { "thread_pool_stack",
tweak_bytes, &mgt_param.wthread_stacksize, tweak_bytes, &mgt_param.wthread_stacksize,
NULL, NULL, NULL, NULL, NULL, // default set in mgt_main.c
"bytes",
"Worker thread stack size.\n" "Worker thread stack size.\n"
"This will likely be rounded up to a multiple of 4k" "This will likely be rounded up to a multiple of 4k"
" (or whatever the page_size might be) by the kernel.\n" " (or whatever the page_size might be) by the kernel.\n"
...@@ -264,7 +264,6 @@ struct parspec WRK_parspec[] = { ...@@ -264,7 +264,6 @@ struct parspec WRK_parspec[] = {
" overflow occurs. Setting it in 150%-200%" " overflow occurs. Setting it in 150%-200%"
" increments is recommended until stack overflows" " increments is recommended until stack overflows"
" cease to occur.", " cease to occur.",
DELAYED_EFFECT, DELAYED_EFFECT },
NULL, "bytes" }, // default set in mgt_main.c
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };
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