]>
Commit | Line | Data |
---|---|---|
89b96684 ER |
1 | diff -r d4826c0a98c2 include/mysql_com.h |
2 | --- a/include/mysql_com.h Wed Jul 29 09:58:58 2009 -0700 | |
3 | +++ b/include/mysql_com.h Wed Jul 29 10:00:12 2009 -0700 | |
4 | @@ -122,6 +122,9 @@ | |
eccb488f ER |
5 | #define REFRESH_DES_KEY_FILE 0x40000L |
6 | #define REFRESH_USER_RESOURCES 0x80000L | |
89b96684 | 7 | |
eccb488f ER |
8 | +/* TRUNCATE INFORMATION_SCHEMA.INNODB_IO_PATTERN */ |
9 | +#define REFRESH_INNODB_IO_PATTERN 0x1000000L | |
89b96684 | 10 | + |
eccb488f ER |
11 | #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */ |
12 | #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */ | |
89b96684 ER |
13 | #define CLIENT_LONG_FLAG 4 /* Get all column flags */ |
14 | diff -r d4826c0a98c2 innobase/buf/buf0buf.c | |
15 | --- a/innobase/buf/buf0buf.c Wed Jul 29 09:58:58 2009 -0700 | |
16 | +++ b/innobase/buf/buf0buf.c Wed Jul 29 10:00:12 2009 -0700 | |
17 | @@ -654,6 +654,9 @@ | |
eccb488f ER |
18 | } |
19 | ||
20 | buf_pool->page_hash = hash_create(2 * max_size); | |
21 | + buf_pool->io_counter_hash = NULL; | |
22 | + buf_pool->io_counter_heap = NULL; | |
23 | + buf_pool->io_counters = 0; | |
24 | ||
25 | buf_pool->n_pend_reads = 0; | |
26 | ||
89b96684 | 27 | @@ -1967,6 +1970,9 @@ |
eccb488f ER |
28 | ulint io_type; |
29 | ulint read_page_no; | |
30 | ||
31 | + buf_io_counter_t* io_counter; | |
32 | + ulint fold; | |
33 | + | |
34 | ut_ad(block); | |
35 | ||
36 | ut_a(block->state == BUF_BLOCK_FILE_PAGE); | |
89b96684 | 37 | @@ -2068,6 +2074,26 @@ |
eccb488f ER |
38 | buf_pool->n_pages_read++; |
39 | ||
40 | rw_lock_x_unlock_gen(&(block->lock), BUF_IO_READ); | |
41 | + /* io_counter here */ | |
42 | + if (srv_io_pattern && srv_io_pattern_trace_running) { | |
43 | + fold = buf_page_address_fold(block->space, block->offset); | |
44 | + HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter, | |
45 | + (io_counter->space == block->space) && (io_counter->offset == block->offset)); | |
46 | + if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) { | |
47 | + io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t))); | |
48 | + io_counter->space = block->space; | |
49 | + io_counter->offset = block->offset; | |
50 | + io_counter->n_read = 0; | |
51 | + io_counter->n_write = 0; | |
52 | + HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash, | |
53 | + buf_page_address_fold(block->space, block->offset), io_counter); | |
54 | + buf_pool->io_counters++; | |
55 | + } | |
56 | + if (io_counter != NULL) { | |
57 | + io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block))); | |
58 | + io_counter->n_read++; | |
59 | + } | |
60 | + } | |
61 | ||
62 | #ifdef UNIV_DEBUG | |
63 | if (buf_debug_prints) { | |
89b96684 | 64 | @@ -2083,6 +2109,26 @@ |
eccb488f ER |
65 | buf_flush_write_complete(block); |
66 | ||
67 | rw_lock_s_unlock_gen(&(block->lock), BUF_IO_WRITE); | |
68 | + /* io_counter here */ | |
69 | + if (srv_io_pattern && srv_io_pattern_trace_running) { | |
70 | + fold = buf_page_address_fold(block->space, block->offset); | |
71 | + HASH_SEARCH(hash, buf_pool->io_counter_hash, fold, io_counter, | |
72 | + (io_counter->space == block->space) && (io_counter->offset == block->offset)); | |
73 | + if (io_counter == NULL && buf_pool->io_counters < srv_io_pattern_size_limit) { | |
74 | + io_counter = mem_heap_alloc(buf_pool->io_counter_heap,(sizeof(buf_io_counter_t))); | |
75 | + io_counter->space = block->space; | |
76 | + io_counter->offset = block->offset; | |
77 | + io_counter->n_read = 0; | |
78 | + io_counter->n_write = 0; | |
79 | + HASH_INSERT(buf_io_counter_t, hash, buf_pool->io_counter_hash, | |
80 | + buf_page_address_fold(block->space, block->offset), io_counter); | |
81 | + buf_pool->io_counters++; | |
82 | + } | |
83 | + if (io_counter != NULL) { | |
84 | + io_counter->index_id = ut_dulint_get_low(btr_page_get_index_id(buf_block_get_frame(block))); | |
85 | + io_counter->n_write++; | |
86 | + } | |
87 | + } | |
88 | ||
89 | buf_pool->n_pages_written++; | |
90 | ||
89b96684 | 91 | @@ -2657,3 +2703,58 @@ |
eccb488f ER |
92 | return buf_pool_get_nth_block(buf_pool, i); |
93 | ||
94 | } | |
95 | + | |
96 | +/************************************************************************* | |
97 | +Controls the internal hash table for IO pattern tracing | |
98 | +along innodb_io_pattern_trace value.*/ | |
99 | + | |
100 | +void | |
101 | +buf_io_counter_control(void) | |
102 | +/*========================*/ | |
103 | +{ | |
104 | + ulint n; | |
105 | + | |
106 | + mutex_enter(&(buf_pool->mutex)); | |
107 | + if (srv_io_pattern_trace) { | |
108 | + if (buf_pool->io_counter_hash == NULL) { | |
109 | + /* estimating (buf_pool * 10) */ | |
110 | + buf_pool->io_counter_hash = hash_create(20 * buf_pool->max_size); | |
111 | + buf_pool->io_counter_heap = mem_heap_create(4096 * 1024); | |
112 | + buf_pool->io_counters = 0; | |
113 | + | |
114 | + srv_io_pattern = TRUE; | |
115 | + } | |
116 | + } else { | |
117 | + if (buf_pool->io_counter_hash != NULL) { | |
118 | + srv_io_pattern = FALSE; | |
119 | + | |
120 | + for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) { | |
121 | + (buf_pool->io_counter_hash->array + n)->node = NULL; | |
122 | + } | |
123 | + mem_heap_free(buf_pool->io_counter_heap); | |
124 | + buf_pool->io_counter_heap = NULL; | |
125 | + buf_pool->io_counters = 0; | |
126 | + | |
127 | + hash_table_free(buf_pool->io_counter_hash); | |
128 | + buf_pool->io_counter_hash = NULL; | |
129 | + } | |
130 | + } | |
131 | + mutex_exit(&(buf_pool->mutex)); | |
132 | +} | |
133 | + | |
134 | +void | |
135 | +buf_io_counter_clear(void) | |
136 | +/*======================*/ | |
137 | +{ | |
138 | + ulint n; | |
139 | + | |
140 | + mutex_enter(&(buf_pool->mutex)); | |
141 | + if (buf_pool->io_counter_hash != NULL) { | |
142 | + for (n = 0; n < buf_pool->io_counter_hash->n_cells; n++) { | |
143 | + (buf_pool->io_counter_hash->array + n)->node = NULL; | |
144 | + } | |
145 | + mem_heap_empty(buf_pool->io_counter_heap); | |
146 | + buf_pool->io_counters = 0; | |
147 | + } | |
148 | + mutex_exit(&(buf_pool->mutex)); | |
149 | +} | |
89b96684 ER |
150 | diff -r d4826c0a98c2 innobase/include/buf0buf.h |
151 | --- a/innobase/include/buf0buf.h Wed Jul 29 09:58:58 2009 -0700 | |
152 | +++ b/innobase/include/buf0buf.h Wed Jul 29 10:00:12 2009 -0700 | |
eccb488f ER |
153 | @@ -709,6 +709,18 @@ |
154 | void buf_pool_dump(void); | |
155 | buf_block_t* buf_pool_get_nth_block_no_inline(buf_pool_t* pool, ulint i); | |
156 | ||
157 | + | |
158 | +/************************************************************************* | |
159 | +Controls the internal hash table for IO pattern tracing | |
160 | +along innodb_io_pattern_trace value.*/ | |
161 | + | |
162 | +void | |
163 | +buf_io_counter_control(void); | |
164 | +/*=========================*/ | |
165 | + | |
166 | +void | |
167 | +buf_io_counter_clear(void); | |
168 | +/*=======================*/ | |
169 | ||
170 | /* The buffer control block structure */ | |
171 | ||
172 | @@ -930,6 +942,9 @@ | |
173 | ulint curr_size; /* current pool size in pages; | |
174 | currently always the same as | |
175 | max_size */ | |
176 | + hash_table_t* io_counter_hash; | |
177 | + mem_heap_t* io_counter_heap; | |
178 | + ulint io_counters; | |
179 | hash_table_t* page_hash; /* hash table of the file pages */ | |
180 | ||
181 | ulint n_pend_reads; /* number of pending read operations */ | |
182 | @@ -1015,6 +1030,15 @@ | |
183 | locki table, are not in this list */ | |
184 | }; | |
185 | ||
186 | +struct buf_io_counter_struct{ | |
187 | + ulint space; | |
188 | + ulint offset; | |
189 | + buf_io_counter_t* hash; | |
190 | + ulint index_id; | |
191 | + ulint n_read; | |
192 | + ulint n_write; | |
193 | +}; | |
194 | + | |
195 | /* States of a control block */ | |
196 | #define BUF_BLOCK_NOT_USED 211 /* is in the free list */ | |
197 | #define BUF_BLOCK_READY_FOR_USE 212 /* when buf_get_free_block returns | |
89b96684 ER |
198 | diff -r d4826c0a98c2 innobase/include/buf0types.h |
199 | --- a/innobase/include/buf0types.h Wed Jul 29 09:58:58 2009 -0700 | |
200 | +++ b/innobase/include/buf0types.h Wed Jul 29 10:00:12 2009 -0700 | |
eccb488f ER |
201 | @@ -12,6 +12,8 @@ |
202 | typedef struct buf_block_struct buf_block_t; | |
203 | typedef struct buf_pool_struct buf_pool_t; | |
204 | ||
205 | +typedef struct buf_io_counter_struct buf_io_counter_t; | |
206 | + | |
207 | /* The 'type' used of a buffer frame */ | |
208 | typedef byte buf_frame_t; | |
209 | ||
89b96684 ER |
210 | diff -r d4826c0a98c2 innobase/include/srv0srv.h |
211 | --- a/innobase/include/srv0srv.h Wed Jul 29 09:58:58 2009 -0700 | |
212 | +++ b/innobase/include/srv0srv.h Wed Jul 29 10:00:12 2009 -0700 | |
213 | @@ -146,6 +146,11 @@ | |
214 | extern ulint srv_enable_unsafe_group_commit; | |
337bc045 | 215 | extern uint srv_read_ahead; |
89b96684 | 216 | extern uint srv_adaptive_checkpoint; |
eccb488f ER |
217 | + |
218 | +extern volatile ibool srv_io_pattern; | |
219 | +extern ulong srv_io_pattern_trace; | |
220 | +extern ulong srv_io_pattern_trace_running; | |
221 | +extern ulong srv_io_pattern_size_limit; | |
222 | /*-------------------------------------------*/ | |
223 | ||
224 | extern ulint srv_n_rows_inserted; | |
89b96684 ER |
225 | diff -r d4826c0a98c2 innobase/srv/srv0srv.c |
226 | --- a/innobase/srv/srv0srv.c Wed Jul 29 09:58:58 2009 -0700 | |
227 | +++ b/innobase/srv/srv0srv.c Wed Jul 29 10:00:12 2009 -0700 | |
228 | @@ -352,6 +352,11 @@ | |
eccb488f | 229 | |
337bc045 | 230 | uint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */ |
89b96684 | 231 | uint srv_adaptive_checkpoint = 0; /* 0: none 1: reflex 2: estimate */ |
eccb488f ER |
232 | + |
233 | +volatile ibool srv_io_pattern = FALSE; | |
234 | +ulint srv_io_pattern_trace = 0; | |
235 | +ulint srv_io_pattern_trace_running = 0; | |
236 | +ulint srv_io_pattern_size_limit = ULINT_MAX - (1024 * 1024); | |
237 | /*-------------------------------------------*/ | |
238 | ulong srv_n_spin_wait_rounds = 20; | |
239 | ulong srv_n_free_tickets_to_enter = 500; | |
89b96684 ER |
240 | diff -r d4826c0a98c2 mysql-test/r/information_schema.result |
241 | --- a/mysql-test/r/information_schema.result Wed Jul 29 09:58:58 2009 -0700 | |
242 | +++ b/mysql-test/r/information_schema.result Wed Jul 29 10:00:12 2009 -0700 | |
eccb488f ER |
243 | @@ -59,6 +59,7 @@ |
244 | USER_PRIVILEGES | |
245 | USER_STATISTICS | |
246 | VIEWS | |
247 | +INNODB_IO_PATTERN | |
248 | columns_priv | |
249 | db | |
250 | func | |
251 | @@ -742,7 +743,7 @@ | |
252 | CREATE VIEW a1 (t_CRASHME) AS SELECT f1 FROM t_crashme GROUP BY f1; | |
253 | CREATE VIEW a2 AS SELECT t_CRASHME FROM a1; | |
254 | count(*) | |
255 | -108 | |
256 | +109 | |
257 | drop view a2, a1; | |
258 | drop table t_crashme; | |
259 | select table_schema,table_name, column_name from | |
260 | @@ -812,12 +813,13 @@ | |
261 | TABLE_PRIVILEGES TABLE_NAME select | |
262 | TABLE_STATISTICS TABLE_NAME select | |
263 | VIEWS TABLE_NAME select | |
264 | +INNODB_IO_PATTERN TABLE_NAME select | |
265 | delete from mysql.user where user='mysqltest_4'; | |
266 | delete from mysql.db where user='mysqltest_4'; | |
267 | flush privileges; | |
268 | SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA; | |
269 | table_schema count(*) | |
270 | -information_schema 23 | |
271 | +information_schema 24 | |
272 | mysql 17 | |
273 | create table t1 (i int, j int); | |
274 | create trigger trg1 before insert on t1 for each row | |
275 | @@ -1225,6 +1227,7 @@ | |
276 | USER_PRIVILEGES GRANTEE | |
277 | USER_STATISTICS USER | |
278 | VIEWS TABLE_SCHEMA | |
279 | +INNODB_IO_PATTERN SPACE | |
280 | SELECT t.table_name, c1.column_name | |
281 | FROM information_schema.tables t | |
282 | INNER JOIN | |
283 | @@ -1263,6 +1266,7 @@ | |
284 | USER_PRIVILEGES GRANTEE | |
285 | USER_STATISTICS USER | |
286 | VIEWS TABLE_SCHEMA | |
287 | +INNODB_IO_PATTERN SPACE | |
288 | SELECT MAX(table_name) FROM information_schema.tables; | |
289 | MAX(table_name) | |
290 | VIEWS | |
291 | @@ -1337,6 +1341,7 @@ | |
292 | COLUMN_PRIVILEGES information_schema.COLUMN_PRIVILEGES 1 | |
293 | INDEX_STATISTICS information_schema.INDEX_STATISTICS 1 | |
294 | INNODB_BUFFER_POOL_CONTENT information_schema.INNODB_BUFFER_POOL_CONTENT 1 | |
295 | +INNODB_IO_PATTERN information_schema.INNODB_IO_PATTERN 1 | |
296 | KEY_COLUMN_USAGE information_schema.KEY_COLUMN_USAGE 1 | |
297 | PROCESSLIST information_schema.PROCESSLIST 1 | |
298 | PROFILING information_schema.PROFILING 1 | |
89b96684 ER |
299 | diff -r d4826c0a98c2 mysql-test/r/information_schema_db.result |
300 | --- a/mysql-test/r/information_schema_db.result Wed Jul 29 09:58:58 2009 -0700 | |
301 | +++ b/mysql-test/r/information_schema_db.result Wed Jul 29 10:00:12 2009 -0700 | |
eccb488f ER |
302 | @@ -28,6 +28,7 @@ |
303 | USER_PRIVILEGES | |
304 | USER_STATISTICS | |
305 | VIEWS | |
306 | +INNODB_IO_PATTERN | |
307 | show tables from INFORMATION_SCHEMA like 'T%'; | |
308 | Tables_in_information_schema (T%) | |
309 | TABLES | |
89b96684 ER |
310 | diff -r d4826c0a98c2 mysql-test/r/mysqlshow.result |
311 | --- a/mysql-test/r/mysqlshow.result Wed Jul 29 09:58:58 2009 -0700 | |
312 | +++ b/mysql-test/r/mysqlshow.result Wed Jul 29 10:00:12 2009 -0700 | |
eccb488f ER |
313 | @@ -102,6 +102,7 @@ |
314 | | USER_PRIVILEGES | | |
315 | | USER_STATISTICS | | |
316 | | VIEWS | | |
317 | +| INNODB_IO_PATTERN | | |
318 | +---------------------------------------+ | |
319 | Database: INFORMATION_SCHEMA | |
320 | +---------------------------------------+ | |
321 | @@ -130,6 +131,7 @@ | |
322 | | USER_PRIVILEGES | | |
323 | | USER_STATISTICS | | |
324 | | VIEWS | | |
325 | +| INNODB_IO_PATTERN | | |
326 | +---------------------------------------+ | |
327 | Wildcard: inf_rmation_schema | |
328 | +--------------------+ | |
89b96684 | 329 | diff -r d4826c0a98c2 patch_info/innodb_io_pattern.info |
eccb488f | 330 | --- /dev/null Thu Jan 01 00:00:00 1970 +0000 |
89b96684 | 331 | +++ b/patch_info/innodb_io_pattern.info Wed Jul 29 10:00:12 2009 -0700 |
eccb488f ER |
332 | @@ -0,0 +1,8 @@ |
333 | +File=innodb_io_pattern.patch | |
334 | +Name=Information schema table of InnoDB IO counts for each datafile pages | |
335 | +Version=1.0 | |
336 | +Author=Percona <info@percona.com> | |
337 | +License=GPL | |
338 | +Comment=INFORMATION_SCHEMA.INNODB_IO_PATTERN | |
339 | +2008-12-01 | |
340 | +YK: fix for mysql-test | |
89b96684 ER |
341 | diff -r d4826c0a98c2 sql/ha_innodb.cc |
342 | --- a/sql/ha_innodb.cc Wed Jul 29 09:58:58 2009 -0700 | |
343 | +++ b/sql/ha_innodb.cc Wed Jul 29 10:00:12 2009 -0700 | |
344 | @@ -1583,6 +1583,8 @@ | |
eccb488f ER |
345 | pthread_cond_init(&commit_cond, NULL); |
346 | innodb_inited= 1; | |
347 | ||
348 | + buf_io_counter_control(); | |
349 | + | |
350 | /* If this is a replication slave and we needed to do a crash recovery, | |
351 | set the master binlog position to what InnoDB internally knew about | |
352 | how far we got transactions durable inside InnoDB. There is a | |
89b96684 | 353 | @@ -6551,6 +6553,28 @@ |
eccb488f ER |
354 | } |
355 | ||
356 | /**************************************************************************** | |
357 | +Controls the internal hash table for IO pattern tracing | |
358 | +along innodb_io_pattern_trace value.*/ | |
359 | + | |
360 | +void | |
361 | +innodb_io_pattern_control(void) | |
362 | +/*===========================*/ | |
363 | +{ | |
364 | + if (innodb_inited) { | |
365 | + buf_io_counter_control(); | |
366 | + } | |
367 | +} | |
368 | + | |
369 | +void | |
370 | +innodb_io_pattern_clear(void) | |
371 | +/*=========================*/ | |
372 | +{ | |
373 | + if (innodb_inited) { | |
374 | + buf_io_counter_clear(); | |
375 | + } | |
376 | +} | |
377 | + | |
378 | +/**************************************************************************** | |
379 | Implements the SHOW INNODB STATUS command. Sends the output of the InnoDB | |
380 | Monitor to the client. */ | |
381 | ||
89b96684 ER |
382 | diff -r d4826c0a98c2 sql/ha_innodb.h |
383 | --- a/sql/ha_innodb.h Wed Jul 29 09:58:58 2009 -0700 | |
384 | +++ b/sql/ha_innodb.h Wed Jul 29 10:00:12 2009 -0700 | |
45532174 | 385 | @@ -245,6 +245,9 @@ |
89b96684 | 386 | extern uint srv_adaptive_checkpoint; |
eccb488f ER |
387 | extern ulong srv_show_locks_held; |
388 | extern ulong srv_show_verbose_locks; | |
389 | +extern ulong srv_io_pattern_trace; | |
390 | +extern ulong srv_io_pattern_trace_running; | |
391 | +extern ulong srv_io_pattern_size_limit; | |
89b96684 | 392 | |
45532174 ER |
393 | /* An option to enable the fix for "Bug#43660 SHOW INDEXES/ANALYZE does |
394 | NOT update cardinality for indexes of InnoDB table". By default we are | |
89b96684 | 395 | @@ -278,6 +281,9 @@ |
eccb488f ER |
396 | bool innodb_mutex_show_status(THD* thd); |
397 | void innodb_export_status(void); | |
89b96684 | 398 | |
eccb488f ER |
399 | +void innodb_io_pattern_control(void); |
400 | +void innodb_io_pattern_clear(void); | |
89b96684 | 401 | + |
eccb488f ER |
402 | void innobase_release_temporary_latches(THD *thd); |
403 | ||
89b96684 ER |
404 | void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset); |
405 | diff -r d4826c0a98c2 sql/lex.h | |
406 | --- a/sql/lex.h Wed Jul 29 09:58:58 2009 -0700 | |
407 | +++ b/sql/lex.h Wed Jul 29 10:00:12 2009 -0700 | |
eccb488f ER |
408 | @@ -244,6 +244,7 @@ |
409 | { "INNER", SYM(INNER_SYM)}, | |
410 | { "INNOBASE", SYM(INNOBASE_SYM)}, | |
411 | { "INNODB", SYM(INNOBASE_SYM)}, | |
412 | + { "INNODB_IO_PATTERN", SYM(INNODB_IO_PATTERN)}, | |
413 | { "INOUT", SYM(INOUT_SYM)}, | |
414 | { "INSENSITIVE", SYM(INSENSITIVE_SYM)}, | |
415 | { "INSERT", SYM(INSERT)}, | |
89b96684 ER |
416 | diff -r d4826c0a98c2 sql/mysqld.cc |
417 | --- a/sql/mysqld.cc Wed Jul 29 09:58:58 2009 -0700 | |
418 | +++ b/sql/mysqld.cc Wed Jul 29 10:00:12 2009 -0700 | |
419 | @@ -5029,6 +5029,9 @@ | |
eccb488f ER |
420 | OPT_INNODB_SYNC_SPIN_LOOPS, |
421 | OPT_INNODB_CONCURRENCY_TICKETS, | |
422 | OPT_INNODB_THREAD_SLEEP_DELAY, | |
423 | + OPT_INNODB_IO_PATTERN_TRACE, | |
424 | + OPT_INNODB_IO_PATTERN_TRACE_RUNNING, | |
425 | + OPT_INNODB_IO_PATTERN_SIZE_LIMIT, | |
426 | OPT_BDB_CACHE_SIZE, | |
427 | OPT_BDB_LOG_BUFFER_SIZE, | |
428 | OPT_BDB_MAX_LOCK, | |
89b96684 | 429 | @@ -5461,6 +5464,18 @@ |
eccb488f ER |
430 | "Number of background write I/O threads in InnoDB.", |
431 | (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads, | |
89b96684 | 432 | 0, GET_LONG, REQUIRED_ARG, 8, 1, 64, 0, 0, 0}, |
eccb488f ER |
433 | + {"innodb_io_pattern_trace", OPT_INNODB_IO_PATTERN_TRACE, |
434 | + "Create/Drop the internal hash table for IO pattern tracing.", | |
435 | + (gptr*) &srv_io_pattern_trace, (gptr*) &srv_io_pattern_trace, | |
436 | + 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0}, | |
437 | + {"innodb_io_pattern_trace_running", OPT_INNODB_IO_PATTERN_TRACE_RUNNING, | |
438 | + "Control IO pattern trace running or not.", | |
439 | + (gptr*) &srv_io_pattern_trace_running, (gptr*) &srv_io_pattern_trace_running, | |
440 | + 0, GET_ULONG, REQUIRED_ARG, 0, 0, 1, 0, 0, 0}, | |
441 | + {"innodb_io_pattern_size_limit", OPT_INNODB_IO_PATTERN_SIZE_LIMIT, | |
442 | + "Set max number of counters per data pages. (0 = disable counting).", | |
443 | + (gptr*) &srv_io_pattern_size_limit, (gptr*) &srv_io_pattern_size_limit, | |
444 | + 0, GET_ULONG, REQUIRED_ARG, 0, 0, ULONG_MAX - (1024 * 1024), 0, 0, 0}, | |
445 | #endif /* End HAVE_INNOBASE_DB */ | |
446 | {"isam", OPT_ISAM, "Obsolete. ISAM storage engine is no longer supported.", | |
447 | (gptr*) &opt_isam, (gptr*) &opt_isam, 0, GET_BOOL, NO_ARG, 0, 0, 0, | |
89b96684 ER |
448 | diff -r d4826c0a98c2 sql/set_var.cc |
449 | --- a/sql/set_var.cc Wed Jul 29 09:58:58 2009 -0700 | |
450 | +++ b/sql/set_var.cc Wed Jul 29 10:00:12 2009 -0700 | |
451 | @@ -546,6 +546,12 @@ | |
eccb488f ER |
452 | sys_var_long_ptr sys_innodb_show_verbose_locks( |
453 | "innodb_show_verbose_locks", | |
454 | &srv_show_verbose_locks); | |
455 | +sys_var_innodb_io_pattern_trace sys_innodb_io_pattern_trace("innodb_io_pattern_trace", | |
456 | + &srv_io_pattern_trace); | |
457 | +sys_var_long_ptr sys_innodb_io_pattern_trace_running("innodb_io_pattern_trace_running", | |
458 | + &srv_io_pattern_trace_running); | |
459 | +sys_var_long_ptr sys_innodb_io_pattern_size_limit("innodb_io_pattern_size_limit", | |
460 | + &srv_io_pattern_size_limit); | |
461 | sys_var_const_os_str_ptr sys_innodb_data_file_path("innodb_data_file_path", | |
462 | &innobase_data_file_path); | |
463 | sys_var_const_os_str_ptr sys_innodb_data_home_dir("innodb_data_home_dir", | |
89b96684 | 464 | @@ -926,6 +932,9 @@ |
eccb488f ER |
465 | &sys_innodb_adaptive_checkpoint, |
466 | &sys_innodb_show_locks_held, | |
467 | &sys_innodb_show_verbose_locks, | |
468 | + &sys_innodb_io_pattern_trace, | |
469 | + &sys_innodb_io_pattern_trace_running, | |
470 | + &sys_innodb_io_pattern_size_limit, | |
471 | #endif | |
472 | &sys_trust_routine_creators, | |
473 | &sys_trust_function_creators, | |
89b96684 | 474 | @@ -1075,6 +1084,9 @@ |
eccb488f ER |
475 | {sys_innodb_adaptive_checkpoint.name, (char*) &sys_innodb_adaptive_checkpoint, SHOW_SYS}, |
476 | {"innodb_read_io_threads", (char*) &innobase_read_io_threads, SHOW_LONG}, | |
477 | {"innodb_write_io_threads", (char*) &innobase_write_io_threads, SHOW_LONG}, | |
478 | + {sys_innodb_io_pattern_trace.name, (char*) &sys_innodb_io_pattern_trace, SHOW_SYS}, | |
479 | + {sys_innodb_io_pattern_trace_running.name, (char*) &sys_innodb_io_pattern_trace_running, SHOW_SYS}, | |
480 | + {sys_innodb_io_pattern_size_limit.name, (char*) &sys_innodb_io_pattern_size_limit, SHOW_SYS}, | |
45532174 ER |
481 | {sys_innodb_use_legacy_cardinality_algorithm.name, |
482 | (char*) &sys_innodb_use_legacy_cardinality_algorithm, SHOW_SYS}, | |
eccb488f | 483 | #endif |
89b96684 | 484 | @@ -3210,6 +3222,19 @@ |
eccb488f ER |
485 | thd->variables.lc_time_names= global_system_variables.lc_time_names; |
486 | } | |
487 | ||
488 | +#ifdef HAVE_INNOBASE_DB | |
489 | +bool sys_var_innodb_io_pattern_trace::update(THD *thd, set_var *var) | |
490 | +{ | |
491 | + bool ret; | |
492 | + | |
493 | + ret = sys_var_long_ptr_global::update(thd, var); | |
494 | + | |
495 | + innodb_io_pattern_control(); | |
496 | + | |
497 | + return ret; | |
498 | +} | |
499 | +#endif /* HAVE_INNOBASE_DB */ | |
500 | + | |
501 | /* | |
502 | Functions to update thd->options bits | |
503 | */ | |
89b96684 ER |
504 | diff -r d4826c0a98c2 sql/set_var.h |
505 | --- a/sql/set_var.h Wed Jul 29 09:58:58 2009 -0700 | |
506 | +++ b/sql/set_var.h Wed Jul 29 10:00:12 2009 -0700 | |
507 | @@ -1012,6 +1012,17 @@ | |
eccb488f ER |
508 | virtual void set_default(THD *thd, enum_var_type type); |
509 | }; | |
510 | ||
511 | +#ifdef HAVE_INNOBASE_DB | |
512 | +/* sys_var_innodb_io_pattern_trace */ | |
513 | +class sys_var_innodb_io_pattern_trace :public sys_var_long_ptr | |
514 | +{ | |
515 | +public: | |
516 | + sys_var_innodb_io_pattern_trace(const char *name_arg, ulong *value_ptr_arg) | |
517 | + :sys_var_long_ptr(name_arg,value_ptr_arg) {} | |
518 | + bool update(THD *thd, set_var *var); | |
519 | +}; | |
520 | +#endif /* HAVE_INNOBASE_DB */ | |
521 | + | |
522 | /**************************************************************************** | |
523 | Classes for parsing of the SET command | |
524 | ****************************************************************************/ | |
89b96684 ER |
525 | diff -r d4826c0a98c2 sql/sql_parse.cc |
526 | --- a/sql/sql_parse.cc Wed Jul 29 09:58:58 2009 -0700 | |
527 | +++ b/sql/sql_parse.cc Wed Jul 29 10:00:12 2009 -0700 | |
528 | @@ -8104,6 +8104,13 @@ | |
eccb488f ER |
529 | } |
530 | pthread_mutex_unlock(&LOCK_global_user_client_stats); | |
531 | } | |
532 | +#ifdef HAVE_INNOBASE_DB | |
533 | + if (options & REFRESH_INNODB_IO_PATTERN) | |
534 | + { | |
535 | + tmp_write_to_binlog= 0; | |
536 | + innodb_io_pattern_clear(); | |
537 | + } | |
538 | +#endif /* HAVE_INNOBASE_DB */ | |
539 | *write_to_binlog= tmp_write_to_binlog; | |
540 | return result; | |
541 | } | |
89b96684 ER |
542 | diff -r d4826c0a98c2 sql/sql_show.cc |
543 | --- a/sql/sql_show.cc Wed Jul 29 09:58:58 2009 -0700 | |
544 | +++ b/sql/sql_show.cc Wed Jul 29 10:00:12 2009 -0700 | |
545 | @@ -33,6 +33,17 @@ | |
eccb488f ER |
546 | #include "ha_innodb.h" |
547 | #endif | |
89b96684 | 548 | |
eccb488f ER |
549 | +#ifdef HAVE_INNOBASE_DB |
550 | +#define INSIDE_HA_INNOBASE_CC | |
551 | +extern "C" { | |
552 | +#include "srv0srv.h" | |
553 | +#include "buf0buf.h" | |
554 | +#include "dict0dict.h" | |
555 | +} | |
556 | +/* We need to undef it in InnoDB */ | |
557 | +#undef byte | |
558 | +#endif /* HAVE_INNOBASE_DB */ | |
89b96684 | 559 | + |
eccb488f ER |
560 | #ifndef NO_EMBEDDED_ACCESS_CHECKS |
561 | static const char *grant_names[]={ | |
89b96684 ER |
562 | "select","insert","update","delete","create","drop","reload","shutdown", |
563 | @@ -4108,6 +4119,72 @@ | |
eccb488f ER |
564 | DBUG_RETURN(res); |
565 | } | |
566 | ||
567 | +int innodb_io_pattern_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) | |
568 | +{ | |
569 | + TABLE *table= (TABLE *) tables->table; | |
570 | + | |
571 | + buf_io_counter_t* io_counter; | |
572 | + dict_index_t* index; | |
573 | + | |
574 | + DBUG_ENTER("innodb_io_pattern_fill_table"); | |
575 | + int returnable= 0; | |
576 | + | |
89b96684 ER |
577 | + /* deny access to non-superusers */ |
578 | + if (check_global_access(thd, PROCESS_ACL)) { | |
579 | + DBUG_RETURN(0); | |
580 | + } | |
581 | + | |
eccb488f ER |
582 | + /* We cannot use inline functions of InnoDB here */ |
583 | + | |
584 | + /* !!!!!ATTENTION!!!!!: This function is not protected by mutex for performance. */ | |
585 | + /* Don't use "DROP TABLE innodb_io_pattern" and INFORMATION_SCHEMA.INNODB_IO_PATTERN */ | |
586 | + /* at the same time as possible. */ | |
587 | + | |
588 | + if (srv_io_pattern) { | |
589 | + for (ulint n=0; n < buf_pool->io_counter_hash->n_cells; n++) { | |
590 | + if (!srv_io_pattern) | |
591 | + goto end_func; | |
592 | + | |
593 | + io_counter = (buf_io_counter_t*)(buf_pool->io_counter_hash->array + n)->node; | |
594 | + while (io_counter) { | |
595 | + if (!srv_io_pattern) | |
596 | + goto end_func; | |
597 | + | |
598 | + if (dict_sys != NULL) { | |
599 | + dulint id; | |
600 | + id.high = 0; | |
601 | + id.low = io_counter->index_id; | |
602 | + index = dict_index_find_on_id_low(id); | |
603 | + } else { | |
604 | + index = NULL; | |
605 | + } | |
606 | + | |
607 | + table->field[0]->store(io_counter->space); | |
608 | + table->field[1]->store(io_counter->offset); | |
609 | + table->field[2]->store(io_counter->index_id); | |
610 | + if (index != NULL) { | |
611 | + table->field[3]->store(index->table_name,strlen(index->table_name),system_charset_info); | |
612 | + table->field[4]->store(index->name,strlen(index->name),system_charset_info); | |
613 | + } else { | |
614 | + table->field[3]->store("",0,system_charset_info); | |
615 | + table->field[4]->store("",0,system_charset_info); | |
616 | + } | |
617 | + table->field[5]->store(io_counter->n_read); | |
618 | + table->field[6]->store(io_counter->n_write); | |
619 | + if (schema_table_store_record(thd, table)) | |
620 | + { | |
621 | + returnable= 1; | |
622 | + goto end_func; | |
623 | + } | |
624 | + io_counter = io_counter->hash; | |
625 | + } | |
626 | + } | |
627 | + } | |
628 | + | |
629 | + end_func: | |
630 | + DBUG_RETURN(returnable); | |
631 | +} | |
632 | + | |
633 | /* | |
634 | Find schema_tables elment by name | |
635 | ||
89b96684 | 636 | @@ -4914,6 +4986,19 @@ |
eccb488f ER |
637 | {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} |
638 | }; | |
639 | ||
640 | +#ifdef HAVE_INNOBASE_DB | |
641 | +ST_FIELD_INFO innodb_io_pattern_field_info[]= | |
642 | +{ | |
643 | + {"SPACE", 11, MYSQL_TYPE_LONG, 0, 0, "space_id"}, | |
644 | + {"OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, "offset"}, | |
645 | + {"INDEX_ID", 11, MYSQL_TYPE_LONG, 0, 0, "index id"}, | |
646 | + {"TABLE_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "table name"}, | |
647 | + {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"}, | |
648 | + {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"}, | |
649 | + {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"}, | |
650 | + {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} | |
651 | +}; | |
652 | +#endif | |
653 | ||
654 | ST_FIELD_INFO variables_fields_info[]= | |
655 | { | |
89b96684 | 656 | @@ -5089,6 +5174,10 @@ |
eccb488f ER |
657 | make_old_format, 0, -1, -1, 1}, |
658 | {"VIEWS", view_fields_info, create_schema_table, | |
659 | get_all_tables, 0, get_schema_views_record, 1, 2, 0}, | |
660 | +#ifdef HAVE_INNOBASE_DB | |
661 | + {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table, | |
662 | + innodb_io_pattern_fill_table, 0, 0, -1, -1, 0}, | |
663 | +#endif | |
664 | {0, 0, 0, 0, 0, 0, 0, 0, 0} | |
665 | }; | |
666 | ||
89b96684 ER |
667 | diff -r d4826c0a98c2 sql/sql_yacc.yy |
668 | --- a/sql/sql_yacc.yy Wed Jul 29 09:58:58 2009 -0700 | |
669 | +++ b/sql/sql_yacc.yy Wed Jul 29 10:00:12 2009 -0700 | |
eccb488f ER |
670 | @@ -685,6 +685,7 @@ |
671 | %token INFILE | |
672 | %token INNER_SYM | |
673 | %token INNOBASE_SYM | |
674 | +%token INNODB_IO_PATTERN | |
675 | %token INOUT_SYM | |
676 | %token INSENSITIVE_SYM | |
677 | %token INSERT | |
89b96684 | 678 | @@ -8500,6 +8501,7 @@ |
eccb488f ER |
679 | | MASTER_SYM { Lex->type|= REFRESH_MASTER; } |
680 | | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; } | |
681 | | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; } | |
682 | + | INNODB_IO_PATTERN { Lex->type|= REFRESH_INNODB_IO_PATTERN; } | |
683 | | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; } | |
684 | | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; } | |
685 | | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; } | |
89b96684 | 686 | @@ -9552,6 +9554,7 @@ |
eccb488f ER |
687 | | ISOLATION {} |
688 | | ISSUER_SYM {} | |
689 | | INNOBASE_SYM {} | |
690 | + | INNODB_IO_PATTERN {} | |
691 | | INSERT_METHOD {} | |
692 | | IO_SYM {} | |
693 | | IPC_SYM {} |