1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

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.
This commit is contained in:
Vladislav Vaintroub
2019-05-31 08:28:22 +00:00
parent 28fad39de7
commit daeaa600ef
6 changed files with 16 additions and 14 deletions

View File

@ -5466,7 +5466,7 @@ DEFAULT_VALUE 500
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE INT UNSIGNED 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. 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_MAX_VALUE 4294967295
NUMERIC_BLOCK_SIZE 1 NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL ENUM_VALUE_LIST NULL

View File

@ -37,7 +37,7 @@ Warnings:
Warning 1292 Truncated incorrect thread_pool_stall_limit value: '-1' Warning 1292 Truncated incorrect thread_pool_stall_limit value: '-1'
select @@global.thread_pool_stall_limit; select @@global.thread_pool_stall_limit;
@@global.thread_pool_stall_limit @@global.thread_pool_stall_limit
10 1
set global thread_pool_stall_limit=10000000000; set global thread_pool_stall_limit=10000000000;
Warnings: Warnings:
Warning 1292 Truncated incorrect thread_pool_stall_limit value: '10000000000' Warning 1292 Truncated incorrect thread_pool_stall_limit value: '10000000000'

View File

@ -1,5 +1,4 @@
# uint global # uint global
--source include/not_windows.inc
--source include/not_embedded.inc --source include/not_embedded.inc
SET @start_global_value = @@global.thread_pool_stall_limit; SET @start_global_value = @@global.thread_pool_stall_limit;

View File

@ -3733,7 +3733,7 @@ static Sys_var_uint Sys_threadpool_stall_limit(
"If a worker thread is stalled, additional worker thread " "If a worker thread is stalled, additional worker thread "
"may be created to handle remaining clients.", "may be created to handle remaining clients.",
GLOBAL_VAR(threadpool_stall_limit), CMD_LINE(REQUIRED_ARG), 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), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
ON_UPDATE(fix_threadpool_stall_limit) ON_UPDATE(fix_threadpool_stall_limit)
); );

View File

@ -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_idle_timeout; /* Shutdown idle worker threads after this timeout */
extern uint threadpool_size; /* Number of parallel executing threads */ extern uint threadpool_size; /* Number of parallel executing threads */
extern uint threadpool_max_size; 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_max_threads; /* Maximum threads in pool */
extern uint threadpool_oversubscribe; /* Maximum active threads in group */ extern uint threadpool_oversubscribe; /* Maximum active threads in group */
extern uint threadpool_prio_kickup_timer; /* Time before low prio item gets prio boost */ 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 #define TP_MODE_GENERIC 1
#endif #endif
#define DEFAULT_THREADPOOL_STALL_LIMIT 500U
struct TP_connection; struct TP_connection;
extern void tp_callback(TP_connection *c); extern void tp_callback(TP_connection *c);

View File

@ -28,6 +28,7 @@
#include <time.h> #include <time.h>
#include <sql_plist.h> #include <sql_plist.h>
#include <threadpool.h> #include <threadpool.h>
#include <algorithm>
#ifdef HAVE_IOCP #ifdef HAVE_IOCP
#define OPTIONAL_IO_POLL_READ_PARAM this #define OPTIONAL_IO_POLL_READ_PARAM this
@ -865,23 +866,24 @@ end:
The actual values were not calculated using any scientific methods. The actual values were not calculated using any scientific methods.
They just look right, and behave well in practice. 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) static ulonglong microsecond_throttling_interval(thread_group_t *thread_group)
{ {
int count= thread_group->thread_count; int count= thread_group->thread_count;
if (count < 4) if (count < 1+ (int)threadpool_oversubscribe)
return 0; return 0;
if (count < 8) if (count < 8)
return 50*1000; return 50*1000*THROTTLING_FACTOR;
if(count < 16) if(count < 16)
return 100*1000; return 100*1000*THROTTLING_FACTOR;
return 200*1000; return 200*100*THROTTLING_FACTOR;
} }