[Commits] Rev 3503: MDEV-156 Threadpool - add thd_wait_begin/thd_wait_end to the network IO functions in file:///H:/bzr/10.0/

Vladislav Vaintroub wlad at montyprogram.com
Tue Feb 19 21:45:03 EET 2013


At file:///H:/bzr/10.0/

------------------------------------------------------------
revno: 3503
revision-id: wlad at montyprogram.com-20130219194433-n0p9yx9hmqbcuh77
parent: monty at askmonty.org-20130215121809-7xb0akrtj71d0pw6
fixes bug: https://mariadb.atlassian.net/browse/MDEV-156
committer: Vladislav Vaintroub <wlad at montyprogram.com>
branch nick: 10.0
timestamp: Tue 2013-02-19 20:44:33 +0100
message:
  MDEV-156 Threadpool - add thd_wait_begin/thd_wait_end to the network IO functions
-------------- next part --------------
=== modified file 'include/mysql/plugin_audit.h.pp'
--- a/include/mysql/plugin_audit.h.pp	2013-01-29 14:10:47 +0000
+++ b/include/mysql/plugin_audit.h.pp	2013-02-19 19:44:33 +0000
@@ -43,7 +43,8 @@ typedef enum _thd_wait_type_e {
   THD_WAIT_BINLOG= 8,
   THD_WAIT_GROUP_COMMIT= 9,
   THD_WAIT_SYNC= 10,
-  THD_WAIT_LAST= 11
+  THD_WAIT_NET= 11,
+  THD_WAIT_LAST= 12
 } thd_wait_type;
 extern struct thd_wait_service_st {
   void (*thd_wait_begin_func)(void*, int);

=== modified file 'include/mysql/plugin_auth.h.pp'
--- a/include/mysql/plugin_auth.h.pp	2013-01-29 14:10:47 +0000
+++ b/include/mysql/plugin_auth.h.pp	2013-02-19 19:44:33 +0000
@@ -43,7 +43,8 @@ typedef enum _thd_wait_type_e {
   THD_WAIT_BINLOG= 8,
   THD_WAIT_GROUP_COMMIT= 9,
   THD_WAIT_SYNC= 10,
-  THD_WAIT_LAST= 11
+  THD_WAIT_NET= 11,
+  THD_WAIT_LAST= 12
 } thd_wait_type;
 extern struct thd_wait_service_st {
   void (*thd_wait_begin_func)(void*, int);

=== modified file 'include/mysql/plugin_ftparser.h.pp'
--- a/include/mysql/plugin_ftparser.h.pp	2013-01-29 14:10:47 +0000
+++ b/include/mysql/plugin_ftparser.h.pp	2013-02-19 19:44:33 +0000
@@ -43,7 +43,8 @@ typedef enum _thd_wait_type_e {
   THD_WAIT_BINLOG= 8,
   THD_WAIT_GROUP_COMMIT= 9,
   THD_WAIT_SYNC= 10,
-  THD_WAIT_LAST= 11
+  THD_WAIT_NET= 11,
+  THD_WAIT_LAST= 12
 } thd_wait_type;
 extern struct thd_wait_service_st {
   void (*thd_wait_begin_func)(void*, int);

=== modified file 'include/mysql/service_thd_wait.h'
--- a/include/mysql/service_thd_wait.h	2011-06-30 15:46:53 +0000
+++ b/include/mysql/service_thd_wait.h	2013-02-19 19:44:33 +0000
@@ -74,7 +74,8 @@ typedef enum _thd_wait_type_e {
   THD_WAIT_BINLOG= 8,
   THD_WAIT_GROUP_COMMIT= 9,
   THD_WAIT_SYNC= 10,
-  THD_WAIT_LAST= 11
+  THD_WAIT_NET= 11,
+  THD_WAIT_LAST= 12
 } thd_wait_type;
 
 extern struct thd_wait_service_st {

=== modified file 'include/violite.h'
--- a/include/violite.h	2012-11-04 20:04:04 +0000
+++ b/include/violite.h	2013-02-19 19:44:33 +0000
@@ -105,7 +105,9 @@ my_bool vio_is_connected(Vio *vio);
 ssize_t vio_pending(Vio *vio);
 #endif
 /* Set timeout for a network operation. */
-int vio_timeout(Vio *vio, uint which, int timeout_sec);
+extern int vio_timeout(Vio *vio, uint which, int timeout_sec);
+extern void vio_set_wait_callback(void (*before_wait)(void),
+                                void (*after_wait)(void));
 /* Connect to a peer. */
 my_bool vio_socket_connect(Vio *vio, struct sockaddr *addr, socklen_t len,
                            int timeout);

=== modified file 'sql/scheduler.cc'
--- a/sql/scheduler.cc	2012-12-20 23:12:37 +0000
+++ b/sql/scheduler.cc	2013-02-19 19:44:33 +0000
@@ -27,6 +27,7 @@
 #include "mysqld.h"
 #include "sql_class.h"
 #include "sql_callback.h"
+#include <violite.h>
 
 /*
   End connection, in case when we are using 'no-threads'
@@ -61,6 +62,15 @@ static void scheduler_wait_sync_begin(vo
 static void scheduler_wait_sync_end(void) {
   thd_wait_end(NULL);
 }
+
+static void scheduler_wait_net_begin(void) {
+   thd_wait_begin(NULL, THD_WAIT_NET);
+}
+
+static void scheduler_wait_net_end(void) {
+   thd_wait_end(NULL);
+}
+
 };
 /**@}*/
 
@@ -76,6 +86,9 @@ void scheduler_init() {
                              scheduler_wait_lock_end);
   thr_set_sync_wait_callback(scheduler_wait_sync_begin,
                              scheduler_wait_sync_end);
+
+  vio_set_wait_callback(scheduler_wait_net_begin,
+    scheduler_wait_net_end);
 }
 
 

=== modified file 'vio/viosocket.c'
--- a/vio/viosocket.c	2012-10-12 09:00:01 +0000
+++ b/vio/viosocket.c	2013-02-19 19:44:33 +0000
@@ -37,6 +37,38 @@
 # include <sys/filio.h>
 #endif
 
+/* Network io wait callbacks  for threadpool */
+static void (*before_io_wait)(void)= 0;
+static void (*after_io_wait)(void)= 0;
+
+/* Wait callback macros (both performance schema and threadpool */
+#define START_SOCKET_WAIT(locker, state_ptr, sock, which) \
+do                                                        \
+{                                                         \
+  MYSQL_START_SOCKET_WAIT(locker, state_ptr, sock,        \
+                            which, 0);                    \
+  if (before_io_wait)                                     \
+    before_io_wait();                                     \
+} while(0)
+
+
+#define END_SOCKET_WAIT(locker)                          \
+do                                                       \
+{                                                        \
+  MYSQL_END_SOCKET_WAIT(locker, 0);                      \
+  if (after_io_wait)                                     \
+    after_io_wait();                                     \
+} while(0)
+
+
+
+void vio_set_wait_callback(void (*before_wait)(void),
+                                void (*after_wait)(void))
+{
+  before_io_wait= before_wait;
+  after_io_wait= after_wait;
+}
+
 int vio_errno(Vio *vio __attribute__((unused)))
 {
   /* These transport types are not Winsock based. */
@@ -903,12 +935,12 @@ int vio_io_wait(Vio *vio, enum enum_vio_
   */
   if (timeout != 0 && vio->async_context && vio->async_context->active)
   {
-    MYSQL_START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
-                            PSI_SOCKET_SELECT, 0);
+    START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
+                            PSI_SOCKET_SELECT);
     ret= my_io_wait_async(vio->async_context, event, timeout);
     if (ret == 0)
       errno= SOCKET_ETIMEDOUT;
-    MYSQL_END_SOCKET_WAIT(locker, 0);
+    END_SOCKET_WAIT(locker);
     DBUG_RETURN(ret);
   }
 
@@ -933,8 +965,7 @@ int vio_io_wait(Vio *vio, enum enum_vio_
     break;
   }
 
-  MYSQL_START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT, 0);
-
+  START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT);
   /*
     Wait for the I/O event and return early in case of
     error or timeout.
@@ -957,7 +988,7 @@ int vio_io_wait(Vio *vio, enum enum_vio_
     break;
   }
 
-  MYSQL_END_SOCKET_WAIT(locker, 0);
+  END_SOCKET_WAIT(locker);
   DBUG_RETURN(ret);
 }
 
@@ -978,12 +1009,12 @@ int vio_io_wait(Vio *vio, enum enum_vio_
   */
   if (timeout != 0 && vio->async_context && vio->async_context->active)
   {
-    MYSQL_START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
-                            PSI_SOCKET_SELECT, 0);
+    START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
+                            PSI_SOCKET_SELECT);
     ret= my_io_wait_async(vio->async_context, event, timeout);
     if (ret == 0)
       WSASetLastError(SOCKET_ETIMEDOUT);
-    MYSQL_END_SOCKET_WAIT(locker, 0);
+    END_SOCKET_WAIT(locker);
     DBUG_RETURN(ret);
   }
 
@@ -1014,12 +1045,12 @@ int vio_io_wait(Vio *vio, enum enum_vio_
     break;
   }
 
-  MYSQL_START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT, 0);
+  START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT);
 
   /* The first argument is ignored on Windows. */
   ret= select(0, &readfds, &writefds, &exceptfds, (timeout >= 0) ? &tm : NULL);
 
-  MYSQL_END_SOCKET_WAIT(locker, 0);
+  END_SOCKET_WAIT(locker);
 
   /* Set error code to indicate a timeout error. */
   if (ret == 0)



More information about the commits mailing list