3382 Marc Alff 2011-06-09
code optimization pass using pahole:
- packed structures better
- reordered critical attributes
- removed unused attributes
modified:
include/mysql/psi/psi.h
include/mysql/psi/psi_abi_v1.h.pp
storage/perfschema/pfs.cc
storage/perfschema/pfs_instr.h
storage/perfschema/pfs_instr_class.cc
storage/perfschema/pfs_instr_class.h
3381 Marc Alff 2011-06-06
performance tuning: de normalized instrumentation flags
modified:
mysql-test/suite/perfschema/t/func_file_io.test
storage/perfschema/pfs.cc
storage/perfschema/pfs_instr.cc
storage/perfschema/pfs_instr.h
storage/perfschema/table_setup_consumers.cc
storage/perfschema/table_setup_instruments.cc
storage/perfschema/unittest/pfs-t.cc
storage/perfschema/unittest/pfs_instr_class-t.cc
=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h 2011-05-04 21:19:21 +0000
+++ b/include/mysql/psi/psi.h 2011-06-09 08:37:11 +0000
@@ -606,6 +606,8 @@ struct PSI_mutex_locker_state_v1
{
/** Internal state. */
uint m_flags;
+ /** Current operation. */
+ enum PSI_mutex_operation m_operation;
/** Current mutex. */
struct PSI_mutex *m_mutex;
/** Current thread. */
@@ -614,12 +616,6 @@ struct PSI_mutex_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /** Current operation. */
- enum PSI_mutex_operation m_operation;
- /** Source file. */
- const char* m_src_file;
- /** Source line number. */
- int m_src_line;
/** Internal data. */
void *m_wait;
};
@@ -637,6 +633,8 @@ struct PSI_rwlock_locker_state_v1
{
/** Internal state. */
uint m_flags;
+ /** Current operation. */
+ enum PSI_rwlock_operation m_operation;
/** Current rwlock. */
struct PSI_rwlock *m_rwlock;
/** Current thread. */
@@ -645,12 +643,6 @@ struct PSI_rwlock_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /** Current operation. */
- enum PSI_rwlock_operation m_operation;
- /** Source file. */
- const char* m_src_file;
- /** Source line number. */
- int m_src_line;
/** Internal data. */
void *m_wait;
};
@@ -668,6 +660,8 @@ struct PSI_cond_locker_state_v1
{
/** Internal state. */
uint m_flags;
+ /** Current operation. */
+ enum PSI_cond_operation m_operation;
/** Current condition. */
struct PSI_cond *m_cond;
/** Current mutex. */
@@ -678,12 +672,6 @@ struct PSI_cond_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /** Current operation. */
- enum PSI_cond_operation m_operation;
- /** Source file. */
- const char* m_src_file;
- /** Source line number. */
- int m_src_line;
/** Internal data. */
void *m_wait;
};
@@ -703,6 +691,8 @@ struct PSI_file_locker_state_v1
{
/** Internal state. */
uint m_flags;
+ /** Current operation. */
+ enum PSI_file_operation m_operation;
/** Current file. */
struct PSI_file *m_file;
/** Current thread. */
@@ -713,12 +703,6 @@ struct PSI_file_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /** Current operation. */
- enum PSI_file_operation m_operation;
- /** Source file. */
- const char* m_src_file;
- /** Source line number. */
- int m_src_line;
/** Internal data. */
void *m_wait;
};
@@ -738,6 +722,8 @@ struct PSI_table_locker_state_v1
{
/** Internal state. */
uint m_flags;
+ /** Current io operation. */
+ enum PSI_table_io_operation m_io_operation;
/** Current table handle. */
struct PSI_table *m_table;
/** Current table share. */
@@ -748,20 +734,14 @@ struct PSI_table_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /** Current io operation. */
- enum PSI_table_io_operation m_io_operation;
+ /** Internal data. */
+ void *m_wait;
/**
Implementation specific.
For table io, the table io index.
For table lock, the lock type.
*/
uint m_index;
- /** Source file. */
- const char* m_src_file;
- /** Source line number. */
- int m_src_line;
- /** Internal data. */
- void *m_wait;
};
/**
@@ -776,6 +756,12 @@ struct PSI_table_locker_state_v1
*/
struct PSI_statement_locker_state_v1
{
+ /** Discarded flag. */
+ my_bool m_discarded;
+ /** Metric, no index used flag. */
+ uchar m_no_index_used;
+ /** Metric, no good index used flag. */
+ uchar m_no_good_index_used;
/** Internal state. */
uint m_flags;
/** Instrumentation class. */
@@ -786,14 +772,8 @@ struct PSI_statement_locker_state_v1
ulonglong m_timer_start;
/** Timer function. */
ulonglong (*m_timer)(void);
- /** Source file. */
- const char* m_src_file;
- /** Source line number. */
- int m_src_line;
/** Internal data. */
void *m_statement;
- /** Discarded flag. */
- my_bool m_discarded;
/** Locked time. */
ulonglong m_lock_time;
/** Rows sent. */
@@ -801,31 +781,27 @@ struct PSI_statement_locker_state_v1
/** Rows examined. */
ulonglong m_rows_examined;
/** Metric, temporary tables created on disk. */
- ulonglong m_created_tmp_disk_tables;
+ ulong m_created_tmp_disk_tables;
/** Metric, temporary tables created. */
- ulonglong m_created_tmp_tables;
+ ulong m_created_tmp_tables;
/** Metric, number of select full join. */
- ulonglong m_select_full_join;
+ ulong m_select_full_join;
/** Metric, number of select full range join. */
- ulonglong m_select_full_range_join;
+ ulong m_select_full_range_join;
/** Metric, number of select range. */
- ulonglong m_select_range;
+ ulong m_select_range;
/** Metric, number of select range check. */
- ulonglong m_select_range_check;
+ ulong m_select_range_check;
/** Metric, number of select scan. */
- ulonglong m_select_scan;
+ ulong m_select_scan;
/** Metric, number of sort merge passes. */
- ulonglong m_sort_merge_passes;
+ ulong m_sort_merge_passes;
/** Metric, number of sort merge. */
- ulonglong m_sort_range;
+ ulong m_sort_range;
/** Metric, number of sort rows. */
- ulonglong m_sort_rows;
+ ulong m_sort_rows;
/** Metric, number of sort scans. */
- ulonglong m_sort_scan;
- /** Metric, number of no index used. */
- ulonglong m_no_index_used;
- /** Metric, number of no good index used. */
- ulonglong m_no_good_index_used;
+ ulong m_sort_scan;
};
/* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */
=== modified file 'include/mysql/psi/psi_abi_v1.h.pp'
--- a/include/mysql/psi/psi_abi_v1.h.pp 2011-05-04 21:19:21 +0000
+++ b/include/mysql/psi/psi_abi_v1.h.pp 2011-06-09 08:37:11 +0000
@@ -119,94 +119,82 @@ struct PSI_statement_info_v1
struct PSI_mutex_locker_state_v1
{
uint m_flags;
+ enum PSI_mutex_operation m_operation;
struct PSI_mutex *m_mutex;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
- enum PSI_mutex_operation m_operation;
- const char* m_src_file;
- int m_src_line;
void *m_wait;
};
struct PSI_rwlock_locker_state_v1
{
uint m_flags;
+ enum PSI_rwlock_operation m_operation;
struct PSI_rwlock *m_rwlock;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
- enum PSI_rwlock_operation m_operation;
- const char* m_src_file;
- int m_src_line;
void *m_wait;
};
struct PSI_cond_locker_state_v1
{
uint m_flags;
+ enum PSI_cond_operation m_operation;
struct PSI_cond *m_cond;
struct PSI_mutex *m_mutex;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
- enum PSI_cond_operation m_operation;
- const char* m_src_file;
- int m_src_line;
void *m_wait;
};
struct PSI_file_locker_state_v1
{
uint m_flags;
+ enum PSI_file_operation m_operation;
struct PSI_file *m_file;
struct PSI_thread *m_thread;
size_t m_number_of_bytes;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
- enum PSI_file_operation m_operation;
- const char* m_src_file;
- int m_src_line;
void *m_wait;
};
struct PSI_table_locker_state_v1
{
uint m_flags;
+ enum PSI_table_io_operation m_io_operation;
struct PSI_table *m_table;
struct PSI_table_share *m_table_share;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
- enum PSI_table_io_operation m_io_operation;
- uint m_index;
- const char* m_src_file;
- int m_src_line;
void *m_wait;
+ uint m_index;
};
struct PSI_statement_locker_state_v1
{
+ my_bool m_discarded;
+ uchar m_no_index_used;
+ uchar m_no_good_index_used;
uint m_flags;
void *m_class;
struct PSI_thread *m_thread;
ulonglong m_timer_start;
ulonglong (*m_timer)(void);
- const char* m_src_file;
- int m_src_line;
void *m_statement;
- my_bool m_discarded;
ulonglong m_lock_time;
ulonglong m_rows_sent;
ulonglong m_rows_examined;
- ulonglong m_created_tmp_disk_tables;
- ulonglong m_created_tmp_tables;
- ulonglong m_select_full_join;
- ulonglong m_select_full_range_join;
- ulonglong m_select_range;
- ulonglong m_select_range_check;
- ulonglong m_select_scan;
- ulonglong m_sort_merge_passes;
- ulonglong m_sort_range;
- ulonglong m_sort_rows;
- ulonglong m_sort_scan;
- ulonglong m_no_index_used;
- ulonglong m_no_good_index_used;
+ ulong m_created_tmp_disk_tables;
+ ulong m_created_tmp_tables;
+ ulong m_select_full_join;
+ ulong m_select_full_range_join;
+ ulong m_select_range;
+ ulong m_select_range_check;
+ ulong m_select_scan;
+ ulong m_sort_merge_passes;
+ ulong m_sort_range;
+ ulong m_sort_rows;
+ ulong m_sort_scan;
};
typedef void (*register_mutex_v1_t)
(const char *category, struct PSI_mutex_info_v1 *info, int count);
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2011-06-06 20:07:48 +0000
+++ b/storage/perfschema/pfs.cc 2011-06-09 08:37:11 +0000
@@ -2197,7 +2197,6 @@ pfs_get_thread_mutex_locker_v1(PSI_mutex
/*
Complete shortcut.
*/
- PFS_mutex *pfs_mutex= reinterpret_cast<PFS_mutex *> (mutex);
/* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
pfs_mutex->m_wait_stat.aggregate_counted();
return NULL;
@@ -2291,7 +2290,6 @@ pfs_get_thread_rwlock_locker_v1(PSI_rwlo
/*
Complete shortcut.
*/
- PFS_rwlock *pfs_rwlock= reinterpret_cast<PFS_rwlock *> (rwlock);
/* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
pfs_rwlock->m_wait_stat.aggregate_counted();
return NULL;
@@ -2399,7 +2397,6 @@ pfs_get_thread_cond_locker_v1(PSI_cond_l
/*
Complete shortcut.
*/
- PFS_cond *pfs_cond= reinterpret_cast<PFS_cond *> (cond);
/* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
pfs_cond->m_wait_stat.aggregate_counted();
return NULL;
=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h 2011-06-06 20:07:48 +0000
+++ b/storage/perfschema/pfs_instr.h 2011-06-09 08:37:11 +0000
@@ -291,6 +291,12 @@ struct PFS_thread : PFS_connection_slice
{
static PFS_thread* get_current_thread(void);
+ /** Thread instrumentation flag. */
+ bool m_enabled;
+ /** Size of @c m_events_waits_stack. */
+ uint m_events_waits_count;
+ /** Event ID counter */
+ ulonglong m_event_id;
/** Internal lock. */
pfs_lock m_lock;
/** Pins for filename_hash. */
@@ -301,10 +307,6 @@ struct PFS_thread : PFS_connection_slice
LF_PINS *m_setup_actor_hash_pins;
/** Pins for setup_object_hash. */
LF_PINS *m_setup_object_hash_pins;
- /** Event ID counter */
- ulonglong m_event_id;
- /** Thread instrumentation flag. */
- bool m_enabled;
/** Internal thread identifier, unique. */
ulong m_thread_internal_id;
/** Parent internal thread identifier. */
@@ -313,8 +315,6 @@ struct PFS_thread : PFS_connection_slice
ulong m_thread_id;
/** Thread class. */
PFS_thread_class *m_class;
- /** Size of @c m_events_waits_stack. */
- uint m_events_waits_count;
/**
Stack of events waits.
This member holds the data for the table PERFORMANCE_SCHEMA.EVENTS_WAITS_CURRENT.
=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc 2011-05-17 13:51:11 +0000
+++ b/storage/perfschema/pfs_instr_class.cc 2011-06-09 08:37:11 +0000
@@ -640,7 +640,6 @@ PFS_sync_key register_mutex_class(const
entry= &mutex_class_array[index];
init_instr_class(entry, name, name_length, flags);
entry->m_lock_stat.reset();
- entry->m_index= index;
entry->m_event_name_index= mutex_class_start + index;
entry->m_singleton= NULL;
/*
@@ -702,7 +701,6 @@ PFS_sync_key register_rwlock_class(const
init_instr_class(entry, name, name_length, flags);
entry->m_read_lock_stat.reset();
entry->m_write_lock_stat.reset();
- entry->m_index= index;
entry->m_event_name_index= rwlock_class_start + index;
entry->m_singleton= NULL;
PFS_atomic::add_u32(&rwlock_class_allocated_count, 1);
@@ -736,7 +734,6 @@ PFS_sync_key register_cond_class(const c
{
entry= &cond_class_array[index];
init_instr_class(entry, name, name_length, flags);
- entry->m_index= index;
entry->m_event_name_index= cond_class_start + index;
entry->m_singleton= NULL;
PFS_atomic::add_u32(&cond_class_allocated_count, 1);
@@ -878,7 +875,6 @@ PFS_file_key register_file_class(const c
{
entry= &file_class_array[index];
init_instr_class(entry, name, name_length, flags);
- entry->m_index= index;
entry->m_event_name_index= file_class_start + index;
entry->m_singleton= NULL;
PFS_atomic::add_u32(&file_class_allocated_count, 1);
@@ -912,7 +908,6 @@ PFS_stage_key register_stage_class(const
{
entry= &stage_class_array[index];
init_instr_class(entry, name, name_length, flags);
- entry->m_index= index;
entry->m_event_name_index= index;
PFS_atomic::add_u32(&stage_class_allocated_count, 1);
@@ -946,7 +941,6 @@ PFS_statement_key register_statement_cla
{
entry= &statement_class_array[index];
init_instr_class(entry, name, name_length, flags);
- entry->m_index= index;
entry->m_event_name_index= index;
PFS_atomic::add_u32(&statement_class_allocated_count, 1);
=== modified file 'storage/perfschema/pfs_instr_class.h'
--- a/storage/perfschema/pfs_instr_class.h 2011-05-13 13:44:31 +0000
+++ b/storage/perfschema/pfs_instr_class.h 2011-06-09 08:37:11 +0000
@@ -76,16 +76,12 @@ extern uint wait_class_max;
/** Information for all instrumentation. */
struct PFS_instr_class
{
- /** Instrument name. */
- char m_name[PFS_MAX_INFO_NAME_LENGTH];
- /** Length in bytes of @c m_name. */
- uint m_name_length;
- /** Instrument flags. */
- int m_flags;
/** True if this instrument is enabled. */
bool m_enabled;
/** True if this instrument is timed. */
bool m_timed;
+ /** Instrument flags. */
+ int m_flags;
/**
Instrument name index.
Self index in:
@@ -94,6 +90,10 @@ struct PFS_instr_class
- EVENTS_STATEMENTS_SUMMARY_*_BY_EVENT_NAME for statements
*/
uint m_event_name_index;
+ /** Instrument name. */
+ char m_name[PFS_MAX_INFO_NAME_LENGTH];
+ /** Length in bytes of @c m_name. */
+ uint m_name_length;
bool is_singleton() const
{
@@ -114,8 +114,6 @@ struct PFS_mutex_class : public PFS_inst
This statistic is not exposed in user visible tables yet.
*/
PFS_single_stat m_lock_stat;
- /** Self index in @c mutex_class_array. */
- uint m_index;
/** Singleton instance. */
PFS_mutex *m_singleton;
};
@@ -135,8 +133,6 @@ struct PFS_rwlock_class : public PFS_ins
This statistic is not exposed in user visible tables yet.
*/
PFS_single_stat m_write_lock_stat;
- /** Self index in @c rwlock_class_array. */
- uint m_index;
/** Singleton instance. */
PFS_rwlock *m_singleton;
};
@@ -151,8 +147,6 @@ struct PFS_cond_class : public PFS_instr
This statistic is not exposed in user visible tables yet.
*/
PFS_cond_stat m_cond_stat;
- /** Self index in @c cond_class_array. */
- uint m_index;
/** Singleton instance. */
PFS_cond *m_singleton;
};
@@ -160,14 +154,14 @@ struct PFS_cond_class : public PFS_instr
/** Instrumentation metadata of a thread. */
struct PFS_thread_class
{
- /** Thread instrument name. */
- char m_name[PFS_MAX_INFO_NAME_LENGTH];
- /** Length in bytes of @c m_name. */
- uint m_name_length;
/** True if this thread instrument is enabled. */
bool m_enabled;
/** Singleton instance. */
PFS_thread *m_singleton;
+ /** Thread instrument name. */
+ char m_name[PFS_MAX_INFO_NAME_LENGTH];
+ /** Length in bytes of @c m_name. */
+ uint m_name_length;
};
/** Key identifying a table share. */
@@ -248,6 +242,14 @@ public:
uint m_setup_objects_version;
/** Internal lock. */
pfs_lock m_lock;
+ /** True if table io instrumentation is enabled. */
+ bool m_io_enabled;
+ /** True if table lock instrumentation is enabled. */
+ bool m_lock_enabled;
+ /** True if table io instrumentation is timed. */
+ bool m_io_timed;
+ /** True if table lock instrumentation is timed. */
+ bool m_lock_timed;
/** Search key. */
PFS_table_share_key m_key;
/** Schema name. */
@@ -258,18 +260,10 @@ public:
const char *m_table_name;
/** Length in bytes of @c m_table_name. */
uint m_table_name_length;
- /** True if table io instrumentation is enabled. */
- bool m_io_enabled;
- /** True if table lock instrumentation is enabled. */
- bool m_lock_enabled;
- /** True if table io instrumentation is timed. */
- bool m_io_timed;
- /** True if table lock instrumentation is timed. */
- bool m_lock_timed;
- /** Table statistics. */
- PFS_table_stat m_table_stat;
/** Number of indexes. */
uint m_key_count;
+ /** Table statistics. */
+ PFS_table_stat m_table_stat;
/** Index names. */
PFS_table_key m_keys[MAX_KEY];
@@ -297,8 +291,6 @@ struct PFS_file_class : public PFS_instr
{
/** File usage statistics. */
PFS_file_stat m_file_stat;
- /** Self index in @c file_class_array. */
- uint m_index;
/** Singleton instance. */
PFS_file *m_singleton;
};
@@ -308,15 +300,11 @@ struct PFS_stage_class : public PFS_inst
{
/** Stage usage statistics. */
PFS_stage_stat m_stage_stat;
- /** Self index in @c stage_class_array. */
- uint m_index;
};
/** Instrumentation metadata for a statement. */
struct PFS_statement_class : public PFS_instr_class
{
- /** Self index in @c statement_class_array. */
- uint m_index;
};
void init_event_name_sizing(const PFS_global_param *param);
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk-pfs-tuning branch (marc.alff:3381 to 3382) | Marc Alff | 9 Jun |