Commit 25cc5e6b authored by jyang's avatar jyang

branches/innodb+: Add support that individual mutex/rwlock can

be excluded from performance schema instrumentation. Exclude
buffer block mutex/rwlock from performance schema instrumentation
by default.
parent dd5cf4b1
......@@ -287,6 +287,24 @@ UNIV_INTERN mysql_pfs_key_t flush_list_mutex_key;
UNIV_INTERN mysql_pfs_key_t flush_order_mutex_key;
#endif /* UNIV_PFS_MUTEX */
#if defined UNIV_PFS_MUTEX || defined UNIV_PFS_RWLOCK
# ifndef PFS_SKIP_BUFFER_MUTEX_RWLOCK
/* Buffer block mutexes and rwlocks can be registered
in one group rather than individually. If PFS_GROUP_BUFFER_SYNC
is defined, register buffer block mutex and rwlock
in one group after their initialization. */
# define PFS_GROUP_BUFFER_SYNC
/* This define caps the number of mutexes/rwlocks can
be registered with performance schema. Developers can
modify this define if necessary. Please note, this would
be effective only if PFS_GROUP_BUFFER_SYNC is defined. */
# define PFS_MAX_BUFFER_MUTEX_LOCK_REGISTER ULINT_MAX
# endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */
#endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */
/** A chunk of buffers. The buffer pool is allocated in chunks. */
struct buf_chunk_struct{
ulint mem_size; /*!< allocated size of the chunk */
......@@ -656,6 +674,53 @@ buf_page_print(
}
#ifndef UNIV_HOTBACKUP
# ifdef PFS_GROUP_BUFFER_SYNC
/********************************************************************//**
This function registers mutexes and rwlocks in buffer blocks with
performance schema. If PFS_MAX_BUFFER_MUTEX_LOCK_REGISTER is
defined to be a value less than chunk->size, then only mutexes
and rwlocks in the first PFS_MAX_BUFFER_MUTEX_LOCK_REGISTER
blocks are registered. */
static
void
pfs_register_buffer_block(
/*======================*/
buf_chunk_t* chunk) /*!< in/out: chunk of buffers */
{
ulint i;
ulint num_to_register;
buf_block_t* block;
block = chunk->blocks;
num_to_register = ut_min(chunk->size,
PFS_MAX_BUFFER_MUTEX_LOCK_REGISTER);
for (i = 0; i < num_to_register; i++) {
mutex_t* mutex;
rw_lock_t* rwlock;
# ifdef UNIV_PFS_MUTEX
mutex = &block->mutex;
ut_a(!mutex->pfs_psi);
mutex->pfs_psi = (PSI_server)
? PSI_server->init_mutex(buffer_block_mutex_key, mutex)
: NULL;
# endif /* UNIV_PFS_MUTEX */
# ifdef UNIV_PFS_RWLOCK
rwlock = &block->lock;
ut_a(!rwlock->pfs_psi);
rwlock->pfs_psi = (PSI_server)
? PSI_server->init_rwlock(buf_block_lock_key, rwlock)
: NULL;
# endif /* UNIV_PFS_RWLOCK */
block++;
}
}
# endif /* PFS_GROUP_BUFFER_SYNC */
/********************************************************************//**
Initializes a buffer control block when the buf_pool is created. */
static
......@@ -695,10 +760,20 @@ buf_block_init(
#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */
page_zip_des_init(&block->page.zip);
mutex_create(buffer_block_mutex_key,
&block->mutex, SYNC_BUF_BLOCK);
#if defined PFS_SKIP_BUFFER_MUTEX_RWLOCK || defined PFS_GROUP_BUFFER_SYNC
/* If PFS_SKIP_BUFFER_MUTEX_RWLOCK is defined, skip registration
of buffer block mutex/rwlock with performance schema. If
PFS_GROUP_BUFFER_SYNC is defined, skip the registration
since buffer block mutex/rwlock will be registered later in
pfs_register_buffer_block() */
mutex_create(PFS_NOT_INSTRUMENTED, &block->mutex, SYNC_BUF_BLOCK);
rw_lock_create(PFS_NOT_INSTRUMENTED, &block->lock, SYNC_LEVEL_VARYING);
#else /* PFS_SKIP_BUFFER_MUTEX_RWLOCK || PFS_GROUP_BUFFER_SYNC */
mutex_create(buffer_block_mutex_key, &block->mutex, SYNC_BUF_BLOCK);
rw_lock_create(buf_block_lock_key, &block->lock, SYNC_LEVEL_VARYING);
#endif /* PFS_SKIP_BUFFER_MUTEX_RWLOCK || PFS_GROUP_BUFFER_SYNC */
ut_ad(rw_lock_validate(&(block->lock)));
#ifdef UNIV_SYNC_DEBUG
......@@ -783,6 +858,9 @@ buf_chunk_init(
frame += UNIV_PAGE_SIZE;
}
#ifdef PFS_GROUP_BUFFER_SYNC
pfs_register_buffer_block(chunk);
#endif
return(chunk);
}
......
......@@ -229,7 +229,9 @@ is defined */
static PSI_mutex_info all_innodb_mutexes[] = {
{&autoinc_mutex_key, "autoinc_mutex", 0},
{&btr_search_enabled_mutex_key, "btr_search_enabled_mutex", 0},
# ifndef PFS_SKIP_BUFFER_MUTEX_RWLOCK
{&buffer_block_mutex_key, "buffer_block_mutex", 0},
# endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */
{&buf_pool_mutex_key, "buf_pool_mutex", 0},
{&buf_pool_zip_mutex_key, "buf_pool_zip_mutex", 0},
{&cache_last_read_mutex_key, "cache_last_read_mutex", 0},
......@@ -238,6 +240,7 @@ static PSI_mutex_info all_innodb_mutexes[] = {
{&file_format_max_mutex_key, "file_format_max_mutex", 0},
{&fil_system_mutex_key, "fil_system_mutex", 0},
{&flush_list_mutex_key, "flush_list_mutex", 0},
{&flush_order_mutex_key, "flush_order_mutex", 0},
{&hash_table_mutex_key, "hash_table_mutex", 0},
{&ibuf_bitmap_mutex_key, "ibuf_bitmap_mutex", 0},
{&ibuf_mutex_key, "ibuf_mutex", 0},
......@@ -269,8 +272,7 @@ static PSI_mutex_info all_innodb_mutexes[] = {
# endif /* UNIV_SYNC_DEBUG */
{&trx_doublewrite_mutex_key, "trx_doublewrite_mutex", 0},
{&thr_local_mutex_key, "thr_local_mutex", 0},
{&trx_undo_mutex_key, "trx_undo_mutex", 0},
{&wq_mutex_key, "wq_mutex", 0}
{&trx_undo_mutex_key, "trx_undo_mutex", 0}
};
# endif /* UNIV_PFS_MUTEX */
......@@ -279,15 +281,19 @@ static PSI_mutex_info all_innodb_mutexes[] = {
performance schema instrumented if "UNIV_PFS_RWLOCK"
is defined */
static PSI_rwlock_info all_innodb_rwlocks[] = {
# ifdef UNIV_LOG_ARCHIVE
{&archive_lock_key, "archive_lock", 0},
# endif /* UNIV_LOG_ARCHIVE */
{&btr_search_latch_key, "btr_search_latch", 0},
# ifndef PFS_SKIP_BUFFER_MUTEX_RWLOCK
{&buf_block_lock_key, "buf_block_lock", 0},
# endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */
# ifdef UNIV_SYNC_DEBUG
{&buf_block_debug_latch_key, "buf_block_debug_latch", 0},
# endif /* UNIV_SYNC_DEBUG */
{&dict_operation_lock_key, "dict_operation_lock", 0},
{&fil_space_latch_key, "fil_space_latch", 0},
{&checkpoint_lock_key, "checkpoint_lock", 0},
{&archive_lock_key, "archive_lock", 0},
{&trx_i_s_cache_lock_key, "trx_i_s_cache_lock", 0},
{&trx_purge_latch_key, "trx_purge_latch", 0},
{&index_tree_rw_lock_key, "index_tree_rw_lock", 0}
......@@ -319,7 +325,6 @@ static PSI_file_info all_innodb_files[] = {
# endif /* UNIV_PFS_IO */
#endif /* HAVE_PSI_INTERFACE */
static INNOBASE_SHARE *get_share(const char *table_name);
static void free_share(INNOBASE_SHARE *share);
static int innobase_close_connection(handlerton *hton, THD* thd);
......
......@@ -108,15 +108,17 @@ extern ib_int64_t rw_x_exit_count;
#ifdef UNIV_PFS_RWLOCK
/* Following are rwlock keys used to register with MySQL
performance schema */
# ifdef UNIV_LOG_ARCHIVE
extern mysql_pfs_key_t archive_lock_key;
# endif /* UNIV_LOG_ARCHIVE */
extern mysql_pfs_key_t btr_search_latch_key;
extern mysql_pfs_key_t buf_block_lock_key;
# ifdef UNIV_SYNC_DEBUG
extern mysql_pfs_key_t buf_block_debug_latch_key;
# endif
# endif /* UNIV_SYNC_DEBUG */
extern mysql_pfs_key_t dict_operation_lock_key;
extern mysql_pfs_key_t fil_space_latch_key;
extern mysql_pfs_key_t checkpoint_lock_key;
extern mysql_pfs_key_t archive_lock_key;
extern mysql_pfs_key_t trx_i_s_cache_lock_key;
extern mysql_pfs_key_t trx_purge_latch_key;
extern mysql_pfs_key_t index_tree_rw_lock_key;
......
......@@ -633,7 +633,7 @@ UNIV_INLINE
void
pfs_rw_lock_create_func(
/*====================*/
PSI_rwlock_key key, /*!< in: key registered with
mysql_pfs_key_t key, /*!< in: key registered with
performance schema */
rw_lock_t* lock, /*!< in: pointer to memory */
# ifdef UNIV_DEBUG
......@@ -646,7 +646,7 @@ pfs_rw_lock_create_func(
ulint cline) /*!< in: file line where created */
{
/* Initialize the rwlock for performance schema */
lock->pfs_psi = PSI_server
lock->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key))
? PSI_server->init_rwlock(key, lock)
: NULL;
......
......@@ -52,6 +52,22 @@ typedef LONG lock_word_t; /*!< On Windows, InterlockedExchange operates
typedef byte lock_word_t;
#endif
#if defined UNIV_PFS_MUTEX || defined UNIV_PFS_RWLOCK
/* There are mutexes/rwlocks that we want to exclude from
instrumentation even if their corresponding performance schema
define is set. And this PFS_NOT_INSTRUMENTED is used
as the key value to dentify those objects that would
be excluded from instrumentation. */
# define PFS_NOT_INSTRUMENTED ULINT32_UNDEFINED
# define PFS_IS_INSTRUMENTED(key) ((key) != PFS_NOT_INSTRUMENTED)
/* By default, buffer mutexes and rwlocks will be excluded from
instrumentation due to their large number of instances. */
# define PFS_SKIP_BUFFER_MUTEX_RWLOCK
#endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */
#ifdef UNIV_PFS_MUTEX
/* Key defines to register InnoDB mutexes with performance schema */
extern mysql_pfs_key_t autoinc_mutex_key;
......@@ -65,6 +81,7 @@ extern mysql_pfs_key_t dict_sys_mutex_key;
extern mysql_pfs_key_t file_format_max_mutex_key;
extern mysql_pfs_key_t fil_system_mutex_key;
extern mysql_pfs_key_t flush_list_mutex_key;
extern mysql_pfs_key_t flush_order_mutex_key;
extern mysql_pfs_key_t hash_table_mutex_key;
extern mysql_pfs_key_t ibuf_bitmap_mutex_key;
extern mysql_pfs_key_t ibuf_mutex_key;
......@@ -96,7 +113,6 @@ extern mysql_pfs_key_t sync_thread_mutex_key;
extern mysql_pfs_key_t trx_doublewrite_mutex_key;
extern mysql_pfs_key_t thr_local_mutex_key;
extern mysql_pfs_key_t trx_undo_mutex_key;
extern mysql_pfs_key_t wq_mutex_key;
#endif /* UNIV_PFS_MUTEX */
/******************************************************************//**
......
......@@ -321,7 +321,7 @@ UNIV_INLINE
void
pfs_mutex_create_func(
/*==================*/
PSI_mutex_key key, /*!< in: Performance Schema key */
mysql_pfs_key_t key, /*!< in: Performance Schema key */
mutex_t* mutex, /*!< in: pointer to memory */
# ifdef UNIV_DEBUG
const char* cmutex_name, /*!< in: mutex name */
......@@ -332,7 +332,7 @@ pfs_mutex_create_func(
const char* cfile_name, /*!< in: file name where created */
ulint cline) /*!< in: file line where created */
{
mutex->pfs_psi = PSI_server
mutex->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key))
? PSI_server->init_mutex(key, mutex)
: NULL;
......
......@@ -84,7 +84,9 @@ UNIV_INTERN log_t* log_sys = NULL;
#ifdef UNIV_PFS_RWLOCK
UNIV_INTERN mysql_pfs_key_t checkpoint_lock_key;
# ifdef UNIV_LOG_ARCHIVE
UNIV_INTERN mysql_pfs_key_t archive_lock_key;
# endif
#endif /* UNIV_PFS_RWLOCK */
#ifdef UNIV_PFS_MUTEX
......
......@@ -25,11 +25,6 @@ A work queue
Created 4/26/2006 Osku Salerma
************************************************************************/
#ifdef UNIV_PFS_MUTEX
/* Key to register wq_mutex with performance schema */
UNIV_INTERN mysql_pfs_key_t wq_mutex_key;
#endif /* UNIV_PFS_MUTEX */
/****************************************************************//**
Create a new work queue.
@return work queue */
......@@ -40,7 +35,9 @@ ib_wqueue_create(void)
{
ib_wqueue_t* wq = mem_alloc(sizeof(ib_wqueue_t));
mutex_create(wq_mutex_key, &wq->mutex, SYNC_WORK_QUEUE);
/* Function ib_wqueue_create() has not been used anywhere,
not necessary to instrument this mutex */
mutex_create(PFS_NOT_INSTRUMENTED, &wq->mutex, SYNC_WORK_QUEUE);
wq->items = ib_list_create();
wq->event = os_event_create(NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment