3431 Mayank Prasad 2012-02-06
WL#5767: Performance Schema, Statements Digest
Details:
- Modified PSI_digest_locker_state_v1 to have last_id_index.
- Modified PFS_digest_storage to have only Token Stream.
- Modified PFS_statements_digest_stat to have Digest Hash.
modified:
include/mysql/psi/psi.h
include/mysql/psi/psi_abi_v1.h.pp
storage/perfschema/pfs.cc
storage/perfschema/pfs_digest.cc
storage/perfschema/pfs_digest.h
storage/perfschema/table_events_statements.cc
storage/perfschema/table_helper.cc
3430 Mayank Prasad 2012-02-06
WL#5767 : Performance Schema, Statements Digest
Details:
- Probable fix for a failing test case on PB2.
modified:
storage/perfschema/pfs_digest.cc
=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h 2012-02-03 16:00:30 +0000
+++ b/include/mysql/psi/psi.h 2012-02-06 09:30:53 +0000
@@ -925,7 +925,7 @@ struct PSI_table_locker_state_v1
struct PSI_digest_locker_state_v1
{
- uint m_token_count;
+ int m_last_id_index;
void *m_statement;
};
=== modified file 'include/mysql/psi/psi_abi_v1.h.pp'
--- a/include/mysql/psi/psi_abi_v1.h.pp 2012-02-03 16:00:30 +0000
+++ b/include/mysql/psi/psi_abi_v1.h.pp 2012-02-06 09:30:53 +0000
@@ -239,7 +239,7 @@ struct PSI_table_locker_state_v1
};
struct PSI_digest_locker_state_v1
{
- uint m_token_count;
+ int m_last_id_index;
void *m_statement;
};
struct PSI_statement_locker_state_v1
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2012-02-03 16:00:30 +0000
+++ b/storage/perfschema/pfs.cc 2012-02-06 09:30:53 +0000
@@ -4539,7 +4539,8 @@ static void end_statement_v1(PSI_stateme
/*
Calculate MD5 Hash of the tokens received.
*/
- MY_MD5_HASH(digest_storage->m_digest_hash.m_md5,
+ PFS_digest_hash digest_hash;
+ MY_MD5_HASH(digest_hash.m_md5,
(unsigned char *)digest_storage->m_token_array,
(uint) sizeof(digest_storage->m_token_array));
@@ -4547,7 +4548,7 @@ static void end_statement_v1(PSI_stateme
Populate PFS_statements_digest_stat with computed digest information.
*/
pfs->statement_digest_stat_ptr=
- find_or_create_digest(thread, digest_storage);
+ find_or_create_digest(thread, digest_hash, digest_storage);
if(pfs->statement_digest_stat_ptr)
{
digest_stat= &(pfs->statement_digest_stat_ptr->m_stat);
@@ -4605,7 +4606,8 @@ static void end_statement_v1(PSI_stateme
/*
Calculate MD5 Hash of the tokens received.
*/
- MY_MD5_HASH(digest_storage->m_digest_hash.m_md5,
+ PFS_digest_hash digest_hash;
+ MY_MD5_HASH(digest_hash.m_md5,
(unsigned char *)digest_storage->m_token_array,
(uint) sizeof(digest_storage->m_token_array));
@@ -4613,7 +4615,7 @@ static void end_statement_v1(PSI_stateme
Populate PFS_statements_digest_stat with computed digest information.
*/
pfs->statement_digest_stat_ptr=
- find_or_create_digest(thread, digest_storage);
+ find_or_create_digest(thread, digest_hash, digest_storage);
if(pfs->statement_digest_stat_ptr)
{
digest_stat= &(pfs->statement_digest_stat_ptr->m_stat);
=== modified file 'storage/perfschema/pfs_digest.cc'
--- a/storage/perfschema/pfs_digest.cc 2012-02-06 06:46:14 +0000
+++ b/storage/perfschema/pfs_digest.cc 2012-02-06 09:30:53 +0000
@@ -81,10 +81,7 @@ int init_digest(unsigned int statements_
for (index= 0; index < statements_digest_size; index++)
{
- 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;
+ statements_digest_stat_array[index].reset();
}
return (statements_digest_stat_array ? 0 : 1);
@@ -112,7 +109,7 @@ static uchar *digest_hash_get_key(const
digest= *typed_entry;
DBUG_ASSERT(digest != NULL);
*length= 16;
- result= digest->m_digest_storage.m_digest_hash.m_md5;
+ result= digest->m_digest_hash.m_md5;
return const_cast<uchar*> (reinterpret_cast<const uchar*> (result));
}
C_MODE_END
@@ -156,7 +153,7 @@ static LF_PINS* get_digest_hash_pins(PFS
}
PFS_statements_digest_stat*
-find_or_create_digest(PFS_thread* thread, PFS_digest_storage* digest_storage)
+find_or_create_digest(PFS_thread* thread, PFS_digest_hash d_hash, PFS_digest_storage* digest_storage)
{
/* get digest pin. */
LF_PINS *pins= get_digest_hash_pins(thread);
@@ -167,7 +164,7 @@ find_or_create_digest(PFS_thread* thread
return NULL;
}
- unsigned char* hash_key= digest_storage->m_digest_hash.m_md5;
+ unsigned char* hash_key= d_hash.m_md5;
PFS_statements_digest_stat **entry;
PFS_statements_digest_stat *pfs= NULL;
@@ -190,7 +187,11 @@ find_or_create_digest(PFS_thread* thread
digest_stat array is full. Add stat at index 0 and return.
*/
pfs= &statements_digest_stat_array[0];
- if(pfs->m_first_seen!=0)
+ /*
+ If this is the first entry at index 0, update
+ first seen information.
+ */
+ if(pfs->m_first_seen==0)
pfs->m_first_seen= now;
pfs->m_last_seen= now;
return pfs;
@@ -206,14 +207,12 @@ find_or_create_digest(PFS_thread* thread
used later to generate digest text.
*/
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);
-
+ memcpy(pfs->m_digest_hash.m_md5,
+ d_hash.m_md5, 16);
pfs->m_first_seen= now;
pfs->m_last_seen= now;
@@ -278,17 +277,19 @@ void purge_digest(PFS_thread* thread, un
return;
}
-void PFS_digest_storage::reset()
+void PFS_statements_digest_stat::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';
+ m_digest_storage.m_byte_count= 0;
+ m_digest_storage.m_token_array[0]= '\0';
+ m_stat.reset();
purge_digest(thread, m_digest_hash.m_md5);
m_digest_hash.m_md5[0]= '\0';
+ m_first_seen= 0;
+ m_last_seen= 0;
}
void reset_esms_by_digest()
@@ -303,10 +304,7 @@ void reset_esms_by_digest()
*/
for (index= 0; index < statements_digest_size; index++)
{
- 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;
+ statements_digest_stat_array[index].reset();
}
/*
@@ -409,7 +407,7 @@ struct PSI_digest_locker* pfs_digest_sta
Initialize token array and token count to 0.
*/
digest_storage->m_byte_count= PFS_MAX_DIGEST_STORAGE_SIZE;
- digest_storage->m_last_id_index= 0;
+ state->m_last_id_index= 0;
while(digest_storage->m_byte_count)
digest_storage->m_token_array[--digest_storage->m_byte_count]= 0;
@@ -455,7 +453,7 @@ PSI_digest_locker* pfs_digest_add_token_
uint last_token = TOK_PFS_UNUSED;
uint last_token2= TOK_PFS_UNUSED;
- read_last_two_tokens(digest_storage, &last_token, &last_token2);
+ read_last_two_tokens(digest_storage, state->m_last_id_index, &last_token, &last_token2);
switch (token)
{
@@ -512,7 +510,7 @@ PSI_digest_locker* pfs_digest_add_token_
token= TOK_PFS_ROW_SINGLE_VALUE;
/* Read last two tokens again */
- read_last_two_tokens(digest_storage, &last_token, &last_token2);
+ read_last_two_tokens(digest_storage, state->m_last_id_index, &last_token, &last_token2);
if((last_token2 == TOK_PFS_ROW_SINGLE_VALUE ||
last_token2 == TOK_PFS_ROW_SINGLE_VALUE_LIST) &&
@@ -543,7 +541,7 @@ PSI_digest_locker* pfs_digest_add_token_
token= TOK_PFS_ROW_MULTIPLE_VALUE;
/* Read last two tokens again */
- read_last_two_tokens(digest_storage, &last_token, &last_token2);
+ read_last_two_tokens(digest_storage, state->m_last_id_index, &last_token, &last_token2);
if((last_token2 == TOK_PFS_ROW_MULTIPLE_VALUE ||
last_token2 == TOK_PFS_ROW_MULTIPLE_VALUE_LIST) &&
@@ -582,7 +580,7 @@ PSI_digest_locker* pfs_digest_add_token_
/*
Update the index of last identifier found.
*/
- digest_storage->m_last_id_index= digest_storage->m_byte_count;
+ state->m_last_id_index= digest_storage->m_byte_count;
break;
}
default:
=== modified file 'storage/perfschema/pfs_digest.h'
--- a/storage/perfschema/pfs_digest.h 2012-02-04 19:02:49 +0000
+++ b/storage/perfschema/pfs_digest.h 2012-02-06 09:30:53 +0000
@@ -45,18 +45,19 @@ 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];
-
- void reset();
} typedef PFS_digest_storage;
/** A statement digest stat record. */
struct PFS_statements_digest_stat
{
/**
+ Digest MD5 Hash.
+ */
+ PFS_digest_hash m_digest_hash;
+
+ /**
Digest Storage.
*/
PFS_digest_storage m_digest_storage;
@@ -71,6 +72,8 @@ struct PFS_statements_digest_stat
*/
ulonglong m_first_seen;
ulonglong m_last_seen;
+
+ void reset();
};
int init_digest(unsigned int digest_sizing);
@@ -79,6 +82,7 @@ void cleanup_digest();
int init_digest_hash(void);
void cleanup_digest_hash(void);
PFS_statements_digest_stat* find_or_create_digest(PFS_thread*,
+ PFS_digest_hash,
PFS_digest_storage*);
void get_digest_text(char* digest_text,
@@ -196,10 +200,9 @@ inline void store_identifier(PFS_digest_
is found, do not look for token after that.
*/
inline void read_last_two_tokens(PFS_digest_storage* digest_storage,
- uint *t1, uint *t2)
+ int last_id_index, uint *t1, uint *t2)
{
int last_token_index;
- int last_id_index= digest_storage->m_last_id_index;
int byte_count= digest_storage->m_byte_count;
if(last_id_index <= byte_count - PFS_SIZE_OF_A_TOKEN)
=== modified file 'storage/perfschema/table_events_statements.cc'
--- a/storage/perfschema/table_events_statements.cc 2012-02-03 11:38:42 +0000
+++ b/storage/perfschema/table_events_statements.cc 2012-02-06 09:30:53 +0000
@@ -375,7 +375,7 @@ void table_events_statements_common::mak
Calculate digest from MD5 HASH collected to be shown as
DIGEST in this row.
*/
- MD5_HASH_TO_STRING(pfs->m_digest_storage.m_digest_hash.m_md5,
+ MD5_HASH_TO_STRING(pfs->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-03 11:38:42 +0000
+++ b/storage/perfschema/table_helper.cc 2012-02-06 09:30:53 +0000
@@ -114,7 +114,7 @@ int PFS_digest_row::make_row(PFS_stateme
Calculate digest from MD5 HASH collected to be shown as
DIGEST in this row.
*/
- MD5_HASH_TO_STRING(pfs->m_digest_storage.m_digest_hash.m_md5, m_digest);
+ MD5_HASH_TO_STRING(pfs->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:3430 to 3431) WL#5767 | Mayank Prasad | 6 Feb |