diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2017-03-23 11:48:56 +0000 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2017-03-23 11:50:22 +0000 |
commit | e5b67a46bcb75a751f5906f19694971bc803d67c (patch) | |
tree | eedc485ef1f5dec061c315b6ffe54a76e496f003 /storage | |
parent | 09a2107b1b2f5567b8a50afec9e54a33284c6233 (diff) | |
download | mariadb-git-e5b67a46bcb75a751f5906f19694971bc803d67c.tar.gz |
MDEV-12345 Performance : replace calls to clock() inside trx_start_low() by THD::start_utime
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 9 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.h | 9 | ||||
-rw-r--r-- | storage/innobase/include/ha_prototypes.h | 7 | ||||
-rw-r--r-- | storage/innobase/include/trx0trx.h | 2 | ||||
-rw-r--r-- | storage/innobase/trx/trx0trx.cc | 3 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.cc | 9 | ||||
-rw-r--r-- | storage/xtradb/handler/ha_innodb.h | 9 | ||||
-rw-r--r-- | storage/xtradb/include/ha_prototypes.h | 7 | ||||
-rw-r--r-- | storage/xtradb/include/trx0trx.h | 2 | ||||
-rw-r--r-- | storage/xtradb/trx/trx0trx.cc | 3 |
10 files changed, 56 insertions, 4 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index c9d78d68092..17c0b45cffe 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1705,6 +1705,15 @@ thd_has_edited_nontrans_tables( return((ibool) thd_non_transactional_update(thd)); } +/* Return high resolution timestamp for the start of the current query */ +UNIV_INTERN +ib_uint64_t +thd_query_start_micro( + const THD* thd) /*!< in: thread handle */ +{ + return thd_start_utime(thd); +} + /******************************************************************//** Returns true if the thread is executing a SELECT statement. @return true if thd is executing SELECT */ diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 478187e0b23..90dfb6102b3 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -421,6 +421,15 @@ int thd_slave_thread(const MYSQL_THD thd); int thd_non_transactional_update(const MYSQL_THD thd); /** + Get high resolution timestamp for the current query start time. + The timestamp is not anchored to any specific point in time, + but can be used for comparison. + + @retval timestamp in microseconds precision +*/ +unsigned long long thd_start_utime(const MYSQL_THD thd); + +/** Get the user thread's binary logging format @param thd user thread @return Value to be used as index into the binlog_format_names array diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index 12453099ef7..2a8f133cb3a 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -150,6 +150,13 @@ thd_has_edited_nontrans_tables( /*===========================*/ THD* thd); /*!< in: thread handle */ +/** +Get high resolution timestamp for the current query start time. + +@retval timestamp in microseconds precision +*/ +unsigned long long thd_query_start_micro(const MYSQL_THD thd); + /*************************************************************//** Prints info of a THD object (== user session thread) to the given file. */ UNIV_INTERN diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 11836183d57..5936fa90e84 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -849,7 +849,7 @@ struct trx_t{ time_t start_time; /*!< time the trx state last time became TRX_STATE_ACTIVE */ - clock_t start_time_micro; /*!< start time of transaction in + ib_uint64_t start_time_micro; /*!< start time of transaction in microseconds */ trx_id_t id; /*!< transaction id */ XID xid; /*!< X/Open XA transaction diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index 301ef17197e..318f1e284ec 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -923,7 +923,8 @@ trx_start_low( trx->start_time = ut_time(); - trx->start_time_micro = clock(); + trx->start_time_micro = + trx->mysql_thd ? thd_query_start_micro(trx->mysql_thd) : 0; MONITOR_INC(MONITOR_TRX_ACTIVE); } diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 4ca4259273f..edc0f3d90f4 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -1981,6 +1981,15 @@ thd_has_edited_nontrans_tables( return((ibool) thd_non_transactional_update(thd)); } +/* Return high resolution timestamp for the start of the current query */ +UNIV_INTERN +ib_uint64_t +thd_query_start_micro( + const THD* thd) /*!< in: thread handle */ +{ + return thd_start_utime(thd); +} + /******************************************************************//** Returns true if the thread is executing a SELECT statement. @return true if thd is executing SELECT */ diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index f91c0fb4703..62b80c492a1 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -428,6 +428,15 @@ int thd_slave_thread(const MYSQL_THD thd); int thd_non_transactional_update(const MYSQL_THD thd); /** + Get high resolution timestamp for the current query start time. + The timestamp is not anchored to any specific point in time, + but can be used for comparison. + + @retval timestamp in microseconds precision +*/ +unsigned long long thd_start_utime(const MYSQL_THD thd); + +/** Get the user thread's binary logging format @param thd user thread @return Value to be used as index into the binlog_format_names array diff --git a/storage/xtradb/include/ha_prototypes.h b/storage/xtradb/include/ha_prototypes.h index dbb23d81eec..69d4d9c175c 100644 --- a/storage/xtradb/include/ha_prototypes.h +++ b/storage/xtradb/include/ha_prototypes.h @@ -157,6 +157,13 @@ thd_has_edited_nontrans_tables( /*===========================*/ THD* thd); /*!< in: thread handle */ +/** +Get high resolution timestamp for the current query start time. + +@retval timestamp in microseconds precision +*/ +unsigned long long thd_query_start_micro(const MYSQL_THD thd); + /*************************************************************//** Prints info of a THD object (== user session thread) to the given file. */ UNIV_INTERN diff --git a/storage/xtradb/include/trx0trx.h b/storage/xtradb/include/trx0trx.h index fc710a86d74..9e2064c3dc2 100644 --- a/storage/xtradb/include/trx0trx.h +++ b/storage/xtradb/include/trx0trx.h @@ -882,7 +882,7 @@ struct trx_t{ time_t start_time; /*!< time the trx state last time became TRX_STATE_ACTIVE */ - clock_t start_time_micro; /*!< start time of transaction in + ib_uint64_t start_time_micro; /*!< start time of transaction in microseconds */ trx_id_t id; /*!< transaction id */ XID xid; /*!< X/Open XA transaction diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc index 73c1172ff0f..439897a5b96 100644 --- a/storage/xtradb/trx/trx0trx.cc +++ b/storage/xtradb/trx/trx0trx.cc @@ -1121,7 +1121,8 @@ trx_start_low( trx->start_time = ut_time(); - trx->start_time_micro = clock(); + trx->start_time_micro = + trx->mysql_thd ? thd_query_start_micro(trx->mysql_thd) : 0; MONITOR_INC(MONITOR_TRX_ACTIVE); } |