3278 cpowers 2011-04-02
WL#4896 "Performance Schema Net IO"
- Refinements to deferred aggregation
modified:
storage/perfschema/pfs.cc
storage/perfschema/pfs_instr.cc
storage/perfschema/pfs_stat.h
storage/perfschema/pfs_visitor.cc
3277 cpowers 2011-04-02
WL#4896 "Performance Schema Net IO"
- Fixed initialization error discovered by unit testing
- Corrected merge errors in unit test code
modified:
storage/perfschema/pfs.cc
storage/perfschema/unittest/pfs-t.cc
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2011-04-02 21:08:06 +0000
+++ b/storage/perfschema/pfs.cc 2011-04-03 00:15:15 +0000
@@ -4597,13 +4597,16 @@ static void end_socket_wait_v1(PSI_socke
DBUG_ASSERT(state != NULL);
ulonglong timer_end= 0;
ulonglong wait_time= 0;
+ bool socket_destroyed= false;
PFS_socket *socket= reinterpret_cast<PFS_socket *>(state->m_socket);
DBUG_ASSERT(socket != NULL);
PFS_thread *thread= reinterpret_cast<PFS_thread *>(state->m_thread);
PFS_byte_stat *byte_stat;
-
+ register uint flags= state->m_flags;
+ size_t bytes= ((int)byte_count > -1 ? byte_count : 0);
+
switch (state->m_operation)
{
/** Group read operations */
@@ -4632,6 +4635,7 @@ static void end_socket_wait_v1(PSI_socke
byte_stat= &socket->m_socket_stat.m_io_stat.m_misc;
/* This socket will no longer be used by the server */
destroy_socket(socket);
+ socket_destroyed= true;
break;
default:
@@ -4640,9 +4644,6 @@ static void end_socket_wait_v1(PSI_socke
break;
}
- register uint flags= state->m_flags;
- size_t bytes= ((int)byte_count > -1 ? byte_count : 0);
-
/** Aggregation for EVENTS_WAITS_SUMMARY_BY_INSTANCE */
if (flags & STATE_FLAG_TIMED)
{
@@ -4660,16 +4661,32 @@ static void end_socket_wait_v1(PSI_socke
/** Global thread aggregation */
if (flags & STATE_FLAG_THREAD)
{
+ DBUG_ASSERT(thread != NULL);
+
+ PFS_single_stat *event_name_array;
+ event_name_array= thread->m_instr_class_waits_stats;
+ uint index= socket->m_class->m_event_name_index;
+
/*
- Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted).
- Aggregation of socket wait stats per thread are deferred.
- */
- if (flags & ~STATE_FLAG_TIMED) // TODO MA: Moved to consumer except count
+ To reduce overhead per operation, aggregate the accumulated socket stats
+ after the socket has been destroyed.
+ */
+ if (socket_destroyed)
{
- PFS_single_stat *event_name_array;
- event_name_array= thread->m_instr_class_waits_stats;
- uint index= socket->m_class->m_event_name_index;
- event_name_array[index].aggregate_counted();
+ /* Combine stats for all operations */
+ PFS_single_stat stat;
+ socket->m_socket_stat.m_io_stat.sum_waits(&stat);
+
+ if (flags & STATE_FLAG_TIMED)
+ {
+ /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (timed) */
+ event_name_array[index].aggregate(&stat);
+ }
+ else
+ {
+ /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted). */
+ event_name_array[index].aggregate_counted(stat.m_count);
+ }
}
/* Aggregate to EVENTS_WAITS_CURRENT and EVENTS_WAITS_HISTORY */
=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc 2011-04-01 22:04:26 +0000
+++ b/storage/perfschema/pfs_instr.cc 2011-04-03 00:15:15 +0000
@@ -1434,17 +1434,6 @@ void destroy_socket(PFS_socket *pfs)
DBUG_ASSERT(pfs != NULL);
PFS_socket_class *klass= pfs->m_class;
-#if 0 // TODO MA: Here or defer to consumer?
- /* Combine per-operation stats into a single stat */
- PFS_single_stat stat;
- pfs->m_socket_stat.m_io_stat.sum_waits(&stat);
-
- /* Aggregate to EVENTS_WAITS_SUMMARY_BY_EVENT_NAME */
- uint index= klass->m_event_name_index;
- global_instr_class_waits_array[index].aggregate(&stat);
- pfs->m_wait_stat.reset();
-#endif
-
/* Aggregate to SOCKET_SUMMARY_BY_INSTANCE and BY_EVENT_NAME */
klass->m_socket_stat.m_io_stat.aggregate(&pfs->m_socket_stat.m_io_stat);
pfs->m_socket_stat.m_io_stat.reset();
=== modified file 'storage/perfschema/pfs_stat.h'
--- a/storage/perfschema/pfs_stat.h 2011-04-01 22:04:26 +0000
+++ b/storage/perfschema/pfs_stat.h 2011-04-03 00:15:15 +0000
@@ -71,6 +71,11 @@ struct PFS_single_stat
m_count++;
}
+ inline void aggregate_counted(ulonglong count)
+ {
+ m_count+= count;
+ }
+
inline void aggregate_value(ulonglong value)
{
m_count++;
=== modified file 'storage/perfschema/pfs_visitor.cc'
--- a/storage/perfschema/pfs_visitor.cc 2011-04-01 22:04:26 +0000
+++ b/storage/perfschema/pfs_visitor.cc 2011-04-03 00:15:15 +0000
@@ -180,7 +180,7 @@ void PFS_instance_iterator::visit_file_i
}
}
-/** Socket instance iterator visting all socket instances */
+/** Socket instance iterator visting a socket class and all instances */
void PFS_instance_iterator::visit_socket_instances(PFS_socket_class *klass,
PFS_instance_visitor *visitor)
@@ -200,7 +200,10 @@ void PFS_instance_iterator::visit_socket
}
}
-/** Socket instance iterator visting sockets owned by PFS_thread */
+/**
+ Socket instance iterator visting sockets owned by PFS_thread.
+ The socket class is not visited.
+*/
void PFS_instance_iterator::visit_socket_instances(PFS_socket_class *klass,
PFS_instance_visitor *visitor,
@@ -209,9 +212,6 @@ void PFS_instance_iterator::visit_socket
DBUG_ASSERT(visitor != NULL);
DBUG_ASSERT(thread != NULL);
- /* Get accumulated socket stats for this thread */
- visitor->visit_socket_class(klass);
-
/* Get current socket stats from each socket instance owned by this thread */
PFS_socket *pfs= socket_array;
PFS_socket *pfs_last= pfs + socket_max;
Attachment: [text/bzr-bundle] bzr/cpowers@tma-1-20110403001515-4st7yqmlyf2oxqtm.bundle
| Thread |
|---|
| • bzr push into mysql-trunk branch (chris.powers:3277 to 3278) WL#4896 | Christopher Powers | 3 Apr |