List:Commits« Previous MessageNext Message »
From:Marc Alff Date:November 10 2011 2:04am
Subject:bzr push into mysql-trunk-pfs-tuning branch (marc.alff:3440 to 3441)
View as plain text  
 3441 Marc Alff	2011-11-09
      tuning in progress

    modified:
      include/mysql/psi/psi.h
      include/mysql/psi/psi_abi_v1.h.pp
      mysys/psi_noop.c
      sql/handler.cc
      storage/perfschema/pfs.cc
 3440 Marc Alff	2011-11-09
      Performance optimization

    modified:
      include/mysql/psi/mysql_socket.h
=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h	2011-11-08 23:28:12 +0000
+++ b/include/mysql/psi/psi.h	2011-11-10 02:03:57 +0000
@@ -1193,8 +1193,8 @@ typedef void (*unbind_table_v1_t)
   is reused for a thread.
   @param table the table to unbind
 */
-typedef void (*rebind_table_v1_t)
-  (struct PSI_table *table);
+typedef PSI_table* (*rebind_table_v1_t)
+  (PSI_table_share *share, const void *identity, PSI_table *table);
 
 /**
   Close an instrumentation table handle.

=== modified file 'include/mysql/psi/psi_abi_v1.h.pp'
--- a/include/mysql/psi/psi_abi_v1.h.pp	2011-11-04 16:34:00 +0000
+++ b/include/mysql/psi/psi_abi_v1.h.pp	2011-11-10 02:03:57 +0000
@@ -313,8 +313,8 @@ typedef struct PSI_table* (*open_table_v
   (struct PSI_table_share *share, const void *identity);
 typedef void (*unbind_table_v1_t)
   (struct PSI_table *table);
-typedef void (*rebind_table_v1_t)
-  (struct PSI_table *table);
+typedef PSI_table* (*rebind_table_v1_t)
+  (PSI_table_share *share, const void *identity, PSI_table *table);
 typedef void (*close_table_v1_t)(struct PSI_table *table);
 typedef void (*create_file_v1_t)(PSI_file_key key, const char *name,
                                  File file);

=== modified file 'mysys/psi_noop.c'
--- a/mysys/psi_noop.c	2011-11-05 12:22:44 +0000
+++ b/mysys/psi_noop.c	2011-11-10 02:03:57 +0000
@@ -158,9 +158,12 @@ static void unbind_table_noop(PSI_table 
   return;
 }
 
-static void rebind_table_noop(PSI_table *table NNN)
+static PSI_table*
+rebind_table_noop(PSI_table_share *share NNN,
+                  const void *identity NNN,
+                  PSI_table *table NNN)
 {
-  return;
+  return NULL;
 }
 
 static void close_table_noop(PSI_table *table NNN)

=== modified file 'sql/handler.cc'
--- a/sql/handler.cc	2011-11-04 16:34:00 +0000
+++ b/sql/handler.cc	2011-11-10 02:03:57 +0000
@@ -2172,25 +2172,24 @@ THD *handler::ha_thd(void) const
 
 void handler::unbind_psi()
 {
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_TABLE_INTERFACE
   /*
     Notify the instrumentation that this table is not owned
     by this thread any more.
   */
-  if (likely(PSI_server != NULL))
-    PSI_server->unbind_table(m_psi);
+  PSI_CALL(unbind_table)(m_psi);
 #endif
 }
 
 void handler::rebind_psi()
 {
-#ifdef HAVE_PSI_INTERFACE
+#ifdef HAVE_PSI_TABLE_INTERFACE
   /*
     Notify the instrumentation that this table is now owned
     by this thread.
   */
-  if (likely(PSI_server != NULL))
-    PSI_server->rebind_table(m_psi);
+  PSI_table_share *share_psi= ha_table_share_psi(table_share);
+  m_psi= PSI_CALL(rebind_table)(share_psi, this, m_psi);
 #endif
 }
 

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2011-11-08 22:45:59 +0000
+++ b/storage/perfschema/pfs.cc	2011-11-10 02:03:57 +0000
@@ -1533,10 +1533,22 @@ open_table_v1(PSI_table_share *share, co
   if (unlikely(pfs_table_share == NULL))
     return NULL;
 
-  // FIXME: full life cycle, with rebind, table cache, etc
+  /* This object is not to be instrumented. */
   if (! pfs_table_share->m_enabled)
     return NULL;
 
+  /* This object is instrumented, but all table instruments are disabled. */
+  if (! global_table_io_class.m_enabled && ! global_table_lock_class.m_enabled)
+    return NULL;
+
+  /*
+    When the performance schema is off, do not instrument anything.
+    Table handles have short life cycle, instrumentation will happen
+    again if needed during the next open().
+  */
+  if (! flag_global_instrumentation)
+    return NULL;
+
   PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
   if (unlikely(thread == NULL))
     return NULL;
@@ -1563,15 +1575,68 @@ static void unbind_table_v1(PSI_table *t
   Implementation of the table instrumentation interface.
   @sa PSI_v1::rebind_table.
 */
-static void rebind_table_v1(PSI_table *table)
+static PSI_table *
+rebind_table_v1(PSI_table_share *share, const void *identity, PSI_table *table)
 {
   PFS_table *pfs= reinterpret_cast<PFS_table*> (table);
   if (likely(pfs != NULL))
   {
+    PFS_thread *thread;
     DBUG_ASSERT(pfs->m_thread_owner == NULL);
 
-    pfs->m_thread_owner= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    /* The table handle was already instrumented, reuse it for this thread. */
+    thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+
+    if (unlikely(thread == NULL))
+    {
+      destroy_table(pfs);
+      return NULL;
+    }
+
+    if (unlikely(! pfs->m_share->m_enabled))
+    {
+      destroy_table(pfs);
+      return NULL;
+    }
+
+    if (unlikely(! global_table_io_class.m_enabled && ! global_table_lock_class.m_enabled))
+    {
+      destroy_table(pfs);
+      return NULL;
+    }
+
+    if (unlikely(! flag_global_instrumentation))
+    {
+      destroy_table(pfs);
+      return NULL;
+    }
+
+    pfs->m_thread_owner= thread;
+    return table;
   }
+
+  /* See open_table_v1() */
+
+  PFS_table_share *pfs_table_share= reinterpret_cast<PFS_table_share*> (share);
+
+  if (unlikely(pfs_table_share == NULL))
+    return NULL;
+
+  if (! pfs_table_share->m_enabled)
+    return NULL;
+
+  if (! global_table_io_class.m_enabled && ! global_table_lock_class.m_enabled)
+    return NULL;
+
+  if (! flag_global_instrumentation)
+    return NULL;
+
+  PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+  if (unlikely(thread == NULL))
+    return NULL;
+
+  PFS_table *pfs_table= create_table(pfs_table_share, thread, identity);
+  return reinterpret_cast<PSI_table *> (pfs_table);
 }
 
 /**

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-pfs-tuning branch (marc.alff:3440 to 3441) Marc Alff11 Nov