Commit daeaa600 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

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.
parent 28fad39d
......@@ -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
......
......@@ -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'
......
# uint global
--source include/not_windows.inc
--source include/not_embedded.inc
SET @start_global_value = @@global.thread_pool_stall_limit;
......
......@@ -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)
);
......
......@@ -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);
......
......@@ -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 @@ static int create_worker(thread_group_t *thread_group, bool due_to_stall)
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;
}
......
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