#At file:///Users/malff/BZR_TREE/mysql-trunk-stage/ based on revid:marc.alff@stripped
3612 Marc Alff 2011-03-23
Follow up on code review.
Fixed tables:
- EVENTS_STAGES_SUMMARY_BY_THREAD_BY_EVENT_NAME
- EVENTS_STATEMENTS_SuMMARY_BY_THREAD_BY_EVENT_NAME
to follow the iteration pattern changed previously for table
- EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
Iteration per thread is in the outer most loop.
modified:
storage/perfschema/table_esgs_by_thread_by_event_name.cc
storage/perfschema/table_esgs_by_thread_by_event_name.h
storage/perfschema/table_esms_by_thread_by_event_name.cc
storage/perfschema/table_esms_by_thread_by_event_name.h
=== modified file 'storage/perfschema/table_esgs_by_thread_by_event_name.cc'
--- a/storage/perfschema/table_esgs_by_thread_by_event_name.cc 2011-02-14 14:23:55 +0000
+++ b/storage/perfschema/table_esgs_by_thread_by_event_name.cc 2011-03-23 13:28:47 +0000
@@ -117,26 +117,27 @@ int table_esgs_by_thread_by_event_name::
PFS_thread *thread;
PFS_stage_class *stage_class;
- m_pos.set_at(&m_next_pos);
-
- do
+ for (m_pos.set_at(&m_next_pos);
+ m_pos.has_more_thread();
+ m_pos.next_thread())
{
- stage_class= find_stage_class(m_pos.m_index_1);
- if (stage_class)
+ thread= &thread_array[m_pos.m_index_1];
+
+ /*
+ Important note: the thread scan is the outer loop (index 1),
+ to minimize the number of calls to atomic operations.
+ */
+ if (thread->m_lock.is_populated())
{
- for ( ; m_pos.has_more_thread(); m_pos.next_thread())
+ stage_class= find_stage_class(m_pos.m_index_2);
+ if (stage_class)
{
- thread= &thread_array[m_pos.m_index_2];
- if (thread->m_lock.is_populated())
- {
- make_row(thread, stage_class);
- m_next_pos.set_after(&m_pos);
- return 0;
- }
+ make_row(thread, stage_class);
+ m_next_pos.set_after(&m_pos);
+ return 0;
}
- m_pos.next_stage();
}
- } while (stage_class != NULL);
+ }
return HA_ERR_END_OF_FILE;
}
@@ -148,13 +149,13 @@ table_esgs_by_thread_by_event_name::rnd_
PFS_stage_class *stage_class;
set_position(pos);
- DBUG_ASSERT(m_pos.m_index_2 < thread_max);
+ DBUG_ASSERT(m_pos.m_index_1 < thread_max);
- thread= &thread_array[m_pos.m_index_2];
+ thread= &thread_array[m_pos.m_index_1];
if (! thread->m_lock.is_populated())
return HA_ERR_RECORD_DELETED;
- stage_class= find_stage_class(m_pos.m_index_1);
+ stage_class= find_stage_class(m_pos.m_index_2);
if (stage_class)
{
make_row(thread, stage_class);
=== modified file 'storage/perfschema/table_esgs_by_thread_by_event_name.h'
--- a/storage/perfschema/table_esgs_by_thread_by_event_name.h 2011-02-14 14:23:55 +0000
+++ b/storage/perfschema/table_esgs_by_thread_by_event_name.h 2011-03-23 13:28:47 +0000
@@ -49,32 +49,32 @@ struct row_esgs_by_thread_by_event_name
/**
Position of a cursor on
PERFORMANCE_SCHEMA.EVENTS_STAGES_SUMMARY_BY_THREAD_BY_EVENT_NAME.
- Index 1 on stage class (1 based).
- Index 2 on thread (0 based).
+ Index 1 on thread (0 based).
+ Index 2 on stage class (1 based).
*/
struct pos_esgs_by_thread_by_event_name
: public PFS_double_index
{
pos_esgs_by_thread_by_event_name()
- : PFS_double_index(1, 0)
+ : PFS_double_index(0, 1)
{}
inline void reset(void)
{
- m_index_1= 1;
- m_index_2= 0;
+ m_index_1= 0;
+ m_index_2= 1;
}
inline bool has_more_thread(void)
- { return (m_index_2 < thread_max); }
+ { return (m_index_1 < thread_max); }
- inline void next_stage(void)
+ inline void next_thread(void)
{
m_index_1++;
- m_index_2= 0;
+ m_index_2= 1;
}
- inline void next_thread(void)
+ inline void next_stage(void)
{
m_index_2++;
}
=== modified file 'storage/perfschema/table_esms_by_thread_by_event_name.cc'
--- a/storage/perfschema/table_esms_by_thread_by_event_name.cc 2011-02-14 14:23:55 +0000
+++ b/storage/perfschema/table_esms_by_thread_by_event_name.cc 2011-03-23 13:28:47 +0000
@@ -212,26 +212,27 @@ int table_esms_by_thread_by_event_name::
PFS_thread *thread;
PFS_statement_class *statement_class;
- m_pos.set_at(&m_next_pos);
-
- do
+ for (m_pos.set_at(&m_next_pos);
+ m_pos.has_more_thread();
+ m_pos.next_thread())
{
- statement_class= find_statement_class(m_pos.m_index_1);
- if (statement_class)
+ thread= &thread_array[m_pos.m_index_1];
+
+ /*
+ Important note: the thread scan is the outer loop (index 1),
+ to minimize the number of calls to atomic operations.
+ */
+ if (thread->m_lock.is_populated())
{
- for ( ; m_pos.has_more_thread(); m_pos.next_thread())
+ statement_class= find_statement_class(m_pos.m_index_2);
+ if (statement_class)
{
- thread= &thread_array[m_pos.m_index_2];
- if (thread->m_lock.is_populated())
- {
- make_row(thread, statement_class);
- m_next_pos.set_after(&m_pos);
- return 0;
- }
+ make_row(thread, statement_class);
+ m_next_pos.set_after(&m_pos);
+ return 0;
}
- m_pos.next_statement();
}
- } while (statement_class != NULL);
+ }
return HA_ERR_END_OF_FILE;
}
@@ -243,13 +244,13 @@ table_esms_by_thread_by_event_name::rnd_
PFS_statement_class *statement_class;
set_position(pos);
- DBUG_ASSERT(m_pos.m_index_2 < thread_max);
+ DBUG_ASSERT(m_pos.m_index_1 < thread_max);
- thread= &thread_array[m_pos.m_index_2];
+ thread= &thread_array[m_pos.m_index_1];
if (! thread->m_lock.is_populated())
return HA_ERR_RECORD_DELETED;
- statement_class= find_statement_class(m_pos.m_index_1);
+ statement_class= find_statement_class(m_pos.m_index_2);
if (statement_class)
{
make_row(thread, statement_class);
=== modified file 'storage/perfschema/table_esms_by_thread_by_event_name.h'
--- a/storage/perfschema/table_esms_by_thread_by_event_name.h 2011-02-14 14:23:55 +0000
+++ b/storage/perfschema/table_esms_by_thread_by_event_name.h 2011-03-23 13:28:47 +0000
@@ -49,32 +49,32 @@ struct row_esms_by_thread_by_event_name
/**
Position of a cursor on
PERFORMANCE_SCHEMA.EVENTS_STATEMENTS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
- Index 1 on statement class (1 based).
- Index 2 on thread (0 based).
+ Index 1 on thread (0 based).
+ Index 2 on statement class (1 based).
*/
struct pos_esms_by_thread_by_event_name
: public PFS_double_index, public PFS_instrument_view_constants
{
pos_esms_by_thread_by_event_name()
- : PFS_double_index(1, 0)
+ : PFS_double_index(0, 1)
{}
inline void reset(void)
{
- m_index_1= 1;
- m_index_2= 0;
+ m_index_1= 0;
+ m_index_2= 1;
}
inline bool has_more_thread(void)
- { return (m_index_2 < thread_max); }
+ { return (m_index_1 < thread_max); }
- inline void next_statement(void)
+ inline void next_thread(void)
{
m_index_1++;
- m_index_2= 0;
+ m_index_2= 1;
}
- inline void next_thread(void)
+ inline void next_statement(void)
{
m_index_2++;
}
Attachment: [text/bzr-bundle] bzr/marc.alff@oracle.com-20110323132847-ta6p692tbg0epwxj.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk branch (marc.alff:3612) | Marc Alff | 23 Mar |