diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2019-05-31 08:28:22 +0000 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2019-05-31 15:04:11 +0200 |
commit | daeaa600ef4cbd9ee79cc2a6fd34bd753137db41 (patch) | |
tree | dc246353c1de26a286a1bdc02a75b41eba1b6ab5 | |
parent | 28fad39de718c6c070f357f6d5a72ee6ac4bd804 (diff) | |
download | mariadb-git-daeaa600ef4cbd9ee79cc2a6fd34bd753137db41.tar.gz |
MDEV-19312 Make throttling interval depend on thread_pool_stall_limit
A thread_pool_stall_limit which is smaller than default would result
in quicker creation of threads.
-rw-r--r-- | mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/r/thread_pool_stall_limit_basic.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/t/thread_pool_stall_limit_basic.test | 1 | ||||
-rw-r--r-- | sql/sys_vars.cc | 2 | ||||
-rw-r--r-- | sql/threadpool.h | 3 | ||||
-rw-r--r-- | sql/threadpool_generic.cc | 20 |
6 files changed, 16 insertions, 14 deletions
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 8d7bf6356aa..043cd983734 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -5466,7 +5466,7 @@ DEFAULT_VALUE 500 VARIABLE_SCOPE GLOBAL VARIABLE_TYPE INT UNSIGNED VARIABLE_COMMENT Maximum query execution time in milliseconds,before an executing non-yielding thread is considered stalled.If a worker thread is stalled, additional worker thread may be created to handle remaining clients. -NUMERIC_MIN_VALUE 10 +NUMERIC_MIN_VALUE 1 NUMERIC_MAX_VALUE 4294967295 NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL diff --git a/mysql-test/suite/sys_vars/r/thread_pool_stall_limit_basic.result b/mysql-test/suite/sys_vars/r/thread_pool_stall_limit_basic.result index eda4e6baebe..0a4d8dea6d2 100644 --- a/mysql-test/suite/sys_vars/r/thread_pool_stall_limit_basic.result +++ b/mysql-test/suite/sys_vars/r/thread_pool_stall_limit_basic.result @@ -37,7 +37,7 @@ Warnings: Warning 1292 Truncated incorrect thread_pool_stall_limit value: '-1' select @@global.thread_pool_stall_limit; @@global.thread_pool_stall_limit -10 +1 set global thread_pool_stall_limit=10000000000; Warnings: Warning 1292 Truncated incorrect thread_pool_stall_limit value: '10000000000' diff --git a/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_basic.test b/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_basic.test index 9b4e1df7ab0..1ab27907535 100644 --- a/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_basic.test +++ b/mysql-test/suite/sys_vars/t/thread_pool_stall_limit_basic.test @@ -1,5 +1,4 @@ # uint global ---source include/not_windows.inc --source include/not_embedded.inc SET @start_global_value = @@global.thread_pool_stall_limit; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index a42a870d68f..7bc294fcc99 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3733,7 +3733,7 @@ static Sys_var_uint Sys_threadpool_stall_limit( "If a worker thread is stalled, additional worker thread " "may be created to handle remaining clients.", GLOBAL_VAR(threadpool_stall_limit), CMD_LINE(REQUIRED_ARG), - VALID_RANGE(10, UINT_MAX), DEFAULT(500), BLOCK_SIZE(1), + VALID_RANGE(1, UINT_MAX), DEFAULT(DEFAULT_THREADPOOL_STALL_LIMIT), BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_threadpool_stall_limit) ); diff --git a/sql/threadpool.h b/sql/threadpool.h index 53ddc2d282d..fe77100a82a 100644 --- a/sql/threadpool.h +++ b/sql/threadpool.h @@ -24,7 +24,7 @@ extern uint threadpool_min_threads; /* Minimum threads in pool */ extern uint threadpool_idle_timeout; /* Shutdown idle worker threads after this timeout */ extern uint threadpool_size; /* Number of parallel executing threads */ extern uint threadpool_max_size; -extern uint threadpool_stall_limit; /* time interval in 10 ms units for stall checks*/ +extern uint threadpool_stall_limit; /* time interval in milliseconds for stall checks*/ extern uint threadpool_max_threads; /* Maximum threads in pool */ extern uint threadpool_oversubscribe; /* Maximum active threads in group */ extern uint threadpool_prio_kickup_timer; /* Time before low prio item gets prio boost */ @@ -36,6 +36,7 @@ extern uint threadpool_mode; /* Thread pool implementation , windows or generic #define TP_MODE_GENERIC 1 #endif +#define DEFAULT_THREADPOOL_STALL_LIMIT 500U struct TP_connection; extern void tp_callback(TP_connection *c); diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc index 162dad2e866..768dbab4e6b 100644 --- a/sql/threadpool_generic.cc +++ b/sql/threadpool_generic.cc @@ -28,6 +28,7 @@ #include <time.h> #include <sql_plist.h> #include <threadpool.h> +#include <algorithm> #ifdef HAVE_IOCP #define OPTIONAL_IO_POLL_READ_PARAM this @@ -865,23 +866,24 @@ end: The actual values were not calculated using any scientific methods. They just look right, and behave well in practice. - - TODO: Should throttling depend on thread_pool_stall_limit? */ + +#define THROTTLING_FACTOR (threadpool_stall_limit/std::max(DEFAULT_THREADPOOL_STALL_LIMIT,threadpool_stall_limit)) + static ulonglong microsecond_throttling_interval(thread_group_t *thread_group) { int count= thread_group->thread_count; - if (count < 4) + if (count < 1+ (int)threadpool_oversubscribe) return 0; - + if (count < 8) - return 50*1000; - + return 50*1000*THROTTLING_FACTOR; + if(count < 16) - return 100*1000; - - return 200*1000; + return 100*1000*THROTTLING_FACTOR; + + return 200*100*THROTTLING_FACTOR; } |