diff options
author | Marc Alff <marc.alff@oracle.com> | 2010-07-09 17:00:24 -0600 |
---|---|---|
committer | Marc Alff <marc.alff@oracle.com> | 2010-07-09 17:00:24 -0600 |
commit | 6090cbe552118f2c17e51d3859ca84119fa46755 (patch) | |
tree | be615d5caa61d6f096f4fc96df6c5a56e956fb11 /include/mysql/psi/psi.h | |
parent | a10ae35328ec800eff63c0bbb06d279e44c0a5a1 (diff) | |
download | mariadb-git-6090cbe552118f2c17e51d3859ca84119fa46755.tar.gz |
Bug#55087 Performance schema: optimization of the instrumentation interface
This change is for performance optimization.
Fixed the performance schema instrumentation interface as follows:
- simplified mysql_unlock_mutex()
- simplified mysql_unlock_rwlock()
- simplified mysql_cond_signal()
- simplified mysql_cond_broadcast()
Changed the get_thread_XXX_locker apis to have one extra parameter,
to provide memory to the instrumentation implementation.
This API change allows to use memory provided by the caller,
to avoid having to use thread local storage.
Using this extra parameter will be done in a separate fix,
this change is for the interface only.
Adjusted all the code and unit tests accordingly.
Diffstat (limited to 'include/mysql/psi/psi.h')
-rw-r--r-- | include/mysql/psi/psi.h | 251 |
1 files changed, 236 insertions, 15 deletions
diff --git a/include/mysql/psi/psi.h b/include/mysql/psi/psi.h index 1cab6c3a11a..562e4a80fd5 100644 --- a/include/mysql/psi/psi.h +++ b/include/mysql/psi/psi.h @@ -422,6 +422,175 @@ struct PSI_file_info_v1 int m_flags; }; +/** + State data storage for @c get_thread_mutex_locker_v1_t. + This structure provide temporary storage to a mutex locker. + The content of this structure is considered opaque, + the fields are only hints of what an implementation + of the psi interface can use. + This memory is provided by the instrumented code for performance reasons. + @sa get_thread_mutex_locker_v1_t +*/ +struct PSI_mutex_locker_state_v1 +{ + /** Internal state. */ + uint m_flags; + /** Current mutex. */ + struct PSI_mutex *m_mutex; + /** Current thread. */ + struct PSI_thread *m_thread; + /** Timer start. */ + 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; +}; + +/** + State data storage for @c get_thread_rwlock_locker_v1_t. + This structure provide temporary storage to a rwlock locker. + The content of this structure is considered opaque, + the fields are only hints of what an implementation + of the psi interface can use. + This memory is provided by the instrumented code for performance reasons. + @sa get_thread_rwlock_locker_v1_t +*/ +struct PSI_rwlock_locker_state_v1 +{ + /** Internal state. */ + uint m_flags; + /** Current rwlock. */ + struct PSI_rwlock *m_rwlock; + /** Current thread. */ + struct PSI_thread *m_thread; + /** Timer start. */ + 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; +}; + +/** + State data storage for @c get_thread_cond_locker_v1_t. + This structure provide temporary storage to a condition locker. + The content of this structure is considered opaque, + the fields are only hints of what an implementation + of the psi interface can use. + This memory is provided by the instrumented code for performance reasons. + @sa get_thread_cond_locker_v1_t +*/ +struct PSI_cond_locker_state_v1 +{ + /** Internal state. */ + uint m_flags; + /** Current condition. */ + struct PSI_cond *m_cond; + /** Current mutex. */ + struct PSI_mutex *m_mutex; + /** Current thread. */ + struct PSI_thread *m_thread; + /** Timer start. */ + 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; +}; + +/** + State data storage for @c get_thread_file_name_locker_v1_t. + This structure provide temporary storage to a file locker. + The content of this structure is considered opaque, + the fields are only hints of what an implementation + of the psi interface can use. + This memory is provided by the instrumented code for performance reasons. + @sa get_thread_file_name_locker_v1_t + @sa get_thread_file_stream_locker_v1_t + @sa get_thread_file_descriptor_locker_v1_t +*/ +struct PSI_file_locker_state_v1 +{ + /** Internal state. */ + uint m_flags; + /** Current file. */ + struct PSI_file *m_file; + /** Current thread. */ + struct PSI_thread *m_thread; + /** Operation number of bytes. */ + size_t m_number_of_bytes; + /** Timer start. */ + 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; +}; + +/** + State data storage for @c get_thread_table_locker_v1_t. + This structure provide temporary storage to a table locker. + The content of this structure is considered opaque, + the fields are only hints of what an implementation + of the psi interface can use. + This memory is provided by the instrumented code for performance reasons. + @sa get_thread_table_locker_v1_t +*/ +struct PSI_table_locker_state_v1 +{ + /** Internal state. */ + uint m_flags; + /** Current table handle. */ + struct PSI_table *m_table; + /** Current table share. */ + struct PSI_table_share *m_table_share; + /** Instrumentation class. */ + void *m_class; + /** Current thread. */ + struct PSI_thread *m_thread; + /** Timer start. */ + ulonglong m_timer_start; + /** Timer function. */ + ulonglong (*m_timer)(void); + /* Current operation (waiting for WL#4895). */ + /* enum PSI_table_operation m_operation; */ + /** Current table io index. */ + uint m_index; + /** Current table lock index. */ + uint m_lock_index; + /** Source file. */ + const char* m_src_file; + /** Source line number. */ + int m_src_line; + /** Internal data. */ + void *m_wait; +}; + /* Using typedef to make reuse between PSI_v1 and PSI_v2 easier later. */ /** @@ -619,40 +788,51 @@ typedef void (*delete_thread_v1_t)(struct PSI_thread *thread); /** Get a mutex instrumentation locker. + @param state data storage for the locker @param mutex the instrumented mutex to lock @return a mutex locker, or NULL */ typedef struct PSI_mutex_locker* (*get_thread_mutex_locker_v1_t) - (struct PSI_mutex *mutex, enum PSI_mutex_operation op); + (struct PSI_mutex_locker_state_v1 *state, + struct PSI_mutex *mutex, + enum PSI_mutex_operation op); /** Get a rwlock instrumentation locker. + @param state data storage for the locker @param rwlock the instrumented rwlock to lock @return a rwlock locker, or NULL */ typedef struct PSI_rwlock_locker* (*get_thread_rwlock_locker_v1_t) - (struct PSI_rwlock *rwlock, enum PSI_rwlock_operation op); + (struct PSI_rwlock_locker_state_v1 *state, + struct PSI_rwlock *rwlock, + enum PSI_rwlock_operation op); /** Get a cond instrumentation locker. + @param state data storage for the locker @param cond the instrumented condition to wait on @param mutex the instrumented mutex associated with the condition @return a condition locker, or NULL */ typedef struct PSI_cond_locker* (*get_thread_cond_locker_v1_t) - (struct PSI_cond *cond, struct PSI_mutex *mutex, + (struct PSI_cond_locker_state_v1 *state, + struct PSI_cond *cond, struct PSI_mutex *mutex, enum PSI_cond_operation op); /** Get a table instrumentation locker. + @param state data storage for the locker @param table the instrumented table to lock @return a table locker, or NULL */ typedef struct PSI_table_locker* (*get_thread_table_locker_v1_t) - (struct PSI_table *table); + (struct PSI_table_locker_state_v1 *state, + struct PSI_table *table); /** Get a file instrumentation locker, for opening or creating a file. + @param state data storage for the locker @param key the file instrumentation key @param op the operation to perform @param name the file name @@ -660,58 +840,59 @@ typedef struct PSI_table_locker* (*get_thread_table_locker_v1_t) @return a file locker, or NULL */ typedef struct PSI_file_locker* (*get_thread_file_name_locker_v1_t) - (PSI_file_key key, enum PSI_file_operation op, const char *name, + (struct PSI_file_locker_state_v1 *state, + PSI_file_key key, enum PSI_file_operation op, const char *name, const void *identity); /** Get a file stream instrumentation locker. + @param state data storage for the locker @param file the file stream to access @param op the operation to perform @return a file locker, or NULL */ typedef struct PSI_file_locker* (*get_thread_file_stream_locker_v1_t) - (struct PSI_file *file, enum PSI_file_operation op); + (struct PSI_file_locker_state_v1 *state, + struct PSI_file *file, enum PSI_file_operation op); /** Get a file instrumentation locker. + @param state data storage for the locker @param file the file descriptor to access @param op the operation to perform @return a file locker, or NULL */ typedef struct PSI_file_locker* (*get_thread_file_descriptor_locker_v1_t) - (File file, enum PSI_file_operation op); + (struct PSI_file_locker_state_v1 *state, + File file, enum PSI_file_operation op); /** Record a mutex instrumentation unlock event. - @param thread the running thread instrumentation @param mutex the mutex instrumentation */ typedef void (*unlock_mutex_v1_t) - (struct PSI_thread *thread, struct PSI_mutex *mutex); + (struct PSI_mutex *mutex); /** Record a rwlock instrumentation unlock event. - @param thread the running thread instrumentation @param rwlock the rwlock instrumentation */ typedef void (*unlock_rwlock_v1_t) - (struct PSI_thread *thread, struct PSI_rwlock *rwlock); + (struct PSI_rwlock *rwlock); /** Record a condition instrumentation signal event. - @param thread the running thread instrumentation @param cond the cond instrumentation */ typedef void (*signal_cond_v1_t) - (struct PSI_thread *thread, struct PSI_cond *cond); + (struct PSI_cond *cond); /** Record a condition instrumentation broadcast event. - @param thread the running thread instrumentation @param cond the cond instrumentation */ typedef void (*broadcast_cond_v1_t) - (struct PSI_thread *thread, struct PSI_cond *cond); + (struct PSI_cond *cond); /** Record a mutex instrumentation wait start event. @@ -1013,6 +1194,36 @@ struct PSI_file_info_v2 int placeholder; }; +struct PSI_mutex_locker_state_v2 +{ + /** Placeholder */ + int placeholder; +}; + +struct PSI_rwlock_locker_state_v2 +{ + /** Placeholder */ + int placeholder; +}; + +struct PSI_cond_locker_state_v2 +{ + /** Placeholder */ + int placeholder; +}; + +struct PSI_file_locker_state_v2 +{ + /** Placeholder */ + int placeholder; +}; + +struct PSI_table_locker_state_v2 +{ + /** Placeholder */ + int placeholder; +}; + /** @} (end of group Group_PSI_v2) */ #endif /* HAVE_PSI_2 */ @@ -1056,6 +1267,11 @@ typedef struct PSI_rwlock_info_v1 PSI_rwlock_info; typedef struct PSI_cond_info_v1 PSI_cond_info; typedef struct PSI_thread_info_v1 PSI_thread_info; typedef struct PSI_file_info_v1 PSI_file_info; +typedef struct PSI_mutex_locker_state_v1 PSI_mutex_locker_state; +typedef struct PSI_rwlock_locker_state_v1 PSI_rwlock_locker_state; +typedef struct PSI_cond_locker_state_v1 PSI_cond_locker_state; +typedef struct PSI_file_locker_state_v1 PSI_file_locker_state; +typedef struct PSI_table_locker_state_v1 PSI_table_locker_state; #endif #ifdef USE_PSI_2 @@ -1065,6 +1281,11 @@ typedef struct PSI_rwlock_info_v2 PSI_rwlock_info; typedef struct PSI_cond_info_v2 PSI_cond_info; typedef struct PSI_thread_info_v2 PSI_thread_info; typedef struct PSI_file_info_v2 PSI_file_info; +typedef struct PSI_mutex_locker_state_v2 PSI_mutex_locker_state; +typedef struct PSI_rwlock_locker_state_v2 PSI_rwlock_locker_state; +typedef struct PSI_cond_locker_state_v2 PSI_cond_locker_state; +typedef struct PSI_file_locker_state_v2 PSI_file_locker_state; +typedef struct PSI_table_locker_state_v2 PSI_table_locker_state; #endif #else /* HAVE_PSI_INTERFACE */ |