List:Commits« Previous MessageNext Message »
From:Mayank Prasad Date:February 3 2012 11:40am
Subject:bzr push into mysql-trunk-wl5767 branch (mayank.prasad:3425 to 3426) WL#5767
View as plain text  
 3426 Mayank Prasad	2012-02-03
      WL#5767 Performance Schema, Statements Digest
      
      Details:
      - Removed duplicates from PFS_statements_digest_stat.
      - Added code to delete hash entries once truncate table is called.
      - Did few code cleanup.

    modified:
      storage/perfschema/pfs_digest.cc
      storage/perfschema/pfs_digest.h
      storage/perfschema/table_esms_by_digest.cc
      storage/perfschema/table_events_statements.cc
      storage/perfschema/table_helper.cc
 3425 Mayank Prasad	2012-02-02
      WL#5767: Performance Schema, Statements Digest
      
      Details
      - Modified result file for failing test cases.

    modified:
      mysql-test/suite/perfschema/r/statements_digest.result
      mysql-test/suite/perfschema/r/statements_digest_long_query.result
=== modified file 'storage/perfschema/pfs_digest.cc'
--- a/storage/perfschema/pfs_digest.cc	2012-02-02 15:57:35 +0000
+++ b/storage/perfschema/pfs_digest.cc	2012-02-03 11:38:42 +0000
@@ -67,7 +67,7 @@ int init_digest(unsigned int statements_
   unsigned int index;
 
   /* 
-    TBD. Allocate memory for statements_digest_stat_array based on 
+    Allocate memory for statements_digest_stat_array based on 
     performance_schema_digests_size values
   */
   statements_digest_size= statements_digest_sizing;
@@ -89,7 +89,7 @@ int init_digest(unsigned int statements_
 void cleanup_digest(void)
 {
   /* 
-    TBD. Free memory allocated to statements_digest_stat_array. 
+    Free memory allocated to statements_digest_stat_array. 
   */
   pfs_free(statements_digest_stat_array);
   statements_digest_stat_array= NULL;
@@ -107,7 +107,7 @@ static uchar *digest_hash_get_key(const
   digest= *typed_entry;
   DBUG_ASSERT(digest != NULL);
   *length= 16; 
-  result= digest->m_md5_hash.m_md5;
+  result= digest->m_digest_storage.m_digest_hash.m_md5;
   return const_cast<uchar*> (reinterpret_cast<const uchar*> (result));
 }
 C_MODE_END
@@ -202,13 +202,13 @@ find_or_create_digest(PFS_thread* thread
     */
     pfs->m_digest_storage.m_byte_count= digest_storage->m_byte_count;
     pfs->m_digest_storage.m_last_id_index= digest_storage->m_last_id_index;
+    /* Copy token array. */
     memcpy(pfs->m_digest_storage.m_token_array, digest_storage->m_token_array,
            PFS_MAX_DIGEST_STORAGE_SIZE);
+    /* Copy digest hash/LF Hash search key. */
     memcpy(pfs->m_digest_storage.m_digest_hash.m_md5,
            digest_storage->m_digest_hash.m_md5, 16);
 
-    /* Set digest hash/LF Hash search key. */
-    memcpy(pfs->m_md5_hash.m_md5, hash_key, 16);
 
     pfs->m_first_seen= now;
     pfs->m_last_seen= now;
@@ -250,6 +250,42 @@ find_or_create_digest(PFS_thread* thread
   return NULL;
 }
  
+void purge_digest(PFS_thread* thread, unsigned char* hash_key)
+{
+  /* get digest pin. */
+  LF_PINS *pins= get_digest_hash_pins(thread);
+  if(unlikely(pins == NULL))
+    return;
+
+  PFS_statements_digest_stat **entry;
+
+  /* Lookup LF_HASH using this new key. */
+  entry= reinterpret_cast<PFS_statements_digest_stat**>
+    (lf_hash_search(&digest_hash, pins,
+                    hash_key, 16));
+
+  if(entry && (entry != MY_ERRPTR))
+  { 
+    lf_hash_delete(&digest_hash, pins,
+                   hash_key, 16);
+  }
+  lf_hash_search_unpin(pins);
+  return;
+}
+
+void PFS_digest_storage::reset()
+{
+  PFS_thread *thread= PFS_thread::get_current_thread();
+  if (unlikely(thread == NULL))
+      return;
+
+  m_byte_count= 0;
+  m_last_id_index= 0;
+  m_token_array[0]= '\0';
+  purge_digest(thread, m_digest_hash.m_md5);
+  m_digest_hash.m_md5[0]= '\0';
+}
+
 void reset_esms_by_digest()
 {
   uint index;
@@ -262,14 +298,14 @@ void reset_esms_by_digest()
   */
   for (index= 0; index < statements_digest_size; index++)
   {
-    statements_digest_stat_array[index].m_md5_hash.m_md5[0]= '\0';
+    statements_digest_stat_array[index].m_digest_storage.reset();
     statements_digest_stat_array[index].m_stat.reset();
     statements_digest_stat_array[index].m_first_seen= 0;
     statements_digest_stat_array[index].m_last_seen= 0;
   }
 
   /* 
-    Reset index which indicates where the next calculated digest informationi
+    Reset index which indicates where the next calculated digest information
     to be inserted in statements_digest_stat_array.
   */
   digest_index= 1;

=== modified file 'storage/perfschema/pfs_digest.h'
--- a/storage/perfschema/pfs_digest.h	2012-02-02 15:57:35 +0000
+++ b/storage/perfschema/pfs_digest.h	2012-02-03 11:38:42 +0000
@@ -45,21 +45,18 @@ struct {
   on which digest is to be calculated.
 */
 struct {
+         PFS_digest_hash m_digest_hash;
          int m_byte_count;
          int m_last_id_index;
          char m_token_array[PFS_MAX_DIGEST_STORAGE_SIZE];
-         PFS_digest_hash m_digest_hash;
+
+         void reset();
        } typedef PFS_digest_storage;
 
 /** A statement digest stat record. */
 struct PFS_statements_digest_stat
 {
   /**
-    Digest hash/LF Hash search key.
-  */
-  PFS_digest_hash m_md5_hash;
-
-  /**
     Digest Storage.
   */
   PFS_digest_storage m_digest_storage;

=== modified file 'storage/perfschema/table_esms_by_digest.cc'
--- a/storage/perfschema/table_esms_by_digest.cc	2012-02-02 12:04:43 +0000
+++ b/storage/perfschema/table_esms_by_digest.cc	2012-02-03 11:38:42 +0000
@@ -231,11 +231,11 @@ int table_esms_by_digest::rnd_next(void)
   digest_stat= &statements_digest_stat_array[m_pos.m_index];
 
   /* 
-    If MD5 HASH information exist for this record or
+    If byte_count is not 0 i.e. its a valid entry in stat array or
     If it is a record at index 0 of statements_digest_stat_array,
     make a new row.
   */
-  if(digest_stat->m_md5_hash.m_md5[0] != '\0' ||
+  if(digest_stat->m_digest_storage.m_byte_count != 0 ||
      m_pos.m_index == 0)
   {
     make_row(digest_stat);
@@ -255,11 +255,11 @@ table_esms_by_digest::rnd_pos(const void
   digest_stat= &statements_digest_stat_array[m_pos.m_index];
 
   /* 
-    If MD5 HASH information exist for this record or
+    If byte_count is not 0 i.e. its a valid entry in stat array or
     If it is a record at index 0 of statements_digest_stat_array,
     make a new row.
   */
-  if(digest_stat->m_md5_hash.m_md5[0] != '\0' ||
+  if(digest_stat->m_digest_storage.m_byte_count != 0 ||
      m_pos.m_index == 0)
   {
     make_row(digest_stat);

=== modified file 'storage/perfschema/table_events_statements.cc'
--- a/storage/perfschema/table_events_statements.cc	2012-02-02 12:04:43 +0000
+++ b/storage/perfschema/table_events_statements.cc	2012-02-03 11:38:42 +0000
@@ -369,13 +369,13 @@ void table_events_statements_common::mak
     Filling up statement digest information.
   */
   PFS_statements_digest_stat *pfs= statement->statement_digest_stat_ptr;
-  if(pfs && pfs->m_md5_hash.m_md5[0] != '\0')
+  if(pfs && pfs->m_digest_storage.m_byte_count != 0)
   {
     /*
       Calculate digest from MD5 HASH collected to be shown as
       DIGEST in this row.
     */
-    MD5_HASH_TO_STRING(pfs->m_md5_hash.m_md5,
+    MD5_HASH_TO_STRING(pfs->m_digest_storage.m_digest_hash.m_md5,
                        m_row.m_digest.m_digest);
     m_row.m_digest.m_digest_length= 16;
 

=== modified file 'storage/perfschema/table_helper.cc'
--- a/storage/perfschema/table_helper.cc	2012-02-02 08:15:42 +0000
+++ b/storage/perfschema/table_helper.cc	2012-02-03 11:38:42 +0000
@@ -104,17 +104,17 @@ void PFS_account_row::set_field(uint ind
 int PFS_digest_row::make_row(PFS_statements_digest_stat* pfs)
 {
   /*
-    "NULL" value for MD5_HASH indicates special entry i.e. aggregated
+    "0" value for byte_count indicates special entry i.e. aggregated
     stats at index 0 of statements_digest_stat_array. So do not calculate
     digest/digest_text as it should always be "NULL".
   */
-  if(pfs->m_md5_hash.m_md5[0] != '\0')
+  if(pfs->m_digest_storage.m_byte_count != 0)
   {
     /*
       Calculate digest from MD5 HASH collected to be shown as
       DIGEST in this row.
     */
-    MD5_HASH_TO_STRING(pfs->m_md5_hash.m_md5, m_digest);
+    MD5_HASH_TO_STRING(pfs->m_digest_storage.m_digest_hash.m_md5, m_digest);
     m_digest_length= 16;
 
     /* 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5767 branch (mayank.prasad:3425 to 3426) WL#5767Mayank Prasad3 Feb