mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-12345 Performance : replace calls to clock() inside trx_start_low() by THD::start_utime
This commit is contained in:
@@ -4534,6 +4534,15 @@ extern "C" int thd_rpl_is_parallel(const MYSQL_THD thd)
|
|||||||
return thd->rgi_slave && thd->rgi_slave->is_parallel_exec;
|
return thd->rgi_slave && thd->rgi_slave->is_parallel_exec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Returns high resolution timestamp for the start
|
||||||
|
of the current query. */
|
||||||
|
extern "C" unsigned long long thd_start_utime(const MYSQL_THD thd)
|
||||||
|
{
|
||||||
|
return thd->start_utime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This function can optionally be called to check if thd_report_wait_for()
|
This function can optionally be called to check if thd_report_wait_for()
|
||||||
needs to be called for waits done by a given transaction.
|
needs to be called for waits done by a given transaction.
|
||||||
|
@@ -1705,6 +1705,15 @@ thd_has_edited_nontrans_tables(
|
|||||||
return((ibool) thd_non_transactional_update(thd));
|
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.
|
Returns true if the thread is executing a SELECT statement.
|
||||||
@return true if thd is executing SELECT */
|
@return true if thd is executing SELECT */
|
||||||
|
@@ -420,6 +420,15 @@ int thd_slave_thread(const MYSQL_THD thd);
|
|||||||
*/
|
*/
|
||||||
int thd_non_transactional_update(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
|
Get the user thread's binary logging format
|
||||||
@param thd user thread
|
@param thd user thread
|
||||||
|
@@ -150,6 +150,13 @@ thd_has_edited_nontrans_tables(
|
|||||||
/*===========================*/
|
/*===========================*/
|
||||||
THD* thd); /*!< in: thread handle */
|
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. */
|
Prints info of a THD object (== user session thread) to the given file. */
|
||||||
UNIV_INTERN
|
UNIV_INTERN
|
||||||
|
@@ -849,7 +849,7 @@ struct trx_t{
|
|||||||
|
|
||||||
time_t start_time; /*!< time the trx state last time became
|
time_t start_time; /*!< time the trx state last time became
|
||||||
TRX_STATE_ACTIVE */
|
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 */
|
microseconds */
|
||||||
trx_id_t id; /*!< transaction id */
|
trx_id_t id; /*!< transaction id */
|
||||||
XID xid; /*!< X/Open XA transaction
|
XID xid; /*!< X/Open XA transaction
|
||||||
|
@@ -923,7 +923,8 @@ trx_start_low(
|
|||||||
|
|
||||||
trx->start_time = ut_time();
|
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);
|
MONITOR_INC(MONITOR_TRX_ACTIVE);
|
||||||
}
|
}
|
||||||
|
@@ -1981,6 +1981,15 @@ thd_has_edited_nontrans_tables(
|
|||||||
return((ibool) thd_non_transactional_update(thd));
|
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.
|
Returns true if the thread is executing a SELECT statement.
|
||||||
@return true if thd is executing SELECT */
|
@return true if thd is executing SELECT */
|
||||||
|
@@ -427,6 +427,15 @@ int thd_slave_thread(const MYSQL_THD thd);
|
|||||||
*/
|
*/
|
||||||
int thd_non_transactional_update(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
|
Get the user thread's binary logging format
|
||||||
@param thd user thread
|
@param thd user thread
|
||||||
|
@@ -157,6 +157,13 @@ thd_has_edited_nontrans_tables(
|
|||||||
/*===========================*/
|
/*===========================*/
|
||||||
THD* thd); /*!< in: thread handle */
|
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. */
|
Prints info of a THD object (== user session thread) to the given file. */
|
||||||
UNIV_INTERN
|
UNIV_INTERN
|
||||||
|
@@ -882,7 +882,7 @@ struct trx_t{
|
|||||||
|
|
||||||
time_t start_time; /*!< time the trx state last time became
|
time_t start_time; /*!< time the trx state last time became
|
||||||
TRX_STATE_ACTIVE */
|
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 */
|
microseconds */
|
||||||
trx_id_t id; /*!< transaction id */
|
trx_id_t id; /*!< transaction id */
|
||||||
XID xid; /*!< X/Open XA transaction
|
XID xid; /*!< X/Open XA transaction
|
||||||
|
@@ -1121,7 +1121,8 @@ trx_start_low(
|
|||||||
|
|
||||||
trx->start_time = ut_time();
|
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);
|
MONITOR_INC(MONITOR_TRX_ACTIVE);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user