Commit a02b81da authored by Monty's avatar Monty

Moved autosetting of host_cache_size and back_log to proper place

- Clean up formulas and comments for host_cache_size and back_log
- Added test of autoset (for host_cache_size)
- Marked open_files_limit as auto_set
parent 742263df
......@@ -569,9 +569,10 @@ The following options may be given as the first argument:
--open-files-limit=#
If this is not 0, then mysqld will use this value to
reserve file descriptors to use with setrlimit(). If this
value is 0 then mysqld will reserve max_connections*5 or
max_connections + table_cache*2 (whichever is larger)
number of file descriptors
value is 0 or autoset then mysqld will reserve
max_connections*5 or max_connections + table_cache*2
(whichever is larger) number of file descriptors
(Automatically configured unless set explicitly)
--optimizer-prune-level=#
Controls the heuristic(s) applied during query
optimization to prune less-promising partial plans from
......
select @@global.host_cache_size;
@@global.host_cache_size
653
......@@ -5216,7 +5216,7 @@ COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME OPEN_FILES_LIMIT
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
VARIABLE_COMMENT If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 or autoset then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 4294967295
NUMERIC_BLOCK_SIZE 1
......
--max_connections=1000 --open-files-limit=1000 --autoset-host-cache-size
......@@ -4400,21 +4400,6 @@ static int init_common_variables()
SYSVAR_AUTOSIZE(threadpool_size, my_getncpus());
#endif
/* Fix host_cache_size. */
if (IS_SYSVAR_AUTOSIZE(&host_cache_size))
{
if (max_connections <= 628 - 128)
SYSVAR_AUTOSIZE(host_cache_size, 128 + max_connections);
else if (max_connections <= ((ulong)(2000 - 628)) * 20 + 500)
SYSVAR_AUTOSIZE(host_cache_size, 628 + ((max_connections - 500) / 20));
else
SYSVAR_AUTOSIZE(host_cache_size, 2000);
}
/* Fix back_log (back_log == 0 added for MySQL compatibility) */
if (back_log == 0 || IS_SYSVAR_AUTOSIZE(&back_log))
SYSVAR_AUTOSIZE(back_log, MY_MIN(900, (50 + max_connections / 5)));
/* connections and databases needs lots of files */
{
uint files, wanted_files, max_open_files;
......@@ -4439,7 +4424,7 @@ static int init_common_variables()
if (files < wanted_files)
{
if (!open_files_limit)
if (!open_files_limit || IS_SYSVAR_AUTOSIZE(&open_files_limit))
{
/*
If we have requested too much file handles than we bring
......@@ -4468,6 +4453,36 @@ static int init_common_variables()
}
SYSVAR_AUTOSIZE(open_files_limit, files);
}
/*
Max_connections is now set.
Now we can fix other variables depending on this variable.
*/
/* Fix host_cache_size */
if (IS_SYSVAR_AUTOSIZE(&host_cache_size))
{
/*
The default value is 128.
The autoset value is 128, plus 1 for a value of max_connections
up to 500, plus 1 for every increment of 20 over 500 in the
max_connections value, capped at 2000.
*/
uint size= (HOST_CACHE_SIZE + MY_MIN(max_connections, 500) +
MY_MAX(((long) max_connections)-500,0)/20);
SYSVAR_AUTOSIZE(host_cache_size, size);
}
/* Fix back_log (back_log == 0 added for MySQL compatibility) */
if (back_log == 0 || IS_SYSVAR_AUTOSIZE(&back_log))
{
/*
The default value is 150.
The autoset value is 50 + max_connections / 5 capped at 900
*/
SYSVAR_AUTOSIZE(back_log, MY_MIN(900, (50 + max_connections / 5)));
}
unireg_init(opt_specialflag); /* Set up extern variabels */
if (!(my_default_lc_messages=
my_locale_by_name(lc_messages)))
......
......@@ -2311,10 +2311,10 @@ export sys_var *Sys_old_passwords_ptr= &Sys_old_passwords; // for sql_acl.cc
static Sys_var_ulong Sys_open_files_limit(
"open_files_limit",
"If this is not 0, then mysqld will use this value to reserve file "
"descriptors to use with setrlimit(). If this value is 0 then mysqld "
"will reserve max_connections*5 or max_connections + table_cache*2 "
"(whichever is larger) number of file descriptors",
READ_ONLY GLOBAL_VAR(open_files_limit), CMD_LINE(REQUIRED_ARG),
"descriptors to use with setrlimit(). If this value is 0 or autoset "
"then mysqld will reserve max_connections*5 or max_connections + "
"table_cache*2 (whichever is larger) number of file descriptors",
AUTO_SET READ_ONLY GLOBAL_VAR(open_files_limit), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, OS_FILE_LIMIT), DEFAULT(0), BLOCK_SIZE(1));
/// @todo change to enum
......
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