]> git.pld-linux.org Git - packages/mysql.git/blame - mysql-innodb_io_pattern.patch
- add xtrabackup patch, needs more or less percona patches to compile
[packages/mysql.git] / mysql-innodb_io_pattern.patch
CommitLineData
eccb488f
ER
1diff -r 2bbfde0e0e70 include/mysql_com.h
2--- a/include/mysql_com.h Mon Dec 22 00:33:11 2008 -0800
3+++ b/include/mysql_com.h Mon Dec 22 00:33:48 2008 -0800
4@@ -121,6 +121,9 @@
5 #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
6 #define REFRESH_DES_KEY_FILE 0x40000L
7 #define REFRESH_USER_RESOURCES 0x80000L
8+
9+/* TRUNCATE INFORMATION_SCHEMA.INNODB_IO_PATTERN */
10+#define REFRESH_INNODB_IO_PATTERN 0x1000000L
11
12 #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
13 #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
14diff -r 2bbfde0e0e70 innobase/buf/buf0buf.c
15--- a/innobase/buf/buf0buf.c Mon Dec 22 00:33:11 2008 -0800
16+++ b/innobase/buf/buf0buf.c Mon Dec 22 00:33:48 2008 -0800
17@@ -653,6 +653,9 @@
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
27@@ -1966,6 +1969,9 @@
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);
37@@ -2067,6 +2073,26 @@
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) {
64@@ -2082,6 +2108,26 @@
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
91@@ -2656,3 +2702,58 @@
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+}
150diff -r 2bbfde0e0e70 innobase/include/buf0buf.h
151--- a/innobase/include/buf0buf.h Mon Dec 22 00:33:11 2008 -0800
152+++ b/innobase/include/buf0buf.h Mon Dec 22 00:33:48 2008 -0800
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
198diff -r 2bbfde0e0e70 innobase/include/buf0types.h
199--- a/innobase/include/buf0types.h Mon Dec 22 00:33:11 2008 -0800
200+++ b/innobase/include/buf0types.h Mon Dec 22 00:33:48 2008 -0800
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
210diff -r 2bbfde0e0e70 innobase/include/srv0srv.h
211--- a/innobase/include/srv0srv.h Mon Dec 22 00:33:11 2008 -0800
212+++ b/innobase/include/srv0srv.h Mon Dec 22 00:33:48 2008 -0800
213@@ -141,6 +141,11 @@
214 extern ulint srv_io_capacity;
215 extern ulint srv_read_ahead;
216 extern ulint srv_adaptive_checkpoint;
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;
225diff -r 2bbfde0e0e70 innobase/srv/srv0srv.c
226--- a/innobase/srv/srv0srv.c Mon Dec 22 00:33:11 2008 -0800
227+++ b/innobase/srv/srv0srv.c Mon Dec 22 00:33:48 2008 -0800
228@@ -337,6 +337,11 @@
229
230 ulint srv_read_ahead = 3; /* 1: random 2: linear 3: Both */
231 ulint srv_adaptive_checkpoint = 0; /* 0:disable 1:enable */
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;
240diff -r 2bbfde0e0e70 mysql-test/r/information_schema.result
241--- a/mysql-test/r/information_schema.result Mon Dec 22 00:33:11 2008 -0800
242+++ b/mysql-test/r/information_schema.result Mon Dec 22 00:33:48 2008 -0800
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
299diff -r 2bbfde0e0e70 mysql-test/r/information_schema_db.result
300--- a/mysql-test/r/information_schema_db.result Mon Dec 22 00:33:11 2008 -0800
301+++ b/mysql-test/r/information_schema_db.result Mon Dec 22 00:33:48 2008 -0800
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
310diff -r 2bbfde0e0e70 mysql-test/r/mysqlshow.result
311--- a/mysql-test/r/mysqlshow.result Mon Dec 22 00:33:11 2008 -0800
312+++ b/mysql-test/r/mysqlshow.result Mon Dec 22 00:33:48 2008 -0800
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 +--------------------+
329diff -r 2bbfde0e0e70 patch_info/innodb_io_pattern.info
330--- /dev/null Thu Jan 01 00:00:00 1970 +0000
331+++ b/patch_info/innodb_io_pattern.info Mon Dec 22 00:33:48 2008 -0800
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
341diff -r 2bbfde0e0e70 sql/ha_innodb.cc
342--- a/sql/ha_innodb.cc Mon Dec 22 00:33:11 2008 -0800
343+++ b/sql/ha_innodb.cc Mon Dec 22 00:33:48 2008 -0800
344@@ -1569,6 +1569,8 @@
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
353@@ -6527,6 +6529,28 @@
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
382diff -r 2bbfde0e0e70 sql/ha_innodb.h
383--- a/sql/ha_innodb.h Mon Dec 22 00:33:11 2008 -0800
384+++ b/sql/ha_innodb.h Mon Dec 22 00:33:48 2008 -0800
385@@ -240,6 +240,9 @@
386 extern ulong srv_adaptive_checkpoint;
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;
392 }
393
394 bool innobase_init(void);
395@@ -266,6 +269,9 @@
396 bool innodb_I_S_buffer_pool_content(THD* thd, TABLE_LIST *tables);
397 bool innodb_mutex_show_status(THD* thd);
398 void innodb_export_status(void);
399+
400+void innodb_io_pattern_control(void);
401+void innodb_io_pattern_clear(void);
402
403 void innobase_release_temporary_latches(THD *thd);
404
405diff -r 2bbfde0e0e70 sql/lex.h
406--- a/sql/lex.h Mon Dec 22 00:33:11 2008 -0800
407+++ b/sql/lex.h Mon Dec 22 00:33:48 2008 -0800
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)},
416diff -r 2bbfde0e0e70 sql/mysqld.cc
417--- a/sql/mysqld.cc Mon Dec 22 00:33:11 2008 -0800
418+++ b/sql/mysqld.cc Mon Dec 22 00:33:48 2008 -0800
419@@ -4983,6 +4983,9 @@
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,
429@@ -5382,6 +5385,18 @@
430 "Number of background write I/O threads in InnoDB.",
431 (gptr*) &innobase_write_io_threads, (gptr*) &innobase_write_io_threads,
432 0, GET_LONG, REQUIRED_ARG, 1, 1, 64, 0, 0, 0},
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,
448diff -r 2bbfde0e0e70 sql/set_var.cc
449--- a/sql/set_var.cc Mon Dec 22 00:33:11 2008 -0800
450+++ b/sql/set_var.cc Mon Dec 22 00:33:48 2008 -0800
451@@ -501,6 +501,12 @@
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",
464@@ -870,6 +876,9 @@
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,
474@@ -1012,6 +1021,9 @@
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},
481 #endif
482 {sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
483 {sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
484@@ -3117,6 +3129,19 @@
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 */
504diff -r 2bbfde0e0e70 sql/set_var.h
505--- a/sql/set_var.h Mon Dec 22 00:33:11 2008 -0800
506+++ b/sql/set_var.h Mon Dec 22 00:33:48 2008 -0800
507@@ -985,6 +985,17 @@
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 ****************************************************************************/
525diff -r 2bbfde0e0e70 sql/sql_parse.cc
526--- a/sql/sql_parse.cc Mon Dec 22 00:33:11 2008 -0800
527+++ b/sql/sql_parse.cc Mon Dec 22 00:33:48 2008 -0800
528@@ -7998,6 +7998,13 @@
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 }
542diff -r 2bbfde0e0e70 sql/sql_show.cc
543--- a/sql/sql_show.cc Mon Dec 22 00:33:11 2008 -0800
544+++ b/sql/sql_show.cc Mon Dec 22 00:33:48 2008 -0800
545@@ -32,6 +32,17 @@
546 #ifdef HAVE_INNOBASE_DB
547 #include "ha_innodb.h"
548 #endif
549+
550+#ifdef HAVE_INNOBASE_DB
551+#define INSIDE_HA_INNOBASE_CC
552+extern "C" {
553+#include "srv0srv.h"
554+#include "buf0buf.h"
555+#include "dict0dict.h"
556+}
557+/* We need to undef it in InnoDB */
558+#undef byte
559+#endif /* HAVE_INNOBASE_DB */
560
561 #ifndef NO_EMBEDDED_ACCESS_CHECKS
562 static const char *grant_names[]={
563@@ -4074,6 +4085,67 @@
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+
577+ /* We cannot use inline functions of InnoDB here */
578+
579+ /* !!!!!ATTENTION!!!!!: This function is not protected by mutex for performance. */
580+ /* Don't use "DROP TABLE innodb_io_pattern" and INFORMATION_SCHEMA.INNODB_IO_PATTERN */
581+ /* at the same time as possible. */
582+
583+ if (srv_io_pattern) {
584+ for (ulint n=0; n < buf_pool->io_counter_hash->n_cells; n++) {
585+ if (!srv_io_pattern)
586+ goto end_func;
587+
588+ io_counter = (buf_io_counter_t*)(buf_pool->io_counter_hash->array + n)->node;
589+ while (io_counter) {
590+ if (!srv_io_pattern)
591+ goto end_func;
592+
593+ if (dict_sys != NULL) {
594+ dulint id;
595+ id.high = 0;
596+ id.low = io_counter->index_id;
597+ index = dict_index_find_on_id_low(id);
598+ } else {
599+ index = NULL;
600+ }
601+
602+ table->field[0]->store(io_counter->space);
603+ table->field[1]->store(io_counter->offset);
604+ table->field[2]->store(io_counter->index_id);
605+ if (index != NULL) {
606+ table->field[3]->store(index->table_name,strlen(index->table_name),system_charset_info);
607+ table->field[4]->store(index->name,strlen(index->name),system_charset_info);
608+ } else {
609+ table->field[3]->store("",0,system_charset_info);
610+ table->field[4]->store("",0,system_charset_info);
611+ }
612+ table->field[5]->store(io_counter->n_read);
613+ table->field[6]->store(io_counter->n_write);
614+ if (schema_table_store_record(thd, table))
615+ {
616+ returnable= 1;
617+ goto end_func;
618+ }
619+ io_counter = io_counter->hash;
620+ }
621+ }
622+ }
623+
624+ end_func:
625+ DBUG_RETURN(returnable);
626+}
627+
628 /*
629 Find schema_tables elment by name
630
631@@ -4880,6 +4952,19 @@
632 {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
633 };
634
635+#ifdef HAVE_INNOBASE_DB
636+ST_FIELD_INFO innodb_io_pattern_field_info[]=
637+{
638+ {"SPACE", 11, MYSQL_TYPE_LONG, 0, 0, "space_id"},
639+ {"OFFSET", 11, MYSQL_TYPE_LONG, 0, 0, "offset"},
640+ {"INDEX_ID", 11, MYSQL_TYPE_LONG, 0, 0, "index id"},
641+ {"TABLE_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "table name"},
642+ {"INDEX_NAME", 32, MYSQL_TYPE_STRING, 0, 0, "index name"},
643+ {"N_READ", 11, MYSQL_TYPE_LONG, 0, 0, "read ios"},
644+ {"N_WRITE", 11, MYSQL_TYPE_LONG, 0, 0, "write ios"},
645+ {0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
646+};
647+#endif
648
649 ST_FIELD_INFO variables_fields_info[]=
650 {
651@@ -5055,6 +5140,10 @@
652 make_old_format, 0, -1, -1, 1},
653 {"VIEWS", view_fields_info, create_schema_table,
654 get_all_tables, 0, get_schema_views_record, 1, 2, 0},
655+#ifdef HAVE_INNOBASE_DB
656+ {"INNODB_IO_PATTERN", innodb_io_pattern_field_info, create_schema_table,
657+ innodb_io_pattern_fill_table, 0, 0, -1, -1, 0},
658+#endif
659 {0, 0, 0, 0, 0, 0, 0, 0, 0}
660 };
661
662diff -r 2bbfde0e0e70 sql/sql_yacc.yy
663--- a/sql/sql_yacc.yy Mon Dec 22 00:33:11 2008 -0800
664+++ b/sql/sql_yacc.yy Mon Dec 22 00:33:48 2008 -0800
665@@ -685,6 +685,7 @@
666 %token INFILE
667 %token INNER_SYM
668 %token INNOBASE_SYM
669+%token INNODB_IO_PATTERN
670 %token INOUT_SYM
671 %token INSENSITIVE_SYM
672 %token INSERT
673@@ -8541,6 +8542,7 @@
674 | MASTER_SYM { Lex->type|= REFRESH_MASTER; }
675 | DES_KEY_FILE { Lex->type|= REFRESH_DES_KEY_FILE; }
676 | RESOURCES { Lex->type|= REFRESH_USER_RESOURCES; }
677+ | INNODB_IO_PATTERN { Lex->type|= REFRESH_INNODB_IO_PATTERN; }
678 | CLIENT_STATS_SYM { Lex->type|= REFRESH_CLIENT_STATS; }
679 | USER_STATS_SYM { Lex->type|= REFRESH_USER_STATS; }
680 | TABLE_STATS_SYM { Lex->type|= REFRESH_TABLE_STATS; }
681@@ -9594,6 +9596,7 @@
682 | ISOLATION {}
683 | ISSUER_SYM {}
684 | INNOBASE_SYM {}
685+ | INNODB_IO_PATTERN {}
686 | INSERT_METHOD {}
687 | IO_SYM {}
688 | IPC_SYM {}
This page took 0.120511 seconds and 4 git commands to generate.