summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/main/mysqld--help.result7
-rw-r--r--mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result28
-rw-r--r--sql/sys_vars.cc14
-rw-r--r--sql/threadpool.h2
-rw-r--r--sql/threadpool_common.cc2
-rw-r--r--sql/threadpool_generic.cc4
6 files changed, 55 insertions, 2 deletions
diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result
index 402d64445e6..3eccd39eac2 100644
--- a/mysql-test/main/mysqld--help.result
+++ b/mysql-test/main/mysqld--help.result
@@ -1320,6 +1320,11 @@ The following specify which files/extra groups are read (specified before remain
--thread-cache-size=#
How many threads we should keep in a cache for reuse.
These are freed after 5 minutes of idle time
+ --thread-pool-dedicated-listener
+ If set to 1,listener thread will not pick up queries
+ --thread-pool-exact-stats
+ If set to 1, provides better statistics in
+ information_schema threadpool tables
--thread-pool-idle-timeout=#
Timeout in seconds for an idle thread in the thread
pool.Worker thread will be shut down after timeout
@@ -1744,6 +1749,8 @@ tcp-keepalive-probes 0
tcp-keepalive-time 0
tcp-nodelay TRUE
thread-cache-size 151
+thread-pool-dedicated-listener FALSE
+thread-pool-exact-stats FALSE
thread-pool-idle-timeout 60
thread-pool-max-threads 65536
thread-pool-oversubscribe 3
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 aa75bb6e2f1..8d7bf6356aa 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
@@ -5346,6 +5346,34 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST one-thread-per-connection,no-threads,pool-of-threads
READ_ONLY YES
COMMAND_LINE_ARGUMENT REQUIRED
+VARIABLE_NAME THREAD_POOL_DEDICATED_LISTENER
+SESSION_VALUE NULL
+GLOBAL_VALUE OFF
+GLOBAL_VALUE_ORIGIN COMPILE-TIME
+DEFAULT_VALUE OFF
+VARIABLE_SCOPE GLOBAL
+VARIABLE_TYPE BOOLEAN
+VARIABLE_COMMENT If set to 1,listener thread will not pick up queries
+NUMERIC_MIN_VALUE NULL
+NUMERIC_MAX_VALUE NULL
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST OFF,ON
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT OPTIONAL
+VARIABLE_NAME THREAD_POOL_EXACT_STATS
+SESSION_VALUE NULL
+GLOBAL_VALUE OFF
+GLOBAL_VALUE_ORIGIN COMPILE-TIME
+DEFAULT_VALUE OFF
+VARIABLE_SCOPE GLOBAL
+VARIABLE_TYPE BOOLEAN
+VARIABLE_COMMENT If set to 1, provides better statistics in information_schema threadpool tables
+NUMERIC_MIN_VALUE NULL
+NUMERIC_MAX_VALUE NULL
+NUMERIC_BLOCK_SIZE NULL
+ENUM_VALUE_LIST OFF,ON
+READ_ONLY NO
+COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME THREAD_POOL_IDLE_TIMEOUT
SESSION_VALUE NULL
GLOBAL_VALUE 60
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 1160e936a2b..a42a870d68f 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -3753,6 +3753,20 @@ static Sys_var_uint Sys_threadpool_threadpool_prio_kickup_timer(
GLOBAL_VAR(threadpool_prio_kickup_timer), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(0, UINT_MAX), DEFAULT(1000), BLOCK_SIZE(1)
);
+
+static Sys_var_mybool Sys_threadpool_exact_stats(
+ "thread_pool_exact_stats",
+ "If set to 1, provides better statistics in information_schema threadpool tables",
+ GLOBAL_VAR(threadpool_exact_stats), CMD_LINE(OPT_ARG), DEFAULT(FALSE),
+ NO_MUTEX_GUARD, NOT_IN_BINLOG
+);
+
+static Sys_var_mybool Sys_threadpool_dedicated_listener(
+ "thread_pool_dedicated_listener",
+ "If set to 1,listener thread will not pick up queries",
+ GLOBAL_VAR(threadpool_dedicated_listener), CMD_LINE(OPT_ARG), DEFAULT(FALSE),
+ NO_MUTEX_GUARD, NOT_IN_BINLOG
+);
#endif /* HAVE_POOL_OF_THREADS */
/**
diff --git a/sql/threadpool.h b/sql/threadpool.h
index 7d2c34e0363..53ddc2d282d 100644
--- a/sql/threadpool.h
+++ b/sql/threadpool.h
@@ -28,6 +28,8 @@ extern uint threadpool_stall_limit; /* time interval in 10 ms units for stall c
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 */
+extern my_bool threadpool_exact_stats; /* Better queueing time stats for information_schema, at small performance cost */
+extern my_bool threadpool_dedicated_listener; /* Listener thread does not pick up work items. */
#ifdef _WIN32
extern uint threadpool_mode; /* Thread pool implementation , windows or generic */
#define TP_MODE_WINDOWS 0
diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc
index 0cbd076016d..13e3886fb97 100644
--- a/sql/threadpool_common.cc
+++ b/sql/threadpool_common.cc
@@ -36,6 +36,8 @@ uint threadpool_max_threads;
uint threadpool_oversubscribe;
uint threadpool_mode;
uint threadpool_prio_kickup_timer;
+my_bool threadpool_exact_stats;
+my_bool threadpool_dedicated_listener;
/* Stats */
TP_STATISTICS tp_stats;
diff --git a/sql/threadpool_generic.cc b/sql/threadpool_generic.cc
index 3cb7be26eb7..162dad2e866 100644
--- a/sql/threadpool_generic.cc
+++ b/sql/threadpool_generic.cc
@@ -744,7 +744,7 @@ static TP_connection_generic * listener(worker_thread_t *current_thread,
more workers.
*/
- bool listener_picks_event=is_queue_empty(thread_group);
+ bool listener_picks_event=is_queue_empty(thread_group) && !threadpool_dedicated_listener;
queue_put(thread_group, ev, cnt);
if (listener_picks_event)
{
@@ -1068,7 +1068,7 @@ static void queue_put(thread_group_t *thread_group, TP_connection_generic *conne
{
DBUG_ENTER("queue_put");
- connection->dequeue_time= pool_timer.current_microtime;
+ connection->enqueue_time= threadpool_exact_stats?microsecond_interval_timer():pool_timer.current_microtime;
thread_group->queues[connection->priority].push_back(connection);
if (thread_group->active_thread_count == 0)