Merge lp:~akopytov/percona-server/tp-high-prio-mode-5.6 into lp:percona-server/5.6

Proposed by Alexey Kopytov
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 514
Proposed branch: lp:~akopytov/percona-server/tp-high-prio-mode-5.6
Merge into: lp:percona-server/5.6
Prerequisite: lp:~akopytov/percona-server/tp-low-prio-queue-throttling-5.6
Diff against target: 201 lines (+116/-4)
6 files modified
Percona-Server/mysql-test/suite/sys_vars/r/thread_pool_high_prio_mode_basic.result (+34/-0)
Percona-Server/mysql-test/suite/sys_vars/t/thread_pool_high_prio_mode_basic.test (+35/-0)
Percona-Server/sql/sql_class.h (+2/-1)
Percona-Server/sql/sys_vars.cc (+15/-0)
Percona-Server/sql/threadpool.h (+9/-0)
Percona-Server/sql/threadpool_unix.cc (+21/-3)
To merge this branch: bzr merge lp:~akopytov/percona-server/tp-high-prio-mode-5.6
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
George Ormond Lorch III (community) g2 Approve
Review via email: mp+198748@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
George Ormond Lorch III (gl-az) :
review: Approve (g2)
Revision history for this message
Alexey Kopytov (akopytov) wrote :

Same comments as in the 5.5 MP.

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/thread_pool_high_prio_mode_basic.result'
--- Percona-Server/mysql-test/suite/sys_vars/r/thread_pool_high_prio_mode_basic.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/r/thread_pool_high_prio_mode_basic.result 2013-12-12 13:56:46 +0000
@@ -0,0 +1,34 @@
1SET @start_global_value = @@GLOBAL.thread_pool_high_prio_mode;
2SET @@GLOBAL.thread_pool_high_prio_mode=DEFAULT;
3SELECT @@GLOBAL.thread_pool_high_prio_mode;
4@@GLOBAL.thread_pool_high_prio_mode
5transactions
6SET @@SESSION.thread_pool_high_prio_mode=DEFAULT;
7SELECT @@SESSION.thread_pool_high_prio_mode;
8@@SESSION.thread_pool_high_prio_mode
9transactions
10SHOW GLOBAL VARIABLES LIKE 'thread_pool_high_prio_mode';
11Variable_name Value
12thread_pool_high_prio_mode transactions
13SHOW SESSION VARIABLES LIKE 'thread_pool_high_prio_mode';
14Variable_name Value
15thread_pool_high_prio_mode transactions
16SET @@thread_pool_high_prio_mode='transactions';
17SELECT @@thread_pool_high_prio_mode;
18@@thread_pool_high_prio_mode
19transactions
20SET @@thread_pool_high_prio_mode='statements';
21SELECT @@thread_pool_high_prio_mode;
22@@thread_pool_high_prio_mode
23statements
24SET @@thread_pool_high_prio_mode='none';
25SELECT @@thread_pool_high_prio_mode;
26@@thread_pool_high_prio_mode
27none
28SET @@thread_pool_high_prio_mode='foo';
29ERROR 42000: Variable 'thread_pool_high_prio_mode' can't be set to the value of 'foo'
30SET @@thread_pool_high_prio_mode=1.1;
31ERROR 42000: Incorrect argument type to variable 'thread_pool_high_prio_mode'
32SET @@thread_pool_high_prio_mode=1e1;
33ERROR 42000: Incorrect argument type to variable 'thread_pool_high_prio_mode'
34SET @@GLOBAL.thread_pool_high_prio_mode = @start_global_value;
035
=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/thread_pool_high_prio_mode_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/thread_pool_high_prio_mode_basic.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/thread_pool_high_prio_mode_basic.test 2013-12-12 13:56:46 +0000
@@ -0,0 +1,35 @@
1--source include/not_windows.inc
2--source include/not_embedded.inc
3
4SET @start_global_value = @@GLOBAL.thread_pool_high_prio_mode;
5
6# Test the default value
7SET @@GLOBAL.thread_pool_high_prio_mode=DEFAULT;
8SELECT @@GLOBAL.thread_pool_high_prio_mode;
9
10# Test that the session value is accepted
11SET @@SESSION.thread_pool_high_prio_mode=DEFAULT;
12SELECT @@SESSION.thread_pool_high_prio_mode;
13
14SHOW GLOBAL VARIABLES LIKE 'thread_pool_high_prio_mode';
15SHOW SESSION VARIABLES LIKE 'thread_pool_high_prio_mode';
16
17SET @@thread_pool_high_prio_mode='transactions';
18SELECT @@thread_pool_high_prio_mode;
19
20SET @@thread_pool_high_prio_mode='statements';
21SELECT @@thread_pool_high_prio_mode;
22
23SET @@thread_pool_high_prio_mode='none';
24SELECT @@thread_pool_high_prio_mode;
25
26--error ER_WRONG_VALUE_FOR_VAR
27SET @@thread_pool_high_prio_mode='foo';
28
29--error ER_WRONG_TYPE_FOR_VAR
30SET @@thread_pool_high_prio_mode=1.1;
31
32--error ER_WRONG_TYPE_FOR_VAR
33SET @@thread_pool_high_prio_mode=1e1;
34
35SET @@GLOBAL.thread_pool_high_prio_mode = @start_global_value;
036
=== modified file 'Percona-Server/sql/sql_class.h'
--- Percona-Server/sql/sql_class.h 2013-12-02 12:25:50 +0000
+++ Percona-Server/sql/sql_class.h 2013-12-12 13:56:46 +0000
@@ -610,7 +610,8 @@
610610
611 my_bool expand_fast_index_creation;611 my_bool expand_fast_index_creation;
612612
613 uint threadpool_high_prio_tickets;613 uint threadpool_high_prio_tickets;
614 ulong thread_pool_high_prio_mode;
614} SV;615} SV;
615616
616617
617618
=== modified file 'Percona-Server/sql/sys_vars.cc'
--- Percona-Server/sql/sys_vars.cc 2013-12-02 12:25:50 +0000
+++ Percona-Server/sql/sys_vars.cc 2013-12-12 13:56:46 +0000
@@ -3152,6 +3152,21 @@
3152 SESSION_VAR(threadpool_high_prio_tickets), CMD_LINE(REQUIRED_ARG),3152 SESSION_VAR(threadpool_high_prio_tickets), CMD_LINE(REQUIRED_ARG),
3153 VALID_RANGE(0, UINT_MAX), DEFAULT(UINT_MAX), BLOCK_SIZE(1)3153 VALID_RANGE(0, UINT_MAX), DEFAULT(UINT_MAX), BLOCK_SIZE(1)
3154);3154);
3155
3156static Sys_var_enum Sys_threadpool_high_prio_mode(
3157 "thread_pool_high_prio_mode",
3158 "High priority queue mode: one of 'transactions', 'statements' or 'none'. "
3159 "In the 'transactions' mode the thread pool uses both high- and low-priority "
3160 "queues depending on whether an event is generated by an already started "
3161 "transaction and whether it has any high priority tickets (see "
3162 "thread_pool_high_prio_tickets). In the 'statements' mode all events (i.e. "
3163 "individual statements) always go to the high priority queue, regardless of "
3164 "the current transaction state and high priority tickets. "
3165 "'none' is the opposite of 'statements', i.e. disables the high priority queue "
3166 "completely.",
3167 SESSION_VAR(thread_pool_high_prio_mode), CMD_LINE(REQUIRED_ARG),
3168 thread_pool_high_prio_mode_names, DEFAULT(TP_HIGH_PRIO_MODE_TRANSACTIONS));
3169
3155#endif /* !WIN32 */3170#endif /* !WIN32 */
3156static Sys_var_uint Sys_threadpool_max_threads(3171static Sys_var_uint Sys_threadpool_max_threads(
3157 "thread_pool_max_threads",3172 "thread_pool_max_threads",
31583173
=== modified file 'Percona-Server/sql/threadpool.h'
--- Percona-Server/sql/threadpool.h 2013-12-02 12:17:20 +0000
+++ Percona-Server/sql/threadpool.h 2013-12-12 13:56:46 +0000
@@ -15,6 +15,12 @@
1515
16#define MAX_THREAD_GROUPS 12816#define MAX_THREAD_GROUPS 128
1717
18enum tp_high_prio_mode_t {
19 TP_HIGH_PRIO_MODE_TRANSACTIONS,
20 TP_HIGH_PRIO_MODE_STATEMENTS,
21 TP_HIGH_PRIO_MODE_NONE
22};
23
18/* Threadpool parameters */24/* Threadpool parameters */
19extern uint threadpool_min_threads; /* Minimum threads in pool */25extern uint threadpool_min_threads; /* Minimum threads in pool */
20extern uint threadpool_idle_timeout; /* Shutdown idle worker threads after this timeout */26extern uint threadpool_idle_timeout; /* Shutdown idle worker threads after this timeout */
@@ -23,6 +29,9 @@
23extern uint threadpool_max_threads; /* Maximum threads in pool */29extern uint threadpool_max_threads; /* Maximum threads in pool */
24extern uint threadpool_oversubscribe; /* Maximum active threads in group */30extern uint threadpool_oversubscribe; /* Maximum active threads in group */
2531
32/* Possible values for thread_pool_high_prio_mode */
33extern const char *thread_pool_high_prio_mode_names[];
34
26/* Common thread pool routines, suitable for different implementations */35/* Common thread pool routines, suitable for different implementations */
27extern void threadpool_remove_connection(THD *thd);36extern void threadpool_remove_connection(THD *thd);
28extern int threadpool_process_request(THD *thd);37extern int threadpool_process_request(THD *thd);
2938
=== modified file 'Percona-Server/sql/threadpool_unix.cc'
--- Percona-Server/sql/threadpool_unix.cc 2013-12-12 13:56:46 +0000
+++ Percona-Server/sql/threadpool_unix.cc 2013-12-12 13:56:46 +0000
@@ -48,6 +48,10 @@
48for stall detection to kick in */48for stall detection to kick in */
49#define THREADPOOL_CREATE_THREADS_ON_WAIT49#define THREADPOOL_CREATE_THREADS_ON_WAIT
5050
51/* Possible values for thread_pool_high_prio_mode */
52const char *thread_pool_high_prio_mode_names[]= {"transactions", "statements",
53 "none", NullS};
54
51/** Indicates that threadpool was initialized*/55/** Indicates that threadpool was initialized*/
52static bool threadpool_started= false; 56static bool threadpool_started= false;
5357
@@ -428,6 +432,21 @@
428 > 1 + (int) threadpool_oversubscribe);432 > 1 + (int) threadpool_oversubscribe);
429}433}
430434
435/*
436 Checks if a given connection is eligible to enter the high priority queue
437 based on its current thread_pool_high_prio_mode value, available high
438 priority tickets and transactional state.
439*/
440
441inline bool connection_is_high_prio(connection_t *c)
442{
443 const ulong mode= c->thd->variables.thread_pool_high_prio_mode;
444
445 return (mode == TP_HIGH_PRIO_MODE_STATEMENTS) ||
446 (mode == TP_HIGH_PRIO_MODE_TRANSACTIONS &&
447 c->tickets > 0 && thd_is_transaction_active(c->thd));
448}
449
431} // namespace450} // namespace
432451
433/* Dequeue element from a workqueue */452/* Dequeue element from a workqueue */
@@ -761,7 +780,7 @@
761 for(int i=(listener_picks_event)?1:0; i < cnt ; i++)780 for(int i=(listener_picks_event)?1:0; i < cnt ; i++)
762 {781 {
763 connection_t *c= (connection_t *)native_event_get_userdata(&ev[i]);782 connection_t *c= (connection_t *)native_event_get_userdata(&ev[i]);
764 if (c->tickets > 0 && thd_is_transaction_active(c->thd))783 if (connection_is_high_prio(c))
765 {784 {
766 c->tickets--;785 c->tickets--;
767 thread_group->high_prio_queue.push_back(c);786 thread_group->high_prio_queue.push_back(c);
@@ -1153,8 +1172,7 @@
1153 must either have a high priority ticket, or there must be not too many1172 must either have a high priority ticket, or there must be not too many
1154 busy threads (as if it was coming from a low priority queue).1173 busy threads (as if it was coming from a low priority queue).
1155 */1174 */
1156 if (connection->tickets > 0 &&1175 if (connection_is_high_prio(connection))
1157 thd_is_transaction_active(connection->thd))
1158 connection->tickets--;1176 connection->tickets--;
1159 else if (too_many_busy_threads(thread_group))1177 else if (too_many_busy_threads(thread_group))
1160 {1178 {

Subscribers

People subscribed via source and target branches