3431 Marc Alff 2011-11-04
Prototyping, table io improvements
modified:
include/mysql/psi/mysql_table.h
include/mysql/psi/psi.h
sql/handler.cc
storage/perfschema/unittest/pfs_benchmark-t.cc
3430 Marc Alff 2011-11-03
fast reset for table stats
modified:
storage/perfschema/pfs_instr.cc
storage/perfschema/pfs_instr_class.cc
storage/perfschema/pfs_server.cc
storage/perfschema/pfs_stat.h
=== modified file 'include/mysql/psi/mysql_table.h'
--- a/include/mysql/psi/mysql_table.h 2011-09-26 23:52:40 +0000
+++ b/include/mysql/psi/mysql_table.h 2011-11-04 14:19:54 +0000
@@ -50,11 +50,9 @@
#endif
/**
- @def MYSQL_START_TABLE_IO_WAIT
+ @def MYSQL_TABLE_IO_WAIT
Instrumentation helper for table io_waits.
This instrumentation marks the start of a wait event.
- @param LOCKER the locker
- @param STATE the locker state
@param PSI the instrumented table
@param OP the table operation to be performed
@param INDEX the table index used if any, or MAY_KEY.
@@ -62,55 +60,59 @@
@sa MYSQL_END_TABLE_WAIT.
*/
#ifdef HAVE_PSI_TABLE_INTERFACE
- #define MYSQL_START_TABLE_IO_WAIT(LOCKER, STATE, PSI, OP, INDEX, FLAGS) \
- LOCKER= inline_mysql_start_table_io_wait(STATE, PSI, \
- OP, INDEX, __FILE__, __LINE__)
+ #define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
+ { \
+ if (PSI != NULL) \
+ { \
+ PSI_table_locker *locker; \
+ PSI_table_locker_state state; \
+ locker= PSI_CALL(start_table_io_wait)(& state, PSI, OP, INDEX, \
+ __FILE__, __LINE__); \
+ PAYLOAD \
+ if (locker != NULL) \
+ PSI_CALL(end_table_io_wait)(locker); \
+ } \
+ else \
+ { \
+ PAYLOAD \
+ } \
+ }
#else
- #define MYSQL_START_TABLE_IO_WAIT(LOCKER, STATE, PSI, OP, INDEX, FLAGS) \
- do {} while (0)
+ #define MYSQL_TABLE_IO_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
+ PAYLOAD
#endif
/**
- @def MYSQL_END_TABLE_IO_WAIT
- Instrumentation helper for table io waits.
- This instrumentation marks the end of a wait event.
- @param LOCKER the locker
- @sa MYSQL_START_TABLE_IO_WAIT.
+ @def MYSQL_TABLE_LOCK_WAIT
+ Instrumentation helper for table io_waits.
+ This instrumentation marks the start of a wait event.
+ @param PSI the instrumented table
+ @param OP the table operation to be performed
+ @param INDEX the table index used if any, or MAY_KEY.
+ @param FLAGS per table operation flags.
+ @sa MYSQL_END_TABLE_WAIT.
*/
#ifdef HAVE_PSI_TABLE_INTERFACE
- #define MYSQL_END_TABLE_IO_WAIT(LOCKER) \
- inline_mysql_end_table_io_wait(LOCKER)
+ #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, FLAGS, PAYLOAD) \
+ { \
+ if (PSI != NULL) \
+ { \
+ PSI_table_locker *locker; \
+ PSI_table_locker_state state; \
+ locker= PSI_CALL(start_table_lock_wait)(& state, PSI, OP, FLAGS, \
+ __FILE__, __LINE__); \
+ PAYLOAD \
+ if (locker != NULL) \
+ PSI_CALL(end_table_lock_wait)(locker); \
+ } \
+ else \
+ { \
+ PAYLOAD \
+ } \
+ }
#else
- #define MYSQL_END_TABLE_IO_WAIT(LOCKER) \
- do {} while (0)
-#endif
-
-#ifdef HAVE_PSI_TABLE_INTERFACE
-/**
- Instrumentation calls for MYSQL_START_TABLE_IO_WAIT.
- @sa MYSQL_END_TABLE_IO_WAIT.
-*/
-static inline struct PSI_table_locker *
-inline_mysql_start_table_io_wait(PSI_table_locker_state *state,
- struct PSI_table *psi,
- enum PSI_table_io_operation op,
- uint index,
- const char *src_file, int src_line)
-{
- struct PSI_table_locker *locker;
- locker= PSI_CALL(start_table_io_wait)(state, psi, op, index, src_file, src_line);
- return locker;
-}
-
-/**
- Instrumentation calls for MYSQL_END_TABLE_IO_WAIT.
- @sa MYSQL_START_TABLE_IO_WAIT.
-*/
-static inline void
-inline_mysql_end_table_io_wait(struct PSI_table_locker *locker)
-{
- PSI_CALL(end_table_io_wait)(locker);
-}
+ #define MYSQL_TABLE_LOCK_WAIT(PSI, OP, INDEX, FLAGS, PAYLOAD) \
+ PAYLOAD
#endif
/**
@@ -159,9 +161,13 @@ inline_mysql_start_table_lock_wait(PSI_t
enum PSI_table_lock_operation op,
ulong flags, const char *src_file, int src_line)
{
- struct PSI_table_locker *locker;
- locker= PSI_CALL(start_table_lock_wait)(state, psi, op, flags, src_file, src_line);
- return locker;
+ if (psi != NULL)
+ {
+ struct PSI_table_locker *locker;
+ locker= PSI_CALL(start_table_lock_wait)(state, psi, op, flags, src_file, src_line);
+ return locker;
+ }
+ return NULL;
}
/**
@@ -171,7 +177,8 @@ inline_mysql_start_table_lock_wait(PSI_t
static inline void
inline_mysql_end_table_lock_wait(struct PSI_table_locker *locker)
{
- PSI_CALL(end_table_lock_wait)(locker);
+ if (locker != NULL)
+ PSI_CALL(end_table_lock_wait)(locker);
}
#endif
=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h 2011-11-02 23:56:22 +0000
+++ b/include/mysql/psi/psi.h 2011-11-04 14:19:54 +0000
@@ -16,6 +16,10 @@
#ifndef MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
#define MYSQL_PERFORMANCE_SCHEMA_INTERFACE_H
+/* temporary, Investigate build failures on embedded */
+#define DISABLE_PSI_STATEMENT
+#define DISABLE_PSI_IDLE
+
#ifndef _global_h
/*
Make sure a .c or .cc file contains an include to my_global.h first.
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2011-10-21 14:59:52 +0000
+++ b/sql/handler.cc 2011-11-04 14:19:54 +0000
@@ -2276,12 +2276,9 @@ int handler::ha_rnd_next(uchar *buf)
int result;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, MAX_KEY, 0);
- result= rnd_next(buf);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, MAX_KEY, 0,
+ { result= rnd_next(buf); })
return result;
}
@@ -2290,12 +2287,9 @@ int handler::ha_rnd_pos(uchar *buf, ucha
int result;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, MAX_KEY, 0);
- result= rnd_pos(buf, pos);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, MAX_KEY, 0,
+ { result= rnd_pos(buf, pos); })
return result;
}
@@ -2306,12 +2300,9 @@ int handler::ha_index_read_map(uchar *bu
int result;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, active_index, 0);
- result= index_read_map(buf, key, keypart_map, find_flag);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0,
+ { result= index_read_map(buf, key, keypart_map, find_flag); })
return result;
}
@@ -2323,12 +2314,9 @@ int handler::ha_index_read_idx_map(uchar
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
DBUG_ASSERT(end_range == NULL);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, index, 0);
- result= index_read_idx_map(buf, index, key, keypart_map, find_flag);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, index, 0,
+ { result= index_read_idx_map(buf, index, key, keypart_map, find_flag); })
return result;
}
@@ -2337,12 +2325,9 @@ int handler::ha_index_next(uchar * buf)
int result;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, active_index, 0);
- result= index_next(buf);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0,
+ { result= index_next(buf); })
return result;
}
@@ -2351,12 +2336,9 @@ int handler::ha_index_prev(uchar * buf)
int result;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, active_index, 0);
- result= index_prev(buf);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0,
+ { result= index_prev(buf); })
return result;
}
@@ -2365,12 +2347,9 @@ int handler::ha_index_first(uchar * buf)
int result;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, active_index, 0);
- result= index_first(buf);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0,
+ { result= index_first(buf); })
return result;
}
@@ -2379,12 +2358,9 @@ int handler::ha_index_last(uchar * buf)
int result;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, active_index, 0);
- result= index_last(buf);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0,
+ { result= index_last(buf); })
return result;
}
@@ -2393,12 +2369,9 @@ int handler::ha_index_next_same(uchar *b
int result;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, active_index, 0);
- result= index_next_same(buf, key, keylen);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0,
+ { result= index_next_same(buf, key, keylen); })
return result;
}
@@ -2408,12 +2381,9 @@ int handler::ha_index_read(uchar *buf, c
int result;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, active_index, 0);
- result= index_read(buf, key, key_len, find_flag);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0,
+ { result= index_read(buf, key, key_len, find_flag); })
return result;
}
@@ -2422,12 +2392,9 @@ int handler::ha_index_read_last(uchar *b
int result;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type != F_UNLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_FETCH_ROW, active_index, 0);
- result= index_read_last(buf, key, key_len);
- MYSQL_END_TABLE_IO_WAIT(locker);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0,
+ { result= index_read_last(buf, key, key_len); })
return result;
}
@@ -5916,8 +5883,7 @@ static int binlog_log_row(TABLE* table,
int handler::ha_external_lock(THD *thd, int lock_type)
{
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
-
+ int error;
DBUG_ENTER("handler::ha_external_lock");
/*
Whether this is lock or unlock, this should be true, and is to verify that
@@ -5953,16 +5919,14 @@ int handler::ha_external_lock(THD *thd,
}
ha_statistic_increment(&SSV::ha_external_lock_count);
- MYSQL_START_TABLE_LOCK_WAIT(locker, &state, m_psi,
- PSI_TABLE_EXTERNAL_LOCK, lock_type);
+
+ MYSQL_TABLE_LOCK_WAIT(m_psi, PSI_TABLE_EXTERNAL_LOCK, lock_type,
+ { error= external_lock(thd, lock_type); })
/*
We cache the table flags if the locking succeeded. Otherwise, we
keep them as they were when they were fetched in ha_open().
*/
- int error= external_lock(thd, lock_type);
-
- MYSQL_END_TABLE_LOCK_WAIT(locker);
if (error == 0)
{
@@ -6032,18 +5996,15 @@ int handler::ha_write_row(uchar *buf)
Log_func *log_func= Write_rows_log_event::binlog_row_logging_function;
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type == F_WRLCK);
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
DBUG_ENTER("handler::ha_write_row");
MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write();
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_WRITE_ROW, MAX_KEY, 0);
- error= write_row(buf);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_WRITE_ROW, MAX_KEY, 0,
+ { error= write_row(buf); })
- MYSQL_END_TABLE_IO_WAIT(locker);
MYSQL_INSERT_ROW_DONE(error);
if (unlikely(error))
DBUG_RETURN(error);
@@ -6060,7 +6021,6 @@ int handler::ha_update_row(const uchar *
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type == F_WRLCK);
Log_func *log_func= Update_rows_log_event::binlog_row_logging_function;
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
/*
Some storage engines require that the new record is in record[0]
@@ -6071,12 +6031,9 @@ int handler::ha_update_row(const uchar *
MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write();
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_UPDATE_ROW, active_index, 0);
-
- error= update_row(old_data, new_data);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_UPDATE_ROW, active_index, 0,
+ { error= update_row(old_data, new_data);})
- MYSQL_END_TABLE_IO_WAIT(locker);
MYSQL_UPDATE_ROW_DONE(error);
if (unlikely(error))
return error;
@@ -6091,17 +6048,13 @@ int handler::ha_delete_row(const uchar *
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
m_lock_type == F_WRLCK);
Log_func *log_func= Delete_rows_log_event::binlog_row_logging_function;
- MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
MYSQL_DELETE_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write();
- MYSQL_START_TABLE_IO_WAIT(locker, &state, m_psi,
- PSI_TABLE_DELETE_ROW, active_index, 0);
-
- error= delete_row(buf);
+ MYSQL_TABLE_IO_WAIT(m_psi, PSI_TABLE_DELETE_ROW, active_index, 0,
+ { error= delete_row(buf);})
- MYSQL_END_TABLE_IO_WAIT(locker);
MYSQL_DELETE_ROW_DONE(error);
if (unlikely(error))
return error;
=== modified file 'storage/perfschema/unittest/pfs_benchmark-t.cc'
--- a/storage/perfschema/unittest/pfs_benchmark-t.cc 2011-11-04 01:19:58 +0000
+++ b/storage/perfschema/unittest/pfs_benchmark-t.cc 2011-11-04 14:19:54 +0000
@@ -521,11 +521,16 @@ void benchmark_table_io(uint count, cons
start_some_work();
for (i= 0 ; i<count; i++)
{
+#if defined MYSQL_TABLE_IO_WAIT
+ MYSQL_TABLE_IO_WAIT(that, PSI_TABLE_FETCH_ROW, MAX_KEY, 0,
+ { do_some_work(); })
+#else
MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
MYSQL_START_TABLE_IO_WAIT(locker, &state, that,
PSI_TABLE_FETCH_ROW, MAX_KEY, 0);
do_some_work();
MYSQL_END_TABLE_IO_WAIT(locker);
+#endif
}
timer_end= my_timer_cycles();
@@ -561,11 +566,16 @@ void benchmark_table_lock(uint count, co
start_some_work();
for (i= 0 ; i<count; i++)
{
+#if defined MYSQL_TABLE_LOCK_WAIT
+ MYSQL_TABLE_LOCK_WAIT(that, PSI_TABLE_EXTERNAL_LOCK, F_RDLCK,
+ { do_some_work(); })
+#else
MYSQL_TABLE_WAIT_VARIABLES(locker, state) /* no ';' */
MYSQL_START_TABLE_LOCK_WAIT(locker, &state, that,
PSI_TABLE_EXTERNAL_LOCK, F_RDLCK);
do_some_work();
MYSQL_END_TABLE_LOCK_WAIT(locker);
+#endif
}
timer_end= my_timer_cycles();
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (marc.alff:3430 to 3431) | Marc Alff | 7 Nov |