diff options
author | Monty <monty@mariadb.org> | 2017-09-26 00:12:36 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2017-09-26 00:13:04 +0300 |
commit | a02b81daeaa63c327bea9e6c24fe45b53dc0008e (patch) | |
tree | a4d22136da545fe1b8d363b77b773df08b173dc7 | |
parent | 742263df4f43ac8ffb611de607fb8337296ae949 (diff) | |
download | mariadb-git-a02b81daeaa63c327bea9e6c24fe45b53dc0008e.tar.gz |
Moved autosetting of host_cache_size and back_log to proper placebb-10-3-marko
- 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
-rw-r--r-- | mysql-test/r/mysqld--help.result | 7 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/r/host_cache_size_auto.result | 3 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/t/host_cache_size_auto-master.opt | 1 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/t/host_cache_size_auto.test | 1 | ||||
-rw-r--r-- | sql/mysqld.cc | 47 | ||||
-rw-r--r-- | sql/sys_vars.cc | 8 |
7 files changed, 45 insertions, 24 deletions
diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result index bcc985a8a50..7005a850ea5 100644 --- a/mysql-test/r/mysqld--help.result +++ b/mysql-test/r/mysqld--help.result @@ -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 diff --git a/mysql-test/suite/sys_vars/r/host_cache_size_auto.result b/mysql-test/suite/sys_vars/r/host_cache_size_auto.result new file mode 100644 index 00000000000..a9a683e017b --- /dev/null +++ b/mysql-test/suite/sys_vars/r/host_cache_size_auto.result @@ -0,0 +1,3 @@ +select @@global.host_cache_size; +@@global.host_cache_size +653 diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index 8d68dce0245..329b519588d 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -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 diff --git a/mysql-test/suite/sys_vars/t/host_cache_size_auto-master.opt b/mysql-test/suite/sys_vars/t/host_cache_size_auto-master.opt new file mode 100644 index 00000000000..ae09e3f57ac --- /dev/null +++ b/mysql-test/suite/sys_vars/t/host_cache_size_auto-master.opt @@ -0,0 +1 @@ +--max_connections=1000 --open-files-limit=1000 --autoset-host-cache-size diff --git a/mysql-test/suite/sys_vars/t/host_cache_size_auto.test b/mysql-test/suite/sys_vars/t/host_cache_size_auto.test new file mode 100644 index 00000000000..35846713d70 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/host_cache_size_auto.test @@ -0,0 +1 @@ +select @@global.host_cache_size; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f464ec807f6..e552d0b05a6 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -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))) diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 7405ca7e884..6f3ccfc9823 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -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 |