102.1.1
by kinoyasu
add header and rule, as the first step of the reordering patch for separate release |
1 |
# name : innodb_thread_concurrency_timer_based.patch |
2 |
# introduced : 11 or before |
|
3 |
# maintainer : Yasufumi |
|
4 |
# |
|
5 |
#!!! notice !!! |
|
6 |
# Any small change to this file in the main branch |
|
7 |
# should be done or reviewed by the maintainer! |
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
8 |
diff -ruN a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
|
9 |
--- a/storage/innodb_plugin/handler/ha_innodb.cc 2010-04-29 16:43:16.000000000 +0900
|
|
10 |
+++ b/storage/innodb_plugin/handler/ha_innodb.cc 2010-04-29 16:43:53.000000000 +0900
|
|
9
by kinoyasu
port for 5.1.47-1.0.8 |
11 |
@@ -151,6 +151,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
12 |
static ulong innobase_read_io_threads; |
13 |
static ulong innobase_write_io_threads; |
|
14 |
||
15 |
+static my_bool innobase_thread_concurrency_timer_based;
|
|
16 |
static long long innobase_buffer_pool_size, innobase_log_file_size; |
|
17 |
||
18 |
/** Percentage of the buffer pool to reserve for 'old' blocks. |
|
208
by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
19 |
@@ -2341,6 +2342,9 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
20 |
srv_n_log_files = (ulint) innobase_log_files_in_group; |
21 |
srv_log_file_size = (ulint) innobase_log_file_size; |
|
22 |
||
23 |
+ srv_thread_concurrency_timer_based =
|
|
24 |
+ (ibool) innobase_thread_concurrency_timer_based;
|
|
25 |
+
|
|
26 |
#ifdef UNIV_LOG_ARCHIVE |
|
27 |
srv_log_archive_on = (ulint) innobase_log_archive; |
|
28 |
#endif /* UNIV_LOG_ARCHIVE */ |
|
208
by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
29 |
@@ -11216,6 +11220,12 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
30 |
"Maximum delay between polling for a spin lock (6 by default)", |
31 |
NULL, NULL, 6L, 0L, ~0L, 0); |
|
32 |
||
33 |
+static MYSQL_SYSVAR_BOOL(thread_concurrency_timer_based,
|
|
34 |
+ innobase_thread_concurrency_timer_based,
|
|
35 |
+ PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
|
|
36 |
+ "Use InnoDB timer based concurrency throttling. ",
|
|
37 |
+ NULL, NULL, FALSE);
|
|
38 |
+
|
|
39 |
static MYSQL_SYSVAR_ULONG(thread_concurrency, srv_thread_concurrency, |
|
40 |
PLUGIN_VAR_RQCMDARG, |
|
41 |
"Helps in performance tuning in heavily concurrent environments. Sets the maximum number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.", |
|
208
by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
42 |
@@ -11432,6 +11442,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
43 |
MYSQL_SYSVAR(spin_wait_delay), |
44 |
MYSQL_SYSVAR(table_locks), |
|
45 |
MYSQL_SYSVAR(thread_concurrency), |
|
46 |
+ MYSQL_SYSVAR(thread_concurrency_timer_based),
|
|
47 |
MYSQL_SYSVAR(thread_sleep_delay), |
|
48 |
MYSQL_SYSVAR(autoinc_lock_mode), |
|
49 |
MYSQL_SYSVAR(show_verbose_locks), |
|
50 |
diff -ruN a/storage/innodb_plugin/handler/innodb_patch_info.h b/storage/innodb_plugin/handler/innodb_patch_info.h
|
|
51 |
--- a/storage/innodb_plugin/handler/innodb_patch_info.h 2010-04-29 16:43:16.000000000 +0900
|
|
52 |
+++ b/storage/innodb_plugin/handler/innodb_patch_info.h 2010-04-29 16:43:53.000000000 +0900
|
|
53 |
@@ -31,5 +31,6 @@
|
|
54 |
{"innodb_expand_undo_slots","expandable maximum number of undo slots","from 1024 (default) to about 4000","http://www.percona.com/docs/wiki/percona-xtradb"}, |
|
55 |
{"innodb_extra_rseg","allow to create extra rollback segments","When create new db, the new parameter allows to create more rollback segments","http://www.percona.com/docs/wiki/percona-xtradb"}, |
|
56 |
{"innodb_overwrite_relay_log_info","overwrite relay-log.info when slave recovery","Building as plugin, it is not used.","http://www.percona.com/docs/wiki/percona-xtradb:innodb_overwrite_relay_log_info"}, |
|
57 |
+{"innodb_thread_concurrency_timer_based","use InnoDB timer based concurrency throttling (backport from MySQL 5.4.0)","",""},
|
|
58 |
{NULL, NULL, NULL, NULL} |
|
59 |
}; |
|
60 |
diff -ruN a/storage/innodb_plugin/include/srv0srv.h b/storage/innodb_plugin/include/srv0srv.h
|
|
61 |
--- a/storage/innodb_plugin/include/srv0srv.h 2010-04-29 16:39:34.000000000 +0900
|
|
62 |
+++ b/storage/innodb_plugin/include/srv0srv.h 2010-04-29 16:43:53.000000000 +0900
|
|
63 |
@@ -147,6 +147,8 @@
|
|
64 |
extern ulint srv_mem_pool_size; |
|
65 |
extern ulint srv_lock_table_size; |
|
66 |
||
67 |
+extern ibool srv_thread_concurrency_timer_based;
|
|
68 |
+
|
|
69 |
extern ulint srv_n_file_io_threads; |
|
70 |
extern ulong srv_read_ahead_threshold; |
|
71 |
extern ulint srv_n_read_io_threads; |
|
72 |
diff -ruN a/storage/innodb_plugin/srv/srv0srv.c b/storage/innodb_plugin/srv/srv0srv.c
|
|
73 |
--- a/storage/innodb_plugin/srv/srv0srv.c 2010-04-29 16:39:34.000000000 +0900
|
|
74 |
+++ b/storage/innodb_plugin/srv/srv0srv.c 2010-04-29 16:43:53.000000000 +0900
|
|
208
by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
75 |
@@ -318,6 +318,7 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
76 |
computer. Bigger computers need bigger values. Value 0 will disable the |
77 |
concurrency check. */ |
|
78 |
||
79 |
+UNIV_INTERN ibool srv_thread_concurrency_timer_based = FALSE;
|
|
80 |
UNIV_INTERN ulong srv_thread_concurrency = 0; |
|
81 |
||
82 |
/* this mutex protects srv_conc data structures */ |
|
208
by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
83 |
@@ -1069,6 +1070,75 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
84 |
/*********************************************************************//** |
85 |
Puts an OS thread to wait if there are too many concurrent threads |
|
86 |
(>= srv_thread_concurrency) inside InnoDB. The threads wait in a FIFO queue. */ |
|
87 |
+
|
|
88 |
+#ifdef HAVE_ATOMIC_BUILTINS
|
|
89 |
+static void
|
|
90 |
+enter_innodb_with_tickets(trx_t* trx)
|
|
91 |
+{
|
|
92 |
+ trx->declared_to_be_inside_innodb = TRUE;
|
|
93 |
+ trx->n_tickets_to_enter_innodb = SRV_FREE_TICKETS_TO_ENTER;
|
|
94 |
+ return;
|
|
95 |
+}
|
|
96 |
+
|
|
97 |
+static void
|
|
98 |
+srv_conc_enter_innodb_timer_based(trx_t* trx)
|
|
99 |
+{
|
|
100 |
+ lint conc_n_threads;
|
|
101 |
+ ibool has_yielded = FALSE;
|
|
102 |
+ ulint has_slept = 0;
|
|
103 |
+
|
|
104 |
+ if (trx->declared_to_be_inside_innodb) {
|
|
105 |
+ ut_print_timestamp(stderr);
|
|
106 |
+ fputs(
|
|
107 |
+" InnoDB: Error: trying to declare trx to enter InnoDB, but\n"
|
|
108 |
+"InnoDB: it already is declared.\n", stderr);
|
|
109 |
+ trx_print(stderr, trx, 0);
|
|
110 |
+ putc('\n', stderr);
|
|
111 |
+ }
|
|
112 |
+retry:
|
|
113 |
+ if (srv_conc_n_threads < (lint) srv_thread_concurrency) {
|
|
114 |
+ conc_n_threads = os_atomic_increment_lint(&srv_conc_n_threads, 1);
|
|
115 |
+ if (conc_n_threads <= (lint) srv_thread_concurrency) {
|
|
116 |
+ enter_innodb_with_tickets(trx);
|
|
117 |
+ return;
|
|
118 |
+ }
|
|
119 |
+ os_atomic_increment_lint(&srv_conc_n_threads, -1);
|
|
120 |
+ }
|
|
121 |
+ if (!has_yielded)
|
|
122 |
+ {
|
|
123 |
+ has_yielded = TRUE;
|
|
124 |
+ os_thread_yield();
|
|
125 |
+ goto retry;
|
|
126 |
+ }
|
|
127 |
+ if (trx->has_search_latch
|
|
128 |
+ || NULL != UT_LIST_GET_FIRST(trx->trx_locks)) {
|
|
129 |
+
|
|
130 |
+ conc_n_threads = os_atomic_increment_lint(&srv_conc_n_threads, 1);
|
|
131 |
+ enter_innodb_with_tickets(trx);
|
|
132 |
+ return;
|
|
133 |
+ }
|
|
134 |
+ if (has_slept < 2)
|
|
135 |
+ {
|
|
136 |
+ trx->op_info = "sleeping before entering InnoDB";
|
|
137 |
+ os_thread_sleep(10000);
|
|
138 |
+ trx->op_info = "";
|
|
139 |
+ has_slept++;
|
|
140 |
+ }
|
|
141 |
+ conc_n_threads = os_atomic_increment_lint(&srv_conc_n_threads, 1);
|
|
142 |
+ enter_innodb_with_tickets(trx);
|
|
143 |
+ return;
|
|
144 |
+}
|
|
145 |
+
|
|
146 |
+static void
|
|
147 |
+srv_conc_exit_innodb_timer_based(trx_t* trx)
|
|
148 |
+{
|
|
149 |
+ os_atomic_increment_lint(&srv_conc_n_threads, -1);
|
|
150 |
+ trx->declared_to_be_inside_innodb = FALSE;
|
|
151 |
+ trx->n_tickets_to_enter_innodb = 0;
|
|
152 |
+ return;
|
|
153 |
+}
|
|
154 |
+#endif
|
|
155 |
+
|
|
156 |
UNIV_INTERN |
|
157 |
void |
|
158 |
srv_conc_enter_innodb( |
|
208
by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
159 |
@@ -1099,6 +1169,13 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
160 |
return; |
161 |
} |
|
162 |
||
163 |
+#ifdef HAVE_ATOMIC_BUILTINS
|
|
164 |
+ if (srv_thread_concurrency_timer_based) {
|
|
165 |
+ srv_conc_enter_innodb_timer_based(trx);
|
|
166 |
+ return;
|
|
167 |
+ }
|
|
168 |
+#endif
|
|
169 |
+
|
|
170 |
os_fast_mutex_lock(&srv_conc_mutex); |
|
171 |
retry: |
|
172 |
if (trx->declared_to_be_inside_innodb) { |
|
208
by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
173 |
@@ -1242,6 +1319,14 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
174 |
} |
175 |
||
176 |
ut_ad(srv_conc_n_threads >= 0); |
|
177 |
+#ifdef HAVE_ATOMIC_BUILTINS
|
|
178 |
+ if (srv_thread_concurrency_timer_based) {
|
|
179 |
+ os_atomic_increment_lint(&srv_conc_n_threads, 1);
|
|
180 |
+ trx->declared_to_be_inside_innodb = TRUE;
|
|
181 |
+ trx->n_tickets_to_enter_innodb = 1;
|
|
182 |
+ return;
|
|
183 |
+ }
|
|
184 |
+#endif
|
|
185 |
||
186 |
os_fast_mutex_lock(&srv_conc_mutex); |
|
187 |
||
208
by Yasufumi Kinoshita
Yasufumi patches and several are ported to 5.1.56; Note: option innodb_stats_method was removed from innodb_stats.patch, because implemented officially. And, bug733317 should be fixed before release |
188 |
@@ -1275,6 +1360,13 @@
|
1
by kinoyasu
merge, reorder and port patches based on mysql 5.1.46 innodb 1.0.7 |
189 |
return; |
190 |
} |
|
191 |
||
192 |
+#ifdef HAVE_ATOMIC_BUILTINS
|
|
193 |
+ if (srv_thread_concurrency_timer_based) {
|
|
194 |
+ srv_conc_exit_innodb_timer_based(trx);
|
|
195 |
+ return;
|
|
196 |
+ }
|
|
197 |
+#endif
|
|
198 |
+
|
|
199 |
os_fast_mutex_lock(&srv_conc_mutex); |
|
200 |
||
201 |
ut_ad(srv_conc_n_threads > 0); |