Skip to content

Commit 548ed17

Browse files
committed
Bug#17310878 PFS OVERHEAD ON FREQUENT CONNECT/DISCONNECT
This fix is for MySQL 5.7 This fix is a performance improvement. The issue was that the call to PSI_THREAD_CALL(delete_current_thread)(), which is executed each time a thread disconnects, was placed inside a critical section involving LOCK_thread_count. The fix is to perform the same call sooner, before entering the LOCK_thread_count critical section. Serializing all calls to pfs_delete_current_thread_v1() was the major cause of performance overhead, for frequent connect/disconnect.
1 parent a9b5dc5 commit 548ed17

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

sql/conn_handler/connection_handler_per_thread.cc

+7-8
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,6 @@ Channel_info* Per_thread_connection_handler::block_until_new_connection()
7474
DBUG_POP();
7575
DBUG_ASSERT( ! _db_is_pushed_());
7676

77-
#ifdef HAVE_PSI_THREAD_INTERFACE
78-
/*
79-
Delete the instrumentation for the job that just completed,
80-
before blocking this pthread (blocked on COND_thread_cache).
81-
*/
82-
PSI_THREAD_CALL(delete_current_thread)();
83-
#endif
84-
8577
// Block pthread
8678
blocked_pthread_count++;
8779
while (!abort_loop && !wake_pthread && !kill_blocked_pthreads_flag)
@@ -236,6 +228,13 @@ pthread_handler_t handle_connection(void *arg)
236228
remove_global_thread(thd);
237229
delete thd;
238230

231+
#ifdef HAVE_PSI_THREAD_INTERFACE
232+
/*
233+
Delete the instrumentation for the job that just completed.
234+
*/
235+
PSI_THREAD_CALL(delete_current_thread)();
236+
#endif
237+
239238
if (abort_loop) // Server is shutting down so end the pthread.
240239
break;
241240

0 commit comments

Comments
 (0)