Merge lp:~laurynas-biveinis/percona-server/xtradb-thread-nice into lp:percona-server/5.6

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Sergei Glushchenko
Approved revision: no longer in the source branch.
Merged at revision: 451
Proposed branch: lp:~laurynas-biveinis/percona-server/xtradb-thread-nice
Merge into: lp:percona-server/5.6
Diff against target: 972 lines (+664/-22)
20 files modified
Percona-Server/mysql-test/include/linux.inc (+5/-0)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_cleaner_basic.result (+30/-0)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_io_basic.result (+30/-0)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_master_basic.result (+30/-0)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_purge_basic.result (+30/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_cleaner_basic.test (+1/-5)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_io_basic.test (+1/-5)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_master_basic.test (+1/-5)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_purge_basic.test (+1/-5)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_cleaner_basic.test (+42/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_io_basic.test (+43/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_master_basic.test (+43/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_purge_basic.test (+43/-0)
Percona-Server/storage/innobase/buf/buf0flu.cc (+4/-0)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+197/-1)
Percona-Server/storage/innobase/include/os0thread.h (+35/-0)
Percona-Server/storage/innobase/include/srv0srv.h (+26/-0)
Percona-Server/storage/innobase/os/os0thread.cc (+52/-0)
Percona-Server/storage/innobase/srv/srv0srv.cc (+39/-0)
Percona-Server/storage/innobase/srv/srv0start.cc (+11/-1)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/xtradb-thread-nice
Reviewer Review Type Date Requested Status
Sergei Glushchenko (community) g2 Approve
Vadim Tkachenko Pending
Review via email: mp+189018@code.launchpad.net

This proposal supersedes a proposal from 2013-10-02.

Description of the change

2nd MP:

    Changes from the 1st MP:
    - created mysql-test/include/linux.inc, used from the test files
      added by current and previous MPs.
    - Made srv_sched_priority_* variables unconditionally declared.

http://jenkins.percona.com/job/percona-server-5.6-param/339/

1st MP:

Implement relative thread scheduling priorities for XtraDB
(https://blueprints.launchpad.net/percona-server/+spec/xtradb-thread-nice).

Add new command line option innodb_sched_priority_cleaner=0..39,
corresponding to Linux nice values of -20..19. Add other options
innodb_sched_priority_purge, innodb_sched_priority_io,
innodb_sched_priority_master, hidden under UNIV_PERF_DEBUG.

On setting the new values, silently do nothing if a corresponding
thread or threads are not running. If they are running, attempt to
set the thread nice priority for the specified thread type and return
a warning with an actual priority if the attempt failed.

As Linux setpriority() accepts as system-specific pid_t thread id,
define a new type os_tid_t. Implement new functions
os_thread_get_tid() and os_thread_set_priority() that use it.

Introduce a new macro SRV_MAX_N_PURGE_THREADS for the maximum allowed
number of purge threads.

Add new sys_vars test for these variables.

http://jenkins.percona.com/job/percona-server-5.6-param/334/

To post a comment you must log in.
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote : Posted in a previous version of this proposal

LGTM from logical point of view.

review: Approve
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote : Posted in a previous version of this proposal

Hi Laurynas,

I noted a lot of OS checks in tests, would be nice to have file have_linux.inc and use it. Also "Linux" (double quotes) is not compatible with MySQL ansi mode, not sure if it is important. Introduction of have_linux will probably not save a lot of code lines, but will save a bit of time for those who need to implement that check in future. One can easily find have_linux.inc and use it instead of digging the actual way how check OS.

Otherwise looks good.

review: Needs Fixing (g2)
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote : Posted in a previous version of this proposal

There are also lines in test cases which are commented out.
diff lines 165-168,177,178,217-220,229,230,269-272,281,282,321-324,333,334

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote : Posted in a previous version of this proposal

srv_sched_priority_cleaner in srv0srv.h but is UNIV_LINUX only, but it used in buf0flu.cc (buf_flush_page_cleaner_thread) without UNIV_LINUX. Likewise other srv_sched_priority_* variables.

Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Sergei -

> There are also lines in test cases which are commented out.
> diff lines 165-168,177,178,217-220,229,230,269-272,281,282,321-324,333,334

Diff line 164 explained this: these are the valid values for the variable, but the test would not necessarily succeed as it needs ulimit setup. Thus leave them in the test to show the legal values, but do not attempt to execute them.

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Approve.

review: Approve (g2)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'Percona-Server/mysql-test/include/linux.inc'
--- Percona-Server/mysql-test/include/linux.inc 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/include/linux.inc 2013-10-03 09:38:30 +0000
@@ -0,0 +1,5 @@
1if (`select convert(@@version_compile_os using latin1) LIKE 'Linux' = 0`)
2{
3 skip Need Linux;
4}
5
06
=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_cleaner_basic.result'
--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_cleaner_basic.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_cleaner_basic.result 2013-10-03 09:38:30 +0000
@@ -0,0 +1,30 @@
1SET @start_value = @@GLOBAL.innodb_sched_priority_cleaner;
2SELECT @@GLOBAL.innodb_sched_priority_cleaner;
3@@GLOBAL.innodb_sched_priority_cleaner
420
5SELECT @@SESSION.innodb_sched_priority_cleaner;
6ERROR HY000: Variable 'innodb_sched_priority_cleaner' is a GLOBAL variable
7SET GLOBAL innodb_sched_priority_cleaner=20;
8SELECT @@GLOBAL.innodb_sched_priority_cleaner;
9@@GLOBAL.innodb_sched_priority_cleaner
1020
11SET GLOBAL innodb_sched_priority_cleaner=25;
12SELECT @@GLOBAL.innodb_sched_priority_cleaner;
13@@GLOBAL.innodb_sched_priority_cleaner
1425
15SET GLOBAL innodb_sched_priority_cleaner=39;
16SELECT @@GLOBAL.innodb_sched_priority_cleaner;
17@@GLOBAL.innodb_sched_priority_cleaner
1839
19SET GLOBAL innodb_sched_priority_cleaner=41;
20Warnings:
21Warning 1292 Truncated incorrect innodb_sched_priority_cleaner value: '41'
22SELECT @@GLOBAL.innodb_sched_priority_cleaner;
23@@GLOBAL.innodb_sched_priority_cleaner
2439
25SET GLOBAL innodb_sched_priority_cleaner=1.1;
26ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_cleaner'
27SET GLOBAL innodb_sched_priority_cleaner=1e1;
28ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_cleaner'
29SET GLOBAL innodb_sched_priority_cleaner='foo';
30ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_cleaner'
031
=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_io_basic.result'
--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_io_basic.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_io_basic.result 2013-10-03 09:38:30 +0000
@@ -0,0 +1,30 @@
1SET @start_value = @@GLOBAL.innodb_sched_priority_io;
2SELECT @@GLOBAL.innodb_sched_priority_io;
3@@GLOBAL.innodb_sched_priority_io
420
5SELECT @@SESSION.innodb_sched_priority_io;
6ERROR HY000: Variable 'innodb_sched_priority_io' is a GLOBAL variable
7SET GLOBAL innodb_sched_priority_io=20;
8SELECT @@GLOBAL.innodb_sched_priority_io;
9@@GLOBAL.innodb_sched_priority_io
1020
11SET GLOBAL innodb_sched_priority_io=25;
12SELECT @@GLOBAL.innodb_sched_priority_io;
13@@GLOBAL.innodb_sched_priority_io
1425
15SET GLOBAL innodb_sched_priority_io=39;
16SELECT @@GLOBAL.innodb_sched_priority_io;
17@@GLOBAL.innodb_sched_priority_io
1839
19SET GLOBAL innodb_sched_priority_io=41;
20Warnings:
21Warning 1292 Truncated incorrect innodb_sched_priority_io value: '41'
22SELECT @@GLOBAL.innodb_sched_priority_io;
23@@GLOBAL.innodb_sched_priority_io
2439
25SET GLOBAL innodb_sched_priority_io=1.1;
26ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_io'
27SET GLOBAL innodb_sched_priority_io=1e1;
28ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_io'
29SET GLOBAL innodb_sched_priority_io='foo';
30ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_io'
031
=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_master_basic.result'
--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_master_basic.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_master_basic.result 2013-10-03 09:38:30 +0000
@@ -0,0 +1,30 @@
1SET @start_value = @@GLOBAL.innodb_sched_priority_master;
2SELECT @@GLOBAL.innodb_sched_priority_master;
3@@GLOBAL.innodb_sched_priority_master
420
5SELECT @@SESSION.innodb_sched_priority_master;
6ERROR HY000: Variable 'innodb_sched_priority_master' is a GLOBAL variable
7SET GLOBAL innodb_sched_priority_master=20;
8SELECT @@GLOBAL.innodb_sched_priority_master;
9@@GLOBAL.innodb_sched_priority_master
1020
11SET GLOBAL innodb_sched_priority_master=25;
12SELECT @@GLOBAL.innodb_sched_priority_master;
13@@GLOBAL.innodb_sched_priority_master
1425
15SET GLOBAL innodb_sched_priority_master=39;
16SELECT @@GLOBAL.innodb_sched_priority_master;
17@@GLOBAL.innodb_sched_priority_master
1839
19SET GLOBAL innodb_sched_priority_master=41;
20Warnings:
21Warning 1292 Truncated incorrect innodb_sched_priority_master value: '41'
22SELECT @@GLOBAL.innodb_sched_priority_master;
23@@GLOBAL.innodb_sched_priority_master
2439
25SET GLOBAL innodb_sched_priority_master=1.1;
26ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_master'
27SET GLOBAL innodb_sched_priority_master=1e1;
28ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_master'
29SET GLOBAL innodb_sched_priority_master='foo';
30ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_master'
031
=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_purge_basic.result'
--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_purge_basic.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_sched_priority_purge_basic.result 2013-10-03 09:38:30 +0000
@@ -0,0 +1,30 @@
1SET @start_value = @@GLOBAL.innodb_sched_priority_purge;
2SELECT @@GLOBAL.innodb_sched_priority_purge;
3@@GLOBAL.innodb_sched_priority_purge
420
5SELECT @@SESSION.innodb_sched_priority_purge;
6ERROR HY000: Variable 'innodb_sched_priority_purge' is a GLOBAL variable
7SET GLOBAL innodb_sched_priority_purge=20;
8SELECT @@GLOBAL.innodb_sched_priority_purge;
9@@GLOBAL.innodb_sched_priority_purge
1020
11SET GLOBAL innodb_sched_priority_purge=25;
12SELECT @@GLOBAL.innodb_sched_priority_purge;
13@@GLOBAL.innodb_sched_priority_purge
1425
15SET GLOBAL innodb_sched_priority_purge=39;
16SELECT @@GLOBAL.innodb_sched_priority_purge;
17@@GLOBAL.innodb_sched_priority_purge
1839
19SET GLOBAL innodb_sched_priority_purge=41;
20Warnings:
21Warning 1292 Truncated incorrect innodb_sched_priority_purge value: '41'
22SELECT @@GLOBAL.innodb_sched_priority_purge;
23@@GLOBAL.innodb_sched_priority_purge
2439
25SET GLOBAL innodb_sched_priority_purge=1.1;
26ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_purge'
27SET GLOBAL innodb_sched_priority_purge=1e1;
28ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_purge'
29SET GLOBAL innodb_sched_priority_purge='foo';
30ERROR 42000: Incorrect argument type to variable 'innodb_sched_priority_purge'
031
=== modified file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_cleaner_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_cleaner_basic.test 2013-09-23 12:31:09 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_cleaner_basic.test 2013-10-03 09:38:30 +0000
@@ -1,10 +1,6 @@
1--source include/have_debug.inc1--source include/have_debug.inc
2--source include/have_innodb.inc2--source include/have_innodb.inc
33--source include/linux.inc
4if (`SELECT @@version_compile_os LIKE "Linux" = 0`)
5{
6 skip Needs Linux;
7}
84
9# A dynamic, global variable5# A dynamic, global variable
106
117
=== modified file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_io_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_io_basic.test 2013-09-23 12:31:09 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_io_basic.test 2013-10-03 09:38:30 +0000
@@ -1,10 +1,6 @@
1--source include/have_debug.inc1--source include/have_debug.inc
2--source include/have_innodb.inc2--source include/have_innodb.inc
33--source include/linux.inc
4if (`SELECT @@version_compile_os LIKE "Linux" = 0`)
5{
6 skip Needs Linux;
7}
84
9# A dynamic, global variable5# A dynamic, global variable
106
117
=== modified file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_master_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_master_basic.test 2013-09-23 12:31:09 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_master_basic.test 2013-10-03 09:38:30 +0000
@@ -1,10 +1,6 @@
1--source include/have_debug.inc1--source include/have_debug.inc
2--source include/have_innodb.inc2--source include/have_innodb.inc
33--source include/linux.inc
4if (`SELECT @@version_compile_os LIKE "Linux" = 0`)
5{
6 skip Needs Linux;
7}
84
9# A dynamic, global variable5# A dynamic, global variable
106
117
=== modified file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_purge_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_purge_basic.test 2013-09-23 12:31:09 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_priority_purge_basic.test 2013-10-03 09:38:30 +0000
@@ -1,10 +1,6 @@
1--source include/have_debug.inc1--source include/have_debug.inc
2--source include/have_innodb.inc2--source include/have_innodb.inc
33--source include/linux.inc
4if (`SELECT @@version_compile_os LIKE "Linux" = 0`)
5{
6 skip Needs Linux;
7}
84
9# A dynamic, global variable5# A dynamic, global variable
106
117
=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_cleaner_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_cleaner_basic.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_cleaner_basic.test 2013-10-03 09:38:30 +0000
@@ -0,0 +1,42 @@
1--source include/have_innodb.inc
2--source include/linux.inc
3
4# A dynamic, global variable
5
6SET @start_value = @@GLOBAL.innodb_sched_priority_cleaner;
7
8# Default value
9SELECT @@GLOBAL.innodb_sched_priority_cleaner;
10
11# Global only
12--error ER_INCORRECT_GLOBAL_LOCAL_VAR
13SELECT @@SESSION.innodb_sched_priority_cleaner;
14
15# Correct values
16# The high priority values may need permissions, thus do not test them
17# SET GLOBAL innodb_sched_priority_cleaner=0;
18# SELECT @@GLOBAL.innodb_sched_priority_cleaner;
19#SET GLOBAL innodb_sched_priority_cleaner=15;
20# SELECT @@GLOBAL.innodb_sched_priority_cleaner;
21SET GLOBAL innodb_sched_priority_cleaner=20;
22SELECT @@GLOBAL.innodb_sched_priority_cleaner;
23SET GLOBAL innodb_sched_priority_cleaner=25;
24SELECT @@GLOBAL.innodb_sched_priority_cleaner;
25SET GLOBAL innodb_sched_priority_cleaner=39;
26SELECT @@GLOBAL.innodb_sched_priority_cleaner;
27
28# Incorrect values
29#SET GLOBAL innodb_sched_priority_cleaner=-1;
30#SELECT @@GLOBAL.innodb_sched_priority_cleaner;
31SET GLOBAL innodb_sched_priority_cleaner=41;
32SELECT @@GLOBAL.innodb_sched_priority_cleaner;
33--error ER_WRONG_TYPE_FOR_VAR
34SET GLOBAL innodb_sched_priority_cleaner=1.1;
35--error ER_WRONG_TYPE_FOR_VAR
36SET GLOBAL innodb_sched_priority_cleaner=1e1;
37--error ER_WRONG_TYPE_FOR_VAR
38SET GLOBAL innodb_sched_priority_cleaner='foo';
39
40# If we are lacking permissions, then we cannot restore the startup value
41# at the end.
42--source include/restart_mysqld.inc
043
=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_io_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_io_basic.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_io_basic.test 2013-10-03 09:38:30 +0000
@@ -0,0 +1,43 @@
1--source include/have_debug.inc
2--source include/have_innodb.inc
3--source include/linux.inc
4
5# A dynamic, global variable
6
7SET @start_value = @@GLOBAL.innodb_sched_priority_io;
8
9# Default value
10SELECT @@GLOBAL.innodb_sched_priority_io;
11
12# Global only
13--error ER_INCORRECT_GLOBAL_LOCAL_VAR
14SELECT @@SESSION.innodb_sched_priority_io;
15
16# Correct values
17# The high priority values may need permissions, thus do not test them
18# SET GLOBAL innodb_sched_priority_io=0;
19# SELECT @@GLOBAL.innodb_sched_priority_io;
20#SET GLOBAL innodb_sched_priority_io=15;
21# SELECT @@GLOBAL.innodb_sched_priority_io;
22SET GLOBAL innodb_sched_priority_io=20;
23SELECT @@GLOBAL.innodb_sched_priority_io;
24SET GLOBAL innodb_sched_priority_io=25;
25SELECT @@GLOBAL.innodb_sched_priority_io;
26SET GLOBAL innodb_sched_priority_io=39;
27SELECT @@GLOBAL.innodb_sched_priority_io;
28
29# Incorrect values
30#SET GLOBAL innodb_sched_priority_io=-1;
31#SELECT @@GLOBAL.innodb_sched_priority_io;
32SET GLOBAL innodb_sched_priority_io=41;
33SELECT @@GLOBAL.innodb_sched_priority_io;
34--error ER_WRONG_TYPE_FOR_VAR
35SET GLOBAL innodb_sched_priority_io=1.1;
36--error ER_WRONG_TYPE_FOR_VAR
37SET GLOBAL innodb_sched_priority_io=1e1;
38--error ER_WRONG_TYPE_FOR_VAR
39SET GLOBAL innodb_sched_priority_io='foo';
40
41# If we are lacking permissions, then we cannot restore the startup value
42# at the end.
43--source include/restart_mysqld.inc
044
=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_master_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_master_basic.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_master_basic.test 2013-10-03 09:38:30 +0000
@@ -0,0 +1,43 @@
1--source include/have_debug.inc
2--source include/have_innodb.inc
3--source include/linux.inc
4
5# A dynamic, global variable
6
7SET @start_value = @@GLOBAL.innodb_sched_priority_master;
8
9# Default value
10SELECT @@GLOBAL.innodb_sched_priority_master;
11
12# Global only
13--error ER_INCORRECT_GLOBAL_LOCAL_VAR
14SELECT @@SESSION.innodb_sched_priority_master;
15
16# Correct values
17# The high priority values may need permissions, thus do not test them
18# SET GLOBAL innodb_sched_priority_master=0;
19# SELECT @@GLOBAL.innodb_sched_priority_master;
20#SET GLOBAL innodb_sched_priority_master=15;
21# SELECT @@GLOBAL.innodb_sched_priority_master;
22SET GLOBAL innodb_sched_priority_master=20;
23SELECT @@GLOBAL.innodb_sched_priority_master;
24SET GLOBAL innodb_sched_priority_master=25;
25SELECT @@GLOBAL.innodb_sched_priority_master;
26SET GLOBAL innodb_sched_priority_master=39;
27SELECT @@GLOBAL.innodb_sched_priority_master;
28
29# Incorrect values
30#SET GLOBAL innodb_sched_priority_master=-1;
31#SELECT @@GLOBAL.innodb_sched_priority_master;
32SET GLOBAL innodb_sched_priority_master=41;
33SELECT @@GLOBAL.innodb_sched_priority_master;
34--error ER_WRONG_TYPE_FOR_VAR
35SET GLOBAL innodb_sched_priority_master=1.1;
36--error ER_WRONG_TYPE_FOR_VAR
37SET GLOBAL innodb_sched_priority_master=1e1;
38--error ER_WRONG_TYPE_FOR_VAR
39SET GLOBAL innodb_sched_priority_master='foo';
40
41# If we are lacking permissions, then we cannot restore the startup value
42# at the end.
43--source include/restart_mysqld.inc
044
=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_purge_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_purge_basic.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_sched_priority_purge_basic.test 2013-10-03 09:38:30 +0000
@@ -0,0 +1,43 @@
1--source include/have_debug.inc
2--source include/have_innodb.inc
3--source include/linux.inc
4
5# A dynamic, global variable
6
7SET @start_value = @@GLOBAL.innodb_sched_priority_purge;
8
9# Default value
10SELECT @@GLOBAL.innodb_sched_priority_purge;
11
12# Global only
13--error ER_INCORRECT_GLOBAL_LOCAL_VAR
14SELECT @@SESSION.innodb_sched_priority_purge;
15
16# Correct values
17# The high priority values may need permissions, thus do not test them
18# SET GLOBAL innodb_sched_priority_purge=0;
19# SELECT @@GLOBAL.innodb_sched_priority_purge;
20#SET GLOBAL innodb_sched_priority_purge=15;
21# SELECT @@GLOBAL.innodb_sched_priority_purge;
22SET GLOBAL innodb_sched_priority_purge=20;
23SELECT @@GLOBAL.innodb_sched_priority_purge;
24SET GLOBAL innodb_sched_priority_purge=25;
25SELECT @@GLOBAL.innodb_sched_priority_purge;
26SET GLOBAL innodb_sched_priority_purge=39;
27SELECT @@GLOBAL.innodb_sched_priority_purge;
28
29# Incorrect values
30#SET GLOBAL innodb_sched_priority_purge=-1;
31#SELECT @@GLOBAL.innodb_sched_priority_purge;
32SET GLOBAL innodb_sched_priority_purge=41;
33SELECT @@GLOBAL.innodb_sched_priority_purge;
34--error ER_WRONG_TYPE_FOR_VAR
35SET GLOBAL innodb_sched_priority_purge=1.1;
36--error ER_WRONG_TYPE_FOR_VAR
37SET GLOBAL innodb_sched_priority_purge=1e1;
38--error ER_WRONG_TYPE_FOR_VAR
39SET GLOBAL innodb_sched_priority_purge='foo';
40
41# If we are lacking permissions, then we cannot restore the startup value
42# at the end.
43--source include/restart_mysqld.inc
044
=== modified file 'Percona-Server/storage/innobase/buf/buf0flu.cc'
--- Percona-Server/storage/innobase/buf/buf0flu.cc 2013-10-03 05:38:15 +0000
+++ Percona-Server/storage/innobase/buf/buf0flu.cc 2013-10-03 09:38:30 +0000
@@ -2633,6 +2633,10 @@
2633 pfs_register_thread(buf_page_cleaner_thread_key);2633 pfs_register_thread(buf_page_cleaner_thread_key);
2634#endif /* UNIV_PFS_THREAD */2634#endif /* UNIV_PFS_THREAD */
26352635
2636 srv_cleaner_tid = os_thread_get_tid();
2637
2638 os_thread_set_priority(srv_cleaner_tid, srv_sched_priority_cleaner);
2639
2636#ifdef UNIV_DEBUG_THREAD_CREATION2640#ifdef UNIV_DEBUG_THREAD_CREATION
2637 fprintf(stderr, "InnoDB: page_cleaner thread running, id %lu\n",2641 fprintf(stderr, "InnoDB: page_cleaner thread running, id %lu\n",
2638 os_thread_pf(os_thread_get_curr_id()));2642 os_thread_pf(os_thread_get_curr_id()));
26392643
=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-09-30 12:13:10 +0000
+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2013-10-03 09:38:30 +0000
@@ -15714,6 +15714,172 @@
15714 }15714 }
15715}15715}
1571615716
15717#ifdef UNIV_LINUX
15718
15719/****************************************************************//**
15720Update the innodb_sched_priority_cleaner variable and set the thread
15721priority accordingly. */
15722static
15723void
15724innodb_sched_priority_cleaner_update(
15725/*=================================*/
15726 THD* thd, /*!< in: thread handle */
15727 struct st_mysql_sys_var* var, /*!< in: pointer to
15728 system variable */
15729 void* var_ptr,/*!< out: where the
15730 formal string goes */
15731 const void* save) /*!< in: immediate result
15732 from check function */
15733{
15734 ulint priority = *static_cast<const ulint *>(save);
15735 ulint actual_priority;
15736
15737 if (srv_read_only_mode) {
15738
15739 return;
15740 }
15741
15742 ut_ad(buf_page_cleaner_is_active);
15743 actual_priority = os_thread_set_priority(srv_cleaner_tid, priority);
15744 if (UNIV_UNLIKELY(actual_priority != priority)) {
15745
15746 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
15747 ER_WRONG_ARGUMENTS,
15748 "Failed to set the page cleaner thread "
15749 "priority to %lu, "
15750 "the current priority is %lu", priority,
15751 actual_priority);
15752 } else {
15753
15754 srv_sched_priority_cleaner = priority;
15755 }
15756}
15757
15758#if defined(UNIV_DEBUG) || (UNIV_PERF_DEBUG)
15759
15760/****************************************************************//**
15761Update the innodb_sched_priority_purge variable and set the thread
15762priorities accordingly. */
15763static
15764void
15765innodb_sched_priority_purge_update(
15766/*===============================*/
15767 THD* thd, /*!< in: thread handle */
15768 struct st_mysql_sys_var* var, /*!< in: pointer to
15769 system variable */
15770 void* var_ptr,/*!< out: where the
15771 formal string goes */
15772 const void* save) /*!< in: immediate result
15773 from check function */
15774{
15775 ulint priority = *static_cast<const ulint *>(save);
15776
15777 if (srv_read_only_mode) {
15778 return;
15779 }
15780
15781 ut_ad(purge_sys->state == PURGE_STATE_RUN);
15782 for (ulint i = 0; i < srv_n_purge_threads; i++) {
15783
15784 ulint actual_priority
15785 = os_thread_set_priority(srv_purge_tids[i], priority);
15786 if (UNIV_UNLIKELY(actual_priority != priority)) {
15787
15788 push_warning_printf(thd,
15789 Sql_condition::WARN_LEVEL_WARN,
15790 ER_WRONG_ARGUMENTS,
15791 "Failed to set the purge "
15792 "thread priority to %lu, the "
15793 "current priority is %lu, "
15794 "aborting priority update",
15795 priority, actual_priority);
15796 return;
15797 }
15798 }
15799
15800 srv_sched_priority_purge = priority;
15801}
15802
15803/****************************************************************//**
15804Update the innodb_sched_priority_io variable and set the thread
15805priorities accordingly. */
15806static
15807void
15808innodb_sched_priority_io_update(
15809/*============================*/
15810 THD* thd, /*!< in: thread handle */
15811 struct st_mysql_sys_var* var, /*!< in: pointer to
15812 system variable */
15813 void* var_ptr,/*!< out: where the
15814 formal string goes */
15815 const void* save) /*!< in: immediate result
15816 from check function */
15817{
15818 ulint priority = *static_cast<const ulint *>(save);
15819
15820 for (ulint i = 0; i < srv_n_file_io_threads; i++) {
15821
15822 ulint actual_priority = os_thread_set_priority(srv_io_tids[i],
15823 priority);
15824
15825 if (UNIV_UNLIKELY(actual_priority != priority)) {
15826
15827 push_warning_printf(thd,
15828 Sql_condition::WARN_LEVEL_WARN,
15829 ER_WRONG_ARGUMENTS,
15830 "Failed to set the I/O "
15831 "thread priority to %lu, the "
15832 "current priority is %lu, "
15833 "aborting priority update",
15834 priority, actual_priority);
15835 return;
15836 }
15837 }
15838
15839 srv_sched_priority_io = priority;
15840}
15841
15842/****************************************************************//**
15843Update the innodb_sched_priority_master variable and set the thread
15844priorities accordingly. */
15845static
15846void
15847innodb_sched_priority_master_update(
15848/*================================*/
15849 THD* thd, /*!< in: thread handle */
15850 struct st_mysql_sys_var* var, /*!< in: pointer to
15851 system variable */
15852 void* var_ptr,/*!< out: where the
15853 formal string goes */
15854 const void* save) /*!< in: immediate result
15855 from check function */
15856{
15857 ulint priority = *static_cast<const lint *>(save);
15858 ulint actual_priority;
15859
15860 if (srv_read_only_mode) {
15861 return;
15862 }
15863
15864 actual_priority = os_thread_set_priority(srv_master_tid, priority);
15865 if (UNIV_UNLIKELY(actual_priority != priority)) {
15866
15867 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
15868 ER_WRONG_ARGUMENTS,
15869 "Failed to set the master thread "
15870 "priority to %lu, "
15871 "the current priority is %lu", priority,
15872 actual_priority);
15873 } else {
15874
15875 srv_sched_priority_master = priority;
15876 }
15877}
15878
15879#endif /* defined(UNIV_DEBUG) || (UNIV_PERF_DEBUG) */
15880
15881#endif /* UNIV_LINUX */
15882
15717/****************************************************************//**15883/****************************************************************//**
15718Callback function for accessing the InnoDB variables from MySQL:15884Callback function for accessing the InnoDB variables from MySQL:
15719SHOW VARIABLES. */15885SHOW VARIABLES. */
@@ -16266,7 +16432,7 @@
16266 NULL, NULL,16432 NULL, NULL,
16267 1, /* Default setting */16433 1, /* Default setting */
16268 1, /* Minimum value */16434 1, /* Minimum value */
16269 32, 0); /* Maximum value */16435 SRV_MAX_N_PURGE_THREADS, 0); /* Maximum value */
1627016436
16271static MYSQL_SYSVAR_ULONG(sync_array_size, srv_sync_array_size,16437static MYSQL_SYSVAR_ULONG(sync_array_size, srv_sync_array_size,
16272 PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,16438 PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
@@ -16539,6 +16705,15 @@
16539 "established by the buffer pool memory region. Disabled by default.",16705 "established by the buffer pool memory region. Disabled by default.",
16540 NULL, NULL, FALSE);16706 NULL, NULL, FALSE);
1654116707
16708#ifdef UNIV_LINUX
16709
16710static MYSQL_SYSVAR_ULONG(sched_priority_cleaner, srv_sched_priority_cleaner,
16711 PLUGIN_VAR_RQCMDARG,
16712 "Nice value for the cleaner thread scheduling",
16713 NULL, innodb_sched_priority_cleaner_update, 20, 0, 39, 0);
16714
16715#endif /* UNIV_LINUX */
16716
16542#if defined UNIV_DEBUG || defined UNIV_PERF_DEBUG16717#if defined UNIV_DEBUG || defined UNIV_PERF_DEBUG
16543static MYSQL_SYSVAR_ULONG(page_hash_locks, srv_n_page_hash_locks,16718static MYSQL_SYSVAR_ULONG(page_hash_locks, srv_n_page_hash_locks,
16544 PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,16719 PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
@@ -16552,6 +16727,21 @@
1655216727
16553#ifdef UNIV_LINUX16728#ifdef UNIV_LINUX
1655416729
16730static MYSQL_SYSVAR_ULONG(sched_priority_purge, srv_sched_priority_purge,
16731 PLUGIN_VAR_RQCMDARG,
16732 "Nice value for the purge thread scheduling",
16733 NULL, innodb_sched_priority_purge_update, 20, 0, 39, 0);
16734
16735static MYSQL_SYSVAR_ULONG(sched_priority_io, srv_sched_priority_io,
16736 PLUGIN_VAR_RQCMDARG,
16737 "Nice value for the I/O handler thread scheduling",
16738 NULL, innodb_sched_priority_io_update, 20, 0, 39, 0);
16739
16740static MYSQL_SYSVAR_ULONG(sched_priority_master, srv_sched_priority_master,
16741 PLUGIN_VAR_RQCMDARG,
16742 "Nice value for the master thread scheduling",
16743 NULL, innodb_sched_priority_master_update, 20, 0, 39, 0);
16744
16555static MYSQL_SYSVAR_BOOL(priority_purge, srv_purge_thread_priority,16745static MYSQL_SYSVAR_BOOL(priority_purge, srv_purge_thread_priority,
16556 PLUGIN_VAR_OPCMDARG,16746 PLUGIN_VAR_OPCMDARG,
16557 "Make purge coordinator and worker threads acquire shared resources with "16747 "Make purge coordinator and worker threads acquire shared resources with "
@@ -17268,10 +17458,16 @@
17268 MYSQL_SYSVAR(log_checkpoint_now),17458 MYSQL_SYSVAR(log_checkpoint_now),
17269 MYSQL_SYSVAR(track_redo_log_now),17459 MYSQL_SYSVAR(track_redo_log_now),
17270#endif /* UNIV_DEBUG */17460#endif /* UNIV_DEBUG */
17461#ifdef UNIV_LINUX
17462 MYSQL_SYSVAR(sched_priority_cleaner),
17463#endif
17271#if defined UNIV_DEBUG || defined UNIV_PERF_DEBUG17464#if defined UNIV_DEBUG || defined UNIV_PERF_DEBUG
17272 MYSQL_SYSVAR(page_hash_locks),17465 MYSQL_SYSVAR(page_hash_locks),
17273 MYSQL_SYSVAR(doublewrite_batch_size),17466 MYSQL_SYSVAR(doublewrite_batch_size),
17274#ifdef UNIV_LINUX17467#ifdef UNIV_LINUX
17468 MYSQL_SYSVAR(sched_priority_purge),
17469 MYSQL_SYSVAR(sched_priority_io),
17470 MYSQL_SYSVAR(sched_priority_master),
17275 MYSQL_SYSVAR(priority_purge),17471 MYSQL_SYSVAR(priority_purge),
17276 MYSQL_SYSVAR(priority_io),17472 MYSQL_SYSVAR(priority_io),
17277 MYSQL_SYSVAR(priority_cleaner),17473 MYSQL_SYSVAR(priority_cleaner),
1727817474
=== modified file 'Percona-Server/storage/innobase/include/os0thread.h'
--- Percona-Server/storage/innobase/include/os0thread.h 2013-06-10 20:44:22 +0000
+++ Percona-Server/storage/innobase/include/os0thread.h 2013-10-03 09:38:30 +0000
@@ -29,6 +29,10 @@
2929
30#include "univ.i"30#include "univ.i"
3131
32#ifdef UNIV_LINUX
33#include <sys/types.h>
34#endif
35
32/* Maximum number of threads which can be created in the program;36/* Maximum number of threads which can be created in the program;
33this is also the size of the wait slot array for MySQL threads which37this is also the size of the wait slot array for MySQL threads which
34can wait inside InnoDB */38can wait inside InnoDB */
@@ -45,6 +49,7 @@
45typedef void* os_thread_t;49typedef void* os_thread_t;
46typedef DWORD os_thread_id_t; /*!< In Windows the thread id50typedef DWORD os_thread_id_t; /*!< In Windows the thread id
47 is an unsigned long int */51 is an unsigned long int */
52typedef os_thread_id_t os_tid_t;
48extern "C" {53extern "C" {
49typedef LPTHREAD_START_ROUTINE os_thread_func_t;54typedef LPTHREAD_START_ROUTINE os_thread_func_t;
50}55}
@@ -65,6 +70,15 @@
65typedef os_thread_t os_thread_id_t; /*!< In Unix we use the thread70typedef os_thread_t os_thread_id_t; /*!< In Unix we use the thread
66 handle itself as the id of71 handle itself as the id of
67 the thread */72 the thread */
73#ifdef UNIV_LINUX
74typedef pid_t os_tid_t; /*!< An alias for pid_t on
75 Linux, where setpriority()
76 accepts thread id of this type
77 and not pthread_t */
78#else
79typedef os_thread_id_t os_tid_t;
80#endif
81
68extern "C" { typedef void* (*os_thread_func_t)(void*); }82extern "C" { typedef void* (*os_thread_func_t)(void*); }
6983
70/** Macro for specifying a POSIX thread start function. */84/** Macro for specifying a POSIX thread start function. */
@@ -134,6 +148,15 @@
134os_thread_get_curr_id(void);148os_thread_get_curr_id(void);
135/*========================*/149/*========================*/
136/*****************************************************************//**150/*****************************************************************//**
151Returns the system-specific thread identifier of current thread. On Linux,
152returns tid. On other systems currently returns os_thread_get_curr_id().
153
154@return current thread identifier */
155UNIV_INTERN
156os_tid_t
157os_thread_get_tid(void);
158/*=====================*/
159/*****************************************************************//**
137Advises the os to give up remainder of the thread's time slice. */160Advises the os to give up remainder of the thread's time slice. */
138UNIV_INTERN161UNIV_INTERN
139void162void
@@ -146,6 +169,18 @@
146os_thread_sleep(169os_thread_sleep(
147/*============*/170/*============*/
148 ulint tm); /*!< in: time in microseconds */171 ulint tm); /*!< in: time in microseconds */
172/*****************************************************************//**
173Set relative scheduling priority for a given thread on Linux. Currently a
174no-op on other systems.
175
176@return An actual thread priority after the update */
177UNIV_INTERN
178ulint
179os_thread_set_priority(
180/*===================*/
181 os_tid_t thread_id, /*!< in: thread id */
182 ulint relative_priority); /*!< in: system-specific
183 priority value */
149184
150#ifndef UNIV_NONINL185#ifndef UNIV_NONINL
151#include "os0thread.ic"186#include "os0thread.ic"
152187
=== modified file 'Percona-Server/storage/innobase/include/srv0srv.h'
--- Percona-Server/storage/innobase/include/srv0srv.h 2013-09-30 12:13:10 +0000
+++ Percona-Server/storage/innobase/include/srv0srv.h 2013-10-03 09:38:30 +0000
@@ -503,11 +503,37 @@
503503
504#define SRV_MAX_N_IO_THREADS 130504#define SRV_MAX_N_IO_THREADS 130
505505
506#define SRV_MAX_N_PURGE_THREADS 32
507
506/* Array of English strings describing the current state of an508/* Array of English strings describing the current state of an
507i/o handler thread */509i/o handler thread */
508extern const char* srv_io_thread_op_info[];510extern const char* srv_io_thread_op_info[];
509extern const char* srv_io_thread_function[];511extern const char* srv_io_thread_function[];
510512
513/* The tid of the cleaner thread */
514extern os_tid_t srv_cleaner_tid;
515
516/* The tids of the purge threads */
517extern os_tid_t srv_purge_tids[];
518
519/* The tids of the I/O threads */
520extern os_tid_t srv_io_tids[];
521
522/* The tid of the master thread */
523extern os_tid_t srv_master_tid;
524
525/* The relative scheduling priority of the cleaner thread */
526extern ulint srv_sched_priority_cleaner;
527
528/* The relative scheduling priority of the purge threads */
529extern ulint srv_sched_priority_purge;
530
531/* The relative scheduling priority of the I/O threads */
532extern ulint srv_sched_priority_io;
533
534/* The relative scheduling priority of the master thread */
535extern ulint srv_sched_priority_master;
536
511/* The relative priority of the purge coordinator and worker threads. */537/* The relative priority of the purge coordinator and worker threads. */
512extern my_bool srv_purge_thread_priority;538extern my_bool srv_purge_thread_priority;
513539
514540
=== modified file 'Percona-Server/storage/innobase/os/os0thread.cc'
--- Percona-Server/storage/innobase/os/os0thread.cc 2013-06-10 20:44:22 +0000
+++ Percona-Server/storage/innobase/os/os0thread.cc 2013-10-03 09:38:30 +0000
@@ -30,6 +30,12 @@
3030
31#ifdef __WIN__31#ifdef __WIN__
32#include <windows.h>32#include <windows.h>
33#elif UNIV_LINUX
34#include <sys/time.h>
35#include <sys/resource.h>
36#include <unistd.h>
37#include <sys/syscall.h>
38#include <sys/types.h>
33#endif39#endif
3440
35#ifndef UNIV_HOTBACKUP41#ifndef UNIV_HOTBACKUP
@@ -98,6 +104,24 @@
98#endif104#endif
99}105}
100106
107/*****************************************************************//**
108Returns the system-specific thread identifier of current thread. On Linux,
109returns tid. On other systems currently returns os_thread_get_curr_id().
110
111@return current thread identifier */
112UNIV_INTERN
113os_tid_t
114os_thread_get_tid(void)
115/*===================*/
116{
117#ifdef UNIV_LINUX
118 return((os_tid_t)syscall(SYS_gettid));
119#else
120 return(os_thread_get_curr_id());
121#endif
122}
123
124
101/****************************************************************//**125/****************************************************************//**
102Creates a new thread of execution. The execution starts from126Creates a new thread of execution. The execution starts from
103the function given. The start function takes a void* parameter127the function given. The start function takes a void* parameter
@@ -255,3 +279,31 @@
255 select(0, NULL, NULL, NULL, &t);279 select(0, NULL, NULL, NULL, &t);
256#endif280#endif
257}281}
282
283/*****************************************************************//**
284Set relative scheduling priority for a given thread on Linux. Currently a
285no-op on other systems.
286
287@return An actual thread priority after the update */
288UNIV_INTERN
289ulint
290os_thread_set_priority(
291/*===================*/
292 os_tid_t thread_id, /*!< in: thread id */
293 ulint relative_priority) /*!< in: system-specific
294 priority value */
295{
296#ifdef UNIV_LINUX
297 lint thread_nice = relative_priority - 20;
298 if (setpriority(PRIO_PROCESS, thread_id, thread_nice) == -1) {
299 ib_logf(IB_LOG_LEVEL_WARN,
300 "Setting thread %lu nice to %ld failed, "
301 "current nice %d, errno %d",
302 os_thread_pf(thread_id), thread_nice,
303 getpriority(PRIO_PROCESS, thread_id), errno);
304 }
305 return(getpriority(PRIO_PROCESS, thread_id) + 20);
306#else
307 return(relative_priority);
308#endif
309}
258310
=== modified file 'Percona-Server/storage/innobase/srv/srv0srv.cc'
--- Percona-Server/storage/innobase/srv/srv0srv.cc 2013-09-30 12:13:10 +0000
+++ Percona-Server/storage/innobase/srv/srv0srv.cc 2013-10-03 09:38:30 +0000
@@ -344,6 +344,30 @@
344/* Number of iterations over which adaptive flushing is averaged. */344/* Number of iterations over which adaptive flushing is averaged. */
345UNIV_INTERN ulong srv_flushing_avg_loops = 30;345UNIV_INTERN ulong srv_flushing_avg_loops = 30;
346346
347/* The tid of the cleaner thread */
348UNIV_INTERN os_tid_t srv_cleaner_tid;
349
350/* The tids of the purge threads */
351UNIV_INTERN os_tid_t srv_purge_tids[SRV_MAX_N_PURGE_THREADS];
352
353/* The tids of the I/O threads */
354UNIV_INTERN os_tid_t srv_io_tids[SRV_MAX_N_IO_THREADS];
355
356/* The tid of the master thread */
357UNIV_INTERN os_tid_t srv_master_tid;
358
359/* The relative scheduling priority of the cleaner thread */
360UNIV_INTERN ulint srv_sched_priority_cleaner = 20;
361
362/* The relative scheduling priority of the purge threads */
363UNIV_INTERN ulint srv_sched_priority_purge = 20;
364
365/* The relative scheduling priority of the I/O threads */
366UNIV_INTERN ulint srv_sched_priority_io = 20;
367
368/* The relative scheduling priority of the master thread */
369UNIV_INTERN ulint srv_sched_priority_master = 20;
370
347/* The relative priority of the current thread. If 0, low priority; if 1, high371/* The relative priority of the current thread. If 0, low priority; if 1, high
348priority. */372priority. */
349UNIV_INTERN UNIV_THREAD_LOCAL ulint srv_current_thread_priority = 0;373UNIV_INTERN UNIV_THREAD_LOCAL ulint srv_current_thread_priority = 0;
@@ -2877,6 +2901,10 @@
28772901
2878 ut_ad(!srv_read_only_mode);2902 ut_ad(!srv_read_only_mode);
28792903
2904 srv_master_tid = os_thread_get_tid();
2905
2906 os_thread_set_priority(srv_master_tid, srv_sched_priority_master);
2907
2880#ifdef UNIV_DEBUG_THREAD_CREATION2908#ifdef UNIV_DEBUG_THREAD_CREATION
2881 fprintf(stderr, "Master thread starts, id %lu\n",2909 fprintf(stderr, "Master thread starts, id %lu\n",
2882 os_thread_pf(os_thread_get_curr_id()));2910 os_thread_pf(os_thread_get_curr_id()));
@@ -3006,6 +3034,8 @@
3006 return(thr != NULL);3034 return(thr != NULL);
3007}3035}
30083036
3037static ulint purge_tid_i = 0;
3038
3009/*********************************************************************//**3039/*********************************************************************//**
3010Worker thread that reads tasks from the work queue and executes them.3040Worker thread that reads tasks from the work queue and executes them.
3011@return a dummy parameter */3041@return a dummy parameter */
@@ -3017,10 +3047,16 @@
3017 required by os_thread_create */3047 required by os_thread_create */
3018{3048{
3019 srv_slot_t* slot;3049 srv_slot_t* slot;
3050 ulint tid_i = os_atomic_increment_ulint(&purge_tid_i, 1);
30203051
3052 ut_ad(tid_i < srv_n_purge_threads);
3021 ut_ad(!srv_read_only_mode);3053 ut_ad(!srv_read_only_mode);
3022 ut_a(srv_force_recovery < SRV_FORCE_NO_BACKGROUND);3054 ut_a(srv_force_recovery < SRV_FORCE_NO_BACKGROUND);
30233055
3056 srv_purge_tids[tid_i] = os_thread_get_tid();
3057 os_thread_set_priority(srv_purge_tids[tid_i],
3058 srv_sched_priority_purge);
3059
3024#ifdef UNIV_DEBUG_THREAD_CREATION3060#ifdef UNIV_DEBUG_THREAD_CREATION
3025 ut_print_timestamp(stderr);3061 ut_print_timestamp(stderr);
3026 fprintf(stderr, " InnoDB: worker thread starting, id %lu\n",3062 fprintf(stderr, " InnoDB: worker thread starting, id %lu\n",
@@ -3286,6 +3322,9 @@
3286 ut_a(trx_purge_state() == PURGE_STATE_INIT);3322 ut_a(trx_purge_state() == PURGE_STATE_INIT);
3287 ut_a(srv_force_recovery < SRV_FORCE_NO_BACKGROUND);3323 ut_a(srv_force_recovery < SRV_FORCE_NO_BACKGROUND);
32883324
3325 srv_purge_tids[0] = os_thread_get_tid();
3326 os_thread_set_priority(srv_purge_tids[0], srv_sched_priority_purge);
3327
3289 rw_lock_x_lock(&purge_sys->latch);3328 rw_lock_x_lock(&purge_sys->latch);
32903329
3291 purge_sys->running = true;3330 purge_sys->running = true;
32923331
=== modified file 'Percona-Server/storage/innobase/srv/srv0start.cc'
--- Percona-Server/storage/innobase/srv/srv0start.cc 2013-09-27 14:09:03 +0000
+++ Percona-Server/storage/innobase/srv/srv0start.cc 2013-10-03 09:38:30 +0000
@@ -127,7 +127,8 @@
127/** io_handler_thread parameters for thread identification */127/** io_handler_thread parameters for thread identification */
128static ulint n[SRV_MAX_N_IO_THREADS + 6];128static ulint n[SRV_MAX_N_IO_THREADS + 6];
129/** io_handler_thread identifiers, 32 is the maximum number of purge threads */129/** io_handler_thread identifiers, 32 is the maximum number of purge threads */
130static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6 + 32];130static os_thread_id_t thread_ids[SRV_MAX_N_IO_THREADS + 6
131 + SRV_MAX_N_PURGE_THREADS];
131132
132/** We use this mutex to test the return value of pthread_mutex_trylock133/** We use this mutex to test the return value of pthread_mutex_trylock
133 on successful locking. HP-UX does NOT return 0, though Linux et al do. */134 on successful locking. HP-UX does NOT return 0, though Linux et al do. */
@@ -452,6 +453,9 @@
452}453}
453454
454#ifndef UNIV_HOTBACKUP455#ifndef UNIV_HOTBACKUP
456
457static ulint io_tid_i = 0;
458
455/********************************************************************//**459/********************************************************************//**
456I/o-handler thread function.460I/o-handler thread function.
457@return OS_THREAD_DUMMY_RETURN */461@return OS_THREAD_DUMMY_RETURN */
@@ -463,9 +467,15 @@
463 the aio array */467 the aio array */
464{468{
465 ulint segment;469 ulint segment;
470 ulint tid_i = os_atomic_increment_ulint(&io_tid_i, 1) - 1;
471
472 ut_ad(tid_i < srv_n_file_io_threads);
466473
467 segment = *((ulint*) arg);474 segment = *((ulint*) arg);
468475
476 srv_io_tids[tid_i] = os_thread_get_tid();
477 os_thread_set_priority(srv_io_tids[tid_i], srv_sched_priority_io);
478
469#ifdef UNIV_DEBUG_THREAD_CREATION479#ifdef UNIV_DEBUG_THREAD_CREATION
470 fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,480 fprintf(stderr, "Io handler thread %lu starts, id %lu\n", segment,
471 os_thread_pf(os_thread_get_curr_id()));481 os_thread_pf(os_thread_get_curr_id()));

Subscribers

People subscribed via source and target branches