mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Increase value of thread_cache_size to 32
Added 5 minute timeout before automaticlally removing threads from thread cache. This solves a problem with jemalloc, which is slow with a small thread cache and also makes thread_cache big enough that most users doesn't have to touch it
This commit is contained in:
@ -1068,7 +1068,8 @@ The following options may be given as the first argument:
|
||||
Decision to use in heuristic recover process. One of:
|
||||
COMMIT, ROLLBACK
|
||||
--thread-cache-size=#
|
||||
How many threads we should keep in a cache for reuse
|
||||
How many threads we should keep in a cache for reuse.
|
||||
These are freed after 5 minutes of idle time
|
||||
--thread-pool-idle-timeout=#
|
||||
Timeout in seconds for an idle thread in the thread
|
||||
pool.Worker thread will be shut down after timeout
|
||||
@ -1426,7 +1427,7 @@ table-cache 431
|
||||
table-definition-cache 400
|
||||
table-open-cache 431
|
||||
tc-heuristic-recover COMMIT
|
||||
thread-cache-size 0
|
||||
thread-cache-size 151
|
||||
thread-pool-idle-timeout 60
|
||||
thread-pool-max-threads 1000
|
||||
thread-pool-oversubscribe 3
|
||||
|
@ -1,24 +1,24 @@
|
||||
SET @start_global_value = @@global.thread_cache_size;
|
||||
SELECT @start_global_value;
|
||||
@start_global_value
|
||||
0
|
||||
256
|
||||
select @@global.thread_cache_size;
|
||||
@@global.thread_cache_size
|
||||
0
|
||||
256
|
||||
select @@session.thread_cache_size;
|
||||
ERROR HY000: Variable 'thread_cache_size' is a GLOBAL variable
|
||||
show global variables like 'thread_cache_size';
|
||||
Variable_name Value
|
||||
thread_cache_size 0
|
||||
thread_cache_size 256
|
||||
show session variables like 'thread_cache_size';
|
||||
Variable_name Value
|
||||
thread_cache_size 0
|
||||
thread_cache_size 256
|
||||
select * from information_schema.global_variables where variable_name='thread_cache_size';
|
||||
VARIABLE_NAME VARIABLE_VALUE
|
||||
THREAD_CACHE_SIZE 0
|
||||
THREAD_CACHE_SIZE 256
|
||||
select * from information_schema.session_variables where variable_name='thread_cache_size';
|
||||
VARIABLE_NAME VARIABLE_VALUE
|
||||
THREAD_CACHE_SIZE 0
|
||||
THREAD_CACHE_SIZE 256
|
||||
set global thread_cache_size=1;
|
||||
select @@global.thread_cache_size;
|
||||
@@global.thread_cache_size
|
||||
@ -51,4 +51,4 @@ select @@global.thread_cache_size;
|
||||
SET @@global.thread_cache_size = @start_global_value;
|
||||
SELECT @@global.thread_cache_size;
|
||||
@@global.thread_cache_size
|
||||
0
|
||||
256
|
||||
|
@ -0,0 +1 @@
|
||||
--max-connections=1024
|
@ -2995,6 +2995,7 @@ void unlink_thd(THD *thd)
|
||||
|
||||
static bool cache_thread()
|
||||
{
|
||||
struct timespec abstime;
|
||||
DBUG_ENTER("cache_thread");
|
||||
|
||||
mysql_mutex_lock(&LOCK_thread_cache);
|
||||
@ -3013,8 +3014,21 @@ static bool cache_thread()
|
||||
PSI_THREAD_CALL(delete_current_thread)();
|
||||
#endif
|
||||
|
||||
set_timespec(abstime, THREAD_CACHE_TIMEOUT);
|
||||
while (!abort_loop && ! wake_thread && ! kill_cached_threads)
|
||||
mysql_cond_wait(&COND_thread_cache, &LOCK_thread_cache);
|
||||
{
|
||||
int error= mysql_cond_timedwait(&COND_thread_cache, &LOCK_thread_cache,
|
||||
&abstime);
|
||||
if (error == ETIMEDOUT || error == ETIME)
|
||||
{
|
||||
/*
|
||||
If timeout, end thread.
|
||||
If a new thread is requested (wake_thread is set), we will handle
|
||||
the call, even if we got a timeout (as we are already awake and free)
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
cached_thread_count--;
|
||||
if (kill_cached_threads)
|
||||
mysql_cond_signal(&COND_flush_thread_cache);
|
||||
|
@ -235,6 +235,8 @@
|
||||
that does not respond to "initial server greeting" timely
|
||||
*/
|
||||
#define CONNECT_TIMEOUT 10
|
||||
/* Wait 5 minutes before removing thread from thread cache */
|
||||
#define THREAD_CACHE_TIMEOUT 5*60
|
||||
|
||||
/* The following can also be changed from the command line */
|
||||
#define DEFAULT_CONCURRENCY 10
|
||||
|
@ -3194,9 +3194,9 @@ static Sys_var_ulong Sys_table_cache_size(
|
||||
|
||||
static Sys_var_ulong Sys_thread_cache_size(
|
||||
"thread_cache_size",
|
||||
"How many threads we should keep in a cache for reuse",
|
||||
"How many threads we should keep in a cache for reuse. These are freed after 5 minutes of idle time",
|
||||
GLOBAL_VAR(thread_cache_size), CMD_LINE(REQUIRED_ARG),
|
||||
VALID_RANGE(0, 16384), DEFAULT(0), BLOCK_SIZE(1));
|
||||
VALID_RANGE(0, 16384), DEFAULT(256), BLOCK_SIZE(1));
|
||||
|
||||
#ifdef HAVE_POOL_OF_THREADS
|
||||
static bool fix_tp_max_threads(sys_var *, THD *, enum_var_type)
|
||||
|
Reference in New Issue
Block a user