Commit 58c3e32d authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Simplify thd_wait_begin. given how seldom they are called, calling current_thd...

Simplify thd_wait_begin. given how seldom they are called, calling current_thd one more time  is not going to be anything performance relevant.

Also use thd_wait_begin/end for thr_lock and sync callbacks.
parent 2a5d8ea9
...@@ -46,28 +46,20 @@ static bool no_threads_end(THD *thd, bool put_in_cache) ...@@ -46,28 +46,20 @@ static bool no_threads_end(THD *thd, bool put_in_cache)
/**@{*/ /**@{*/
extern "C" extern "C"
{ {
static void scheduler_wait_lock_begin(void) { static void scheduler_wait_lock_begin(void) {
THD *thd=current_thd; thd_wait_begin(NULL, THD_WAIT_TABLE_LOCK);
if(thd)
MYSQL_CALLBACK(thd->scheduler, thd_wait_begin, (thd, THD_WAIT_TABLE_LOCK));
} }
static void scheduler_wait_lock_end(void) { static void scheduler_wait_lock_end(void) {
THD *thd=current_thd; thd_wait_end(NULL);
if(thd)
MYSQL_CALLBACK(thd->scheduler, thd_wait_end, (thd));
} }
static void scheduler_wait_sync_begin(void) { static void scheduler_wait_sync_begin(void) {
THD *thd=current_thd; thd_wait_begin(NULL, THD_WAIT_SYNC);
if(thd)
MYSQL_CALLBACK(thd->scheduler, thd_wait_begin, (thd, THD_WAIT_TABLE_LOCK));
} }
static void scheduler_wait_sync_end(void) { static void scheduler_wait_sync_end(void) {
THD *thd=current_thd; thd_wait_end(NULL);
if(thd)
MYSQL_CALLBACK(thd->scheduler, thd_wait_end, (thd));
} }
}; };
/**@}*/ /**@}*/
......
...@@ -3935,13 +3935,10 @@ extern "C" bool thd_sqlcom_can_generate_row_events(const MYSQL_THD thd) ...@@ -3935,13 +3935,10 @@ extern "C" bool thd_sqlcom_can_generate_row_events(const MYSQL_THD thd)
*/ */
extern "C" void thd_wait_begin(MYSQL_THD thd, int wait_type) extern "C" void thd_wait_begin(MYSQL_THD thd, int wait_type)
{ {
if (!thd)
if (unlikely(!thread_scheduler) || !thread_scheduler->thd_wait_begin)
return;
if (thd == NULL)
{ {
thd=current_thd; thd= current_thd;
if(unlikely(thd == NULL)) if (unlikely(!thd))
return; return;
} }
MYSQL_CALLBACK(thd->scheduler, thd_wait_begin, (thd, wait_type)); MYSQL_CALLBACK(thd->scheduler, thd_wait_begin, (thd, wait_type));
...@@ -3956,16 +3953,13 @@ extern "C" void thd_wait_begin(MYSQL_THD thd, int wait_type) ...@@ -3956,16 +3953,13 @@ extern "C" void thd_wait_begin(MYSQL_THD thd, int wait_type)
*/ */
extern "C" void thd_wait_end(MYSQL_THD thd) extern "C" void thd_wait_end(MYSQL_THD thd)
{ {
if (unlikely(!thread_scheduler) || ! thread_scheduler->thd_wait_begin) if (!thd)
return;
if (thd == NULL)
{ {
thd=current_thd; thd= current_thd;
if(unlikely(thd == NULL)) if (unlikely(!thd))
return; return;
} }
if(likely(thd->scheduler == thread_scheduler)) MYSQL_CALLBACK(thd->scheduler, thd_wait_end, (thd));
thread_scheduler->thd_wait_end(thd);
} }
#endif // INNODB_COMPATIBILITY_HOOKS */ #endif // INNODB_COMPATIBILITY_HOOKS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment