InnoDB Plugin  1.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
srv0mon.h File Reference
#include "univ.i"
#include "srv0mon.ic"
Include dependency graph for srv0mon.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  monitor_value_t
struct  monitor_info_t

Macros

#define MIN_RESERVED   ((mon_type_t) (IB_UINT64_MAX >> 1))
#define MAX_RESERVED   (~MIN_RESERVED)
#define MONITOR_WILDCARD_MATCH   (NUM_MONITOR + 1)
#define MONITOR_NO_MATCH   (NUM_MONITOR + 2)
#define NUM_BITS_ULINT   (sizeof(ulint) * CHAR_BIT)
#define MONITOR_ON(monitor)
#define MONITOR_OFF(monitor)
#define MONITOR_IS_ON(monitor)
#define MONITOR_FIELD(monitor, field)   (innodb_counter_value[monitor].field)
#define MONITOR_VALUE(monitor)   MONITOR_FIELD(monitor, mon_value)
#define MONITOR_MAX_VALUE(monitor)   MONITOR_FIELD(monitor, mon_max_value)
#define MONITOR_MIN_VALUE(monitor)   MONITOR_FIELD(monitor, mon_min_value)
#define MONITOR_VALUE_RESET(monitor)   MONITOR_FIELD(monitor, mon_value_reset)
#define MONITOR_MAX_VALUE_START(monitor)   MONITOR_FIELD(monitor, mon_max_value_start)
#define MONITOR_MIN_VALUE_START(monitor)   MONITOR_FIELD(monitor, mon_min_value_start)
#define MONITOR_LAST_VALUE(monitor)   MONITOR_FIELD(monitor, mon_last_value)
#define MONITOR_START_VALUE(monitor)   MONITOR_FIELD(monitor, mon_start_value)
#define MONITOR_VALUE_SINCE_START(monitor)   (MONITOR_VALUE(monitor) + MONITOR_VALUE_RESET(monitor))
#define MONITOR_STATUS(monitor)   MONITOR_FIELD(monitor, mon_status)
#define MONITOR_SET_START(monitor)
#define MONITOR_SET_OFF(monitor)
#define MONITOR_INIT_ZERO_VALUE   0
#define MONITOR_MAX_MIN_NOT_INIT(monitor)
#define MONITOR_INIT(monitor)
#define MONITOR_INC(monitor)
#define MONITOR_MUTEX_INC(mutex, monitor)
#define MONITOR_MUTEX_DEC(mutex, monitor)
#define MONITOR_ATOMIC_INC(monitor)   MONITOR_MUTEX_INC(&monitor_mutex, monitor)
#define MONITOR_ATOMIC_DEC(monitor)   MONITOR_MUTEX_DEC(&monitor_mutex, monitor)
#define MONITOR_DEC(monitor)
#define MONITOR_CHECK_DEFINED(value)   (void) 0
#define MONITOR_INC_VALUE(monitor, value)
#define MONITOR_DEC_VALUE(monitor, value)
#define MONITOR_INC_NOCHECK(monitor)
#define MONITOR_DEC_NOCHECK(monitor)
#define MONITOR_SET(monitor, value)
#define MONITOR_INC_TIME_IN_MICRO_SECS(monitor, value)
#define MONITOR_INC_VALUE_CUMULATIVE(monitor, monitor_n_calls, monitor_per_call, value)
#define MONITOR_SET_UPD_MAX_ONLY(monitor, value)
#define MONITOR_SET_SIMPLE(monitor, value)
#define MONITOR_RESET_ALL(monitor)
#define MONITOR_SAVE_START(monitor, value)
#define MONITOR_SAVE_LAST(monitor)
#define MONITOR_SET_DIFF(monitor, value)

Typedefs

typedef enum monitor_running_status monitor_running_t
typedef ib_int64_t mon_type_t

Enumerations

enum  monitor_running_status { MONITOR_STARTED = 1, MONITOR_STOPPED = 2 }
enum  monitor_type_t {
  MONITOR_NONE = 0, MONITOR_MODULE = 1, MONITOR_EXISTING = 2, MONITOR_NO_AVERAGE = 4,
  MONITOR_DISPLAY_CURRENT = 8, MONITOR_GROUP_MODULE = 16, MONITOR_DEFAULT_ON = 32, MONITOR_SET_OWNER = 64,
  MONITOR_SET_MEMBER = 128, MONITOR_HIDDEN = 256
}
enum  monitor_id_t {
  MONITOR_DEFAULT_START = 0, MONITOR_MODULE_METADATA, MONITOR_TABLE_OPEN, MONITOR_TABLE_CLOSE,
  MONITOR_TABLE_REFERENCE, MONITOR_OVLD_META_MEM_POOL, MONITOR_MODULE_LOCK, MONITOR_DEADLOCK,
  MONITOR_TIMEOUT, MONITOR_LOCKREC_WAIT, MONITOR_TABLELOCK_WAIT, MONITOR_NUM_RECLOCK_REQ,
  MONITOR_RECLOCK_CREATED, MONITOR_RECLOCK_REMOVED, MONITOR_NUM_RECLOCK, MONITOR_TABLELOCK_CREATED,
  MONITOR_TABLELOCK_REMOVED, MONITOR_NUM_TABLELOCK, MONITOR_OVLD_ROW_LOCK_CURRENT_WAIT, MONITOR_OVLD_LOCK_WAIT_TIME,
  MONITOR_OVLD_LOCK_MAX_WAIT_TIME, MONITOR_OVLD_ROW_LOCK_WAIT, MONITOR_OVLD_LOCK_AVG_WAIT_TIME, MONITOR_MODULE_BUFFER,
  MONITOR_OVLD_BUFFER_POOL_SIZE, MONITOR_OVLD_BUF_POOL_READS, MONITOR_OVLD_BUF_POOL_READ_REQUESTS, MONITOR_OVLD_BUF_POOL_WRITE_REQUEST,
  MONITOR_OVLD_BUF_POOL_WAIT_FREE, MONITOR_OVLD_BUF_POOL_READ_AHEAD, MONITOR_OVLD_BUF_POOL_READ_AHEAD_EVICTED, MONITOR_OVLD_BUF_POOL_PAGE_TOTAL,
  MONITOR_OVLD_BUF_POOL_PAGE_MISC, MONITOR_OVLD_BUF_POOL_PAGES_DATA, MONITOR_OVLD_BUF_POOL_BYTES_DATA, MONITOR_OVLD_BUF_POOL_PAGES_DIRTY,
  MONITOR_OVLD_BUF_POOL_BYTES_DIRTY, MONITOR_OVLD_BUF_POOL_PAGES_FREE, MONITOR_OVLD_PAGE_CREATED, MONITOR_OVLD_PAGES_WRITTEN,
  MONITOR_OVLD_PAGES_READ, MONITOR_OVLD_BYTE_READ, MONITOR_OVLD_BYTE_WRITTEN, MONITOR_FLUSH_BATCH_SCANNED,
  MONITOR_FLUSH_BATCH_SCANNED_NUM_CALL, MONITOR_FLUSH_BATCH_SCANNED_PER_CALL, MONITOR_FLUSH_HP_RESCAN, MONITOR_FLUSH_BATCH_TOTAL_PAGE,
  MONITOR_FLUSH_BATCH_COUNT, MONITOR_FLUSH_BATCH_PAGES, MONITOR_FLUSH_NEIGHBOR_TOTAL_PAGE, MONITOR_FLUSH_NEIGHBOR_COUNT,
  MONITOR_FLUSH_NEIGHBOR_PAGES, MONITOR_FLUSH_N_TO_FLUSH_REQUESTED, MONITOR_FLUSH_AVG_PAGE_RATE, MONITOR_FLUSH_LSN_AVG_RATE,
  MONITOR_FLUSH_PCT_FOR_DIRTY, MONITOR_FLUSH_PCT_FOR_LSN, MONITOR_FLUSH_SYNC_WAITS, MONITOR_FLUSH_ADAPTIVE_TOTAL_PAGE,
  MONITOR_FLUSH_ADAPTIVE_COUNT, MONITOR_FLUSH_ADAPTIVE_PAGES, MONITOR_FLUSH_SYNC_TOTAL_PAGE, MONITOR_FLUSH_SYNC_COUNT,
  MONITOR_FLUSH_SYNC_PAGES, MONITOR_FLUSH_BACKGROUND_TOTAL_PAGE, MONITOR_FLUSH_BACKGROUND_COUNT, MONITOR_FLUSH_BACKGROUND_PAGES,
  MONITOR_LRU_BATCH_SCANNED, MONITOR_LRU_BATCH_SCANNED_NUM_CALL, MONITOR_LRU_BATCH_SCANNED_PER_CALL, MONITOR_LRU_BATCH_TOTAL_PAGE,
  MONITOR_LRU_BATCH_COUNT, MONITOR_LRU_BATCH_PAGES, MONITOR_LRU_SINGLE_FLUSH_SCANNED, MONITOR_LRU_SINGLE_FLUSH_SCANNED_NUM_CALL,
  MONITOR_LRU_SINGLE_FLUSH_SCANNED_PER_CALL, MONITOR_LRU_SINGLE_FLUSH_FAILURE_COUNT, MONITOR_LRU_GET_FREE_SEARCH, MONITOR_LRU_SEARCH_SCANNED,
  MONITOR_LRU_SEARCH_SCANNED_NUM_CALL, MONITOR_LRU_SEARCH_SCANNED_PER_CALL, MONITOR_LRU_UNZIP_SEARCH_SCANNED, MONITOR_LRU_UNZIP_SEARCH_SCANNED_NUM_CALL,
  MONITOR_LRU_UNZIP_SEARCH_SCANNED_PER_CALL, MONITOR_MODULE_BUF_PAGE, MONITOR_INDEX_LEAF_PAGE_READ, MONITOR_INDEX_NON_LEAF_PAGE_READ,
  MONITOR_INDEX_IBUF_LEAF_PAGE_READ, MONITOR_INDEX_IBUF_NON_LEAF_PAGE_READ, MONITOR_UNDO_LOG_PAGE_READ, MONITOR_INODE_PAGE_READ,
  MONITOR_IBUF_FREELIST_PAGE_READ, MONITOR_IBUF_BITMAP_PAGE_READ, MONITOR_SYSTEM_PAGE_READ, MONITOR_TRX_SYSTEM_PAGE_READ,
  MONITOR_FSP_HDR_PAGE_READ, MONITOR_XDES_PAGE_READ, MONITOR_BLOB_PAGE_READ, MONITOR_ZBLOB_PAGE_READ,
  MONITOR_ZBLOB2_PAGE_READ, MONITOR_OTHER_PAGE_READ, MONITOR_INDEX_LEAF_PAGE_WRITTEN, MONITOR_INDEX_NON_LEAF_PAGE_WRITTEN,
  MONITOR_INDEX_IBUF_LEAF_PAGE_WRITTEN, MONITOR_INDEX_IBUF_NON_LEAF_PAGE_WRITTEN, MONITOR_UNDO_LOG_PAGE_WRITTEN, MONITOR_INODE_PAGE_WRITTEN,
  MONITOR_IBUF_FREELIST_PAGE_WRITTEN, MONITOR_IBUF_BITMAP_PAGE_WRITTEN, MONITOR_SYSTEM_PAGE_WRITTEN, MONITOR_TRX_SYSTEM_PAGE_WRITTEN,
  MONITOR_FSP_HDR_PAGE_WRITTEN, MONITOR_XDES_PAGE_WRITTEN, MONITOR_BLOB_PAGE_WRITTEN, MONITOR_ZBLOB_PAGE_WRITTEN,
  MONITOR_ZBLOB2_PAGE_WRITTEN, MONITOR_OTHER_PAGE_WRITTEN, MONITOR_MODULE_OS, MONITOR_OVLD_OS_FILE_READ,
  MONITOR_OVLD_OS_FILE_WRITE, MONITOR_OVLD_OS_FSYNC, MONITOR_OS_PENDING_READS, MONITOR_OS_PENDING_WRITES,
  MONITOR_OVLD_OS_LOG_WRITTEN, MONITOR_OVLD_OS_LOG_FSYNC, MONITOR_OVLD_OS_LOG_PENDING_FSYNC, MONITOR_OVLD_OS_LOG_PENDING_WRITES,
  MONITOR_MODULE_TRX, MONITOR_TRX_RW_COMMIT, MONITOR_TRX_RO_COMMIT, MONITOR_TRX_NL_RO_COMMIT,
  MONITOR_TRX_COMMIT_UNDO, MONITOR_TRX_ROLLBACK, MONITOR_TRX_ROLLBACK_SAVEPOINT, MONITOR_TRX_ROLLBACK_ACTIVE,
  MONITOR_TRX_ACTIVE, MONITOR_RSEG_HISTORY_LEN, MONITOR_NUM_UNDO_SLOT_USED, MONITOR_NUM_UNDO_SLOT_CACHED,
  MONITOR_RSEG_CUR_SIZE, MONITOR_MODULE_PURGE, MONITOR_N_DEL_ROW_PURGE, MONITOR_N_UPD_EXIST_EXTERN,
  MONITOR_PURGE_INVOKED, MONITOR_PURGE_N_PAGE_HANDLED, MONITOR_DML_PURGE_DELAY, MONITOR_PURGE_STOP_COUNT,
  MONITOR_PURGE_RESUME_COUNT, MONITOR_MODULE_RECOVERY, MONITOR_NUM_CHECKPOINT, MONITOR_OVLD_LSN_FLUSHDISK,
  MONITOR_OVLD_LSN_CHECKPOINT, MONITOR_OVLD_LSN_CURRENT, MONITOR_LSN_CHECKPOINT_AGE, MONITOR_OVLD_BUF_OLDEST_LSN,
  MONITOR_OVLD_MAX_AGE_ASYNC, MONITOR_OVLD_MAX_AGE_SYNC, MONITOR_PENDING_LOG_WRITE, MONITOR_PENDING_CHECKPOINT_WRITE,
  MONITOR_LOG_IO, MONITOR_OVLD_LOG_WAITS, MONITOR_OVLD_LOG_WRITE_REQUEST, MONITOR_OVLD_LOG_WRITES,
  MONITOR_MODULE_PAGE, MONITOR_PAGE_COMPRESS, MONITOR_PAGE_DECOMPRESS, MONITOR_PAD_INCREMENTS,
  MONITOR_PAD_DECREMENTS, MONITOR_MODULE_INDEX, MONITOR_INDEX_SPLIT, MONITOR_INDEX_MERGE_ATTEMPTS,
  MONITOR_INDEX_MERGE_SUCCESSFUL, MONITOR_INDEX_REORG_ATTEMPTS, MONITOR_INDEX_REORG_SUCCESSFUL, MONITOR_INDEX_DISCARD,
  MONITOR_MODULE_ADAPTIVE_HASH, MONITOR_OVLD_ADAPTIVE_HASH_SEARCH, MONITOR_OVLD_ADAPTIVE_HASH_SEARCH_BTREE, MONITOR_ADAPTIVE_HASH_PAGE_ADDED,
  MONITOR_ADAPTIVE_HASH_PAGE_REMOVED, MONITOR_ADAPTIVE_HASH_ROW_ADDED, MONITOR_ADAPTIVE_HASH_ROW_REMOVED, MONITOR_ADAPTIVE_HASH_ROW_REMOVE_NOT_FOUND,
  MONITOR_ADAPTIVE_HASH_ROW_UPDATED, MONITOR_MODULE_FIL_SYSTEM, MONITOR_OVLD_N_FILE_OPENED, MONITOR_MODULE_IBUF_SYSTEM,
  MONITOR_OVLD_IBUF_MERGE_INSERT, MONITOR_OVLD_IBUF_MERGE_DELETE, MONITOR_OVLD_IBUF_MERGE_PURGE, MONITOR_OVLD_IBUF_MERGE_DISCARD_INSERT,
  MONITOR_OVLD_IBUF_MERGE_DISCARD_DELETE, MONITOR_OVLD_IBUF_MERGE_DISCARD_PURGE, MONITOR_OVLD_IBUF_MERGES, MONITOR_OVLD_IBUF_SIZE,
  MONITOR_MODULE_SERVER, MONITOR_MASTER_THREAD_SLEEP, MONITOR_OVLD_SERVER_ACTIVITY, MONITOR_MASTER_ACTIVE_LOOPS,
  MONITOR_MASTER_IDLE_LOOPS, MONITOR_SRV_BACKGROUND_DROP_TABLE_MICROSECOND, MONITOR_SRV_IBUF_MERGE_MICROSECOND, MONITOR_SRV_LOG_FLUSH_MICROSECOND,
  MONITOR_SRV_MEM_VALIDATE_MICROSECOND, MONITOR_SRV_PURGE_MICROSECOND, MONITOR_SRV_DICT_LRU_MICROSECOND, MONITOR_SRV_CHECKPOINT_MICROSECOND,
  MONITOR_OVLD_SRV_DBLWR_WRITES, MONITOR_OVLD_SRV_DBLWR_PAGES_WRITTEN, MONITOR_OVLD_SRV_PAGE_SIZE, MONITOR_OVLD_RWLOCK_S_SPIN_WAITS,
  MONITOR_OVLD_RWLOCK_X_SPIN_WAITS, MONITOR_OVLD_RWLOCK_S_SPIN_ROUNDS, MONITOR_OVLD_RWLOCK_X_SPIN_ROUNDS, MONITOR_OVLD_RWLOCK_S_OS_WAITS,
  MONITOR_OVLD_RWLOCK_X_OS_WAITS, MONITOR_MODULE_DML_STATS, MONITOR_OLVD_ROW_READ, MONITOR_OLVD_ROW_INSERTED,
  MONITOR_OLVD_ROW_DELETED, MONITOR_OLVD_ROW_UPDTATED, MONITOR_MODULE_DDL_STATS, MONITOR_BACKGROUND_DROP_INDEX,
  MONITOR_BACKGROUND_DROP_TABLE, MONITOR_ONLINE_CREATE_INDEX, MONITOR_PENDING_ALTER_TABLE, MONITOR_MODULE_ICP,
  MONITOR_ICP_ATTEMPTS, MONITOR_ICP_NO_MATCH, MONITOR_ICP_OUT_OF_RANGE, MONITOR_ICP_MATCH,
  MONITOR_ALL_COUNTER, NUM_MONITOR
}
enum  mon_option_t {
  MONITOR_TURN_ON = 1, MONITOR_TURN_OFF, MONITOR_RESET_VALUE, MONITOR_RESET_ALL_VALUE,
  MONITOR_GET_VALUE
}

Functions

UNIV_INTERN void srv_mon_create (void)
UNIV_INTERN void srv_mon_free (void)
UNIV_INTERN monitor_info_tsrv_mon_get_info (monitor_id_t monitor_id)
UNIV_INTERN const char * srv_mon_get_name (monitor_id_t monitor_id)
UNIV_INTERN void srv_mon_set_module_control (monitor_id_t module_id, mon_option_t set_option)
UNIV_INTERN void srv_mon_process_existing_counter (monitor_id_t monitor_id, mon_option_t set_option)
UNIV_INLINE mon_type_t srv_mon_calc_max_since_start (monitor_id_t monitor)
UNIV_INLINE mon_type_t srv_mon_calc_min_since_start (monitor_id_t monitor)
UNIV_INTERN void srv_mon_reset (monitor_id_t monitor)
UNIV_INLINE void srv_mon_reset_all (monitor_id_t monitor)
UNIV_INTERN void srv_mon_default_on (void)

Variables

ulint monitor_set_tbl [(NUM_MONITOR+NUM_BITS_ULINT-1)/NUM_BITS_ULINT]
monitor_value_t innodb_counter_value [NUM_MONITOR]
ib_mutex_t monitor_mutex

Detailed Description

Server monitor counter related defines

Created 12/15/2009 Jimmy Yang

Macro Definition Documentation

#define MIN_RESERVED   ((mon_type_t) (IB_UINT64_MAX >> 1))

Counter minimum value is initialized to be max value of mon_type_t (ib_int64_t)

#define MONITOR_ATOMIC_DEC (   monitor)    MONITOR_MUTEX_DEC(&monitor_mutex, monitor)
Atomically decrement a monitor counter.

Use MONITOR_DEC if appropriate mutex protection exists.

Parameters
monitormonitor to be decremented by 1
#define MONITOR_ATOMIC_INC (   monitor)    MONITOR_MUTEX_INC(&monitor_mutex, monitor)
Atomically increment a monitor counter.

Use MONITOR_INC if appropriate mutex protection exists.

Parameters
monitormonitor to be incremented by 1
#define MONITOR_DEC (   monitor)
Value:
if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor)--; \
if (MONITOR_VALUE(monitor) < MONITOR_MIN_VALUE(monitor)) { \
MONITOR_MIN_VALUE(monitor) = MONITOR_VALUE(monitor);\
} \
}
#define MONITOR_DEC_NOCHECK (   monitor)
Value:
do { \
MONITOR_VALUE(monitor)--; \
if (MONITOR_VALUE(monitor) < MONITOR_MIN_VALUE(monitor)) { \
MONITOR_MIN_VALUE(monitor) = MONITOR_VALUE(monitor);\
} \
} while (0)
#define MONITOR_DEC_VALUE (   monitor,
  value 
)
Value:
MONITOR_CHECK_DEFINED(value); \
if (MONITOR_IS_ON(monitor)) { \
ut_ad(MONITOR_VALUE(monitor) >= (mon_type_t) (value); \
MONITOR_VALUE(monitor) -= (mon_type_t) (value); \
if (MONITOR_VALUE(monitor) < MONITOR_MIN_VALUE(monitor)) { \
MONITOR_MIN_VALUE(monitor) = MONITOR_VALUE(monitor);\
} \
}
#define MONITOR_FIELD (   monitor,
  field 
)    (innodb_counter_value[monitor].field)
Following are macro defines for basic montior counter manipulations.

Please note we do not provide any synchronization for these monitor operations due to performance consideration. Most counters can be placed under existing mutex protections in respective code module. Macros to access various fields of a monitor counters

#define MONITOR_INC (   monitor)
Value:
if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor)++; \
if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor);\
} \
}
Macros to increment/decrement the counters. The normal

monitor counter operation expects appropriate synchronization already exists. No additional mutex is necessary when operating on the counters

#define MONITOR_INC_NOCHECK (   monitor)
Value:
do { \
MONITOR_VALUE(monitor)++; \
if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor);\
} \
} while (0) \
#define MONITOR_INC_TIME_IN_MICRO_SECS (   monitor,
  value 
)
Value:
MONITOR_CHECK_DEFINED(value); \
if (MONITOR_IS_ON(monitor)) { \
ullint old_time = (value); \
value = ut_time_us(NULL); \
MONITOR_VALUE(monitor) += (mon_type_t) (value - old_time);\
}
Add time difference between now and input "value" (in seconds) to the

monitor counter

Parameters
monitormonitor to update for the time difference
valuethe start time value
#define MONITOR_INC_VALUE (   monitor,
  value 
)
Value:
MONITOR_CHECK_DEFINED(value); \
if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor) += (mon_type_t) (value); \
if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor);\
} \
}
#define MONITOR_INC_VALUE_CUMULATIVE (   monitor,
  monitor_n_calls,
  monitor_per_call,
  value 
)
Value:
MONITOR_CHECK_DEFINED(value); \
if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor_n_calls)++; \
MONITOR_VALUE(monitor_per_call) = (mon_type_t) (value); \
if (MONITOR_VALUE(monitor_per_call) \
> MONITOR_MAX_VALUE(monitor_per_call)) { \
MONITOR_MAX_VALUE(monitor_per_call) = \
(mon_type_t) (value); \
} \
MONITOR_VALUE(monitor) += (mon_type_t) (value); \
if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor);\
} \
}
This macro updates 3 counters in one call. However, it only checks the

main/first monitor counter 'monitor', to see it is on or off to decide whether to do the update.

Parameters
monitorthe main monitor counter to update. It accounts for the accumulative value for the counter.
monitor_n_callscounter that counts number of times this macro is called
monitor_per_callcounter that records the current and max value of each incremental value
valueincremental value to record this time
#define MONITOR_INIT (   monitor)
Value:
if (MONITOR_MAX_MIN_NOT_INIT(monitor)) { \
MONITOR_MIN_VALUE(monitor) = MIN_RESERVED; \
MONITOR_MIN_VALUE_START(monitor) = MIN_RESERVED; \
MONITOR_MAX_VALUE(monitor) = MAX_RESERVED; \
MONITOR_MAX_VALUE_START(monitor) = MAX_RESERVED; \
}
#define MONITOR_IS_ON (   monitor)
Value:
((ulint)1 << (monitor % NUM_BITS_ULINT)))

Check whether the requested monitor is turned on/off

#define MONITOR_MAX_MIN_NOT_INIT (   monitor)
Value:
(MONITOR_STATUS(monitor) == MONITOR_INIT_ZERO_VALUE \
&& MONITOR_MIN_VALUE(monitor) == MONITOR_INIT_ZERO_VALUE \
&& MONITOR_MAX_VALUE(monitor) == MONITOR_INIT_ZERO_VALUE)
Max and min values are initialized when we first turn on the monitor

counter, and set the MONITOR_STATUS.

#define MONITOR_MUTEX_DEC (   mutex,
  monitor 
)
Value:
ut_ad(!mutex_own(mutex)); \
if (MONITOR_IS_ON(monitor)) { \
mutex_enter(mutex); \
if (--MONITOR_VALUE(monitor) < MONITOR_MIN_VALUE(monitor)) { \
MONITOR_MIN_VALUE(monitor) = MONITOR_VALUE(monitor); \
} \
mutex_exit(mutex); \
}
Decrement a monitor counter under mutex protection.

Use MONITOR_DEC if appropriate mutex protection already exists.

Parameters
monitormonitor to be decremented by 1
mutexmutex to acquire and relese
#define MONITOR_MUTEX_INC (   mutex,
  monitor 
)
Value:
ut_ad(!mutex_own(mutex)); \
if (MONITOR_IS_ON(monitor)) { \
mutex_enter(mutex); \
if (++MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor); \
} \
mutex_exit(mutex); \
}
Increment a monitor counter under mutex protection.

Use MONITOR_INC if appropriate mutex protection already exists.

Parameters
monitormonitor to be incremented by 1
mutexmutex to acquire and relese
#define MONITOR_NO_MATCH   (NUM_MONITOR + 2)

Cannot find monitor counter with a specified name

#define MONITOR_OFF (   monitor)
Value:
~((ulint)1 << (monitor % NUM_BITS_ULINT)))
#define MONITOR_ON (   monitor)
Value:
((ulint)1 << (monitor % NUM_BITS_ULINT)))
Macros to turn on/off the control bit in monitor_set_tbl for a monitor

counter option.

#define MONITOR_RESET_ALL (   monitor)
Value:
do { \
MONITOR_VALUE(monitor) = MONITOR_INIT_ZERO_VALUE; \
MONITOR_MAX_VALUE(monitor) = MAX_RESERVED; \
MONITOR_MIN_VALUE(monitor) = MIN_RESERVED; \
MONITOR_VALUE_RESET(monitor) = MONITOR_INIT_ZERO_VALUE; \
MONITOR_MAX_VALUE_START(monitor) = MAX_RESERVED; \
MONITOR_MIN_VALUE_START(monitor) = MIN_RESERVED; \
MONITOR_LAST_VALUE(monitor) = MONITOR_INIT_ZERO_VALUE; \
MONITOR_FIELD(monitor, mon_start_time) = \
MONITOR_INIT_ZERO_VALUE; \
MONITOR_FIELD(monitor, mon_stop_time) = \
MONITOR_INIT_ZERO_VALUE; \
MONITOR_FIELD(monitor, mon_reset_time) = \
MONITOR_INIT_ZERO_VALUE; \
} while (0)
Reset the monitor value and max/min value to zero. The reset

operation would only be conducted when the counter is turned off

#define MONITOR_SAVE_LAST (   monitor)
Value:
do { \
MONITOR_LAST_VALUE(monitor) = MONITOR_VALUE(monitor); \
MONITOR_START_VALUE(monitor) += MONITOR_VALUE(monitor); \
} while (0)
Save the passed-in value to mon_last_value field of monitor

counters

#define MONITOR_SAVE_START (   monitor,
  value 
)
Value:
do { \
MONITOR_CHECK_DEFINED(value); \
(MONITOR_START_VALUE(monitor) = \
(mon_type_t) (value) - MONITOR_VALUE_RESET(monitor)); \
} while (0)
Following four macros defines necessary operations to fetch and

consolidate information from existing system status variables. Save the passed-in value to mon_start_value field of monitor counters

#define MONITOR_SET (   monitor,
  value 
)
Value:
MONITOR_CHECK_DEFINED(value); \
if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor) = (mon_type_t) (value); \
if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor);\
} \
if (MONITOR_VALUE(monitor) < MONITOR_MIN_VALUE(monitor)) { \
MONITOR_MIN_VALUE(monitor) = MONITOR_VALUE(monitor);\
} \
}

Directly set a monitor counter's value

#define MONITOR_SET_DIFF (   monitor,
  value 
)
Value:
MONITOR_SET_UPD_MAX_ONLY(monitor, ((value) \
- MONITOR_VALUE_RESET(monitor) \
- MONITOR_FIELD(monitor, mon_start_value) \
+ MONITOR_FIELD(monitor, mon_last_value)))
Set monitor value to the difference of value and mon_start_value

compensated by mon_last_value if accumulated value is required.

#define MONITOR_SET_OFF (   monitor)
Value:
do { \
MONITOR_STATUS(monitor) = MONITOR_STOPPED; \
MONITOR_FIELD((monitor), mon_stop_time) = time(NULL); \
} while (0)
#define MONITOR_SET_SIMPLE (   monitor,
  value 
)
Value:
MONITOR_CHECK_DEFINED(value); \
if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor) = (mon_type_t) (value); \
}
Some values such as log sequence number are montomically increasing

number, do not need to record max/min values

#define MONITOR_SET_START (   monitor)
Value:
do { \
MONITOR_STATUS(monitor) = MONITOR_STARTED; \
MONITOR_FIELD((monitor), mon_start_time) = time(NULL); \
} while (0)
#define MONITOR_SET_UPD_MAX_ONLY (   monitor,
  value 
)
Value:
MONITOR_CHECK_DEFINED(value); \
if (MONITOR_IS_ON(monitor)) { \
MONITOR_VALUE(monitor) = (mon_type_t) (value); \
if (MONITOR_VALUE(monitor) > MONITOR_MAX_VALUE(monitor)) { \
MONITOR_MAX_VALUE(monitor) = MONITOR_VALUE(monitor);\
} \
}
Directly set a monitor counter's value, and if the value

is monotonically increasing, only max value needs to be updated

#define MONITOR_WILDCARD_MATCH   (NUM_MONITOR + 1)
This informs the monitor control system to turn

on/off and reset monitor counters through wild card match

#define NUM_BITS_ULINT   (sizeof(ulint) * CHAR_BIT)

Number of bit in a ulint datatype

Typedef Documentation

typedef ib_int64_t mon_type_t

Monitor counter value type

Enumeration Type Documentation

Following are the "set_option" values allowed for

srv_mon_process_existing_counter() and srv_mon_process_existing_counter() functions. To turn on/off/reset the monitor counters.

Enumerator:
MONITOR_TURN_ON 

Turn on the counter

MONITOR_TURN_OFF 

Turn off the counter

MONITOR_RESET_VALUE 

Reset current values

MONITOR_RESET_ALL_VALUE 

Reset all values

MONITOR_GET_VALUE 

Option for srv_mon_process_existing_counter() function

This enumeration defines internal monitor identifier used internally

to identify each particular counter. Its value indexes into two arrays, one is the "innodb_counter_value" array which records actual monitor counter values, the other is "innodb_counter_info" array which describes each counter's basic information (name, desc etc.). A couple of naming rules here: 1) If the monitor defines a module, it starts with MONITOR_MODULE 2) If the monitor uses exisitng counters from "status variable", its ID name shall start with MONITOR_OVLD

Please refer to "innodb_counter_info" in srv/srv0mon.cc for detail information for each monitor counter

Possible status values for "mon_status" in "struct monitor_value"

Enumerator:
MONITOR_STARTED 

Monitor has been turned on

MONITOR_STOPPED 

Monitor has been turned off

Follwoing defines are possible values for "monitor_type" field in

"struct monitor_info"

Enumerator:
MONITOR_NONE 

No monitoring

MONITOR_MODULE 

This is a monitor module type, not a counter

MONITOR_EXISTING 

The monitor carries information from an existing system status variable

MONITOR_NO_AVERAGE 

Set this status if we don't want to calculate the average value for the counter

MONITOR_DISPLAY_CURRENT 

Display current value of the counter, rather than incremental value over the period. Mostly for counters displaying current resource usage

MONITOR_GROUP_MODULE 

Monitor can be turned on/off only as a module, but not individually

MONITOR_DEFAULT_ON 

Monitor will be turned on by default at server start up

MONITOR_SET_OWNER 

Owner of "monitor set", a set of monitor counters

MONITOR_SET_MEMBER 

Being part of a "monitor set"

MONITOR_HIDDEN 

Do not display this monitor in the metrics table

Function Documentation

UNIV_INLINE mon_type_t srv_mon_calc_max_since_start ( monitor_id_t  monitor)

This function is used to calculate the maximum counter value since the start of monitor counter

Returns
max counter value since start. in: monitor id

This function is used to calculate the maximum counter value since the start of monitor counter

Returns
max counter value since start.
Parameters
monitorin: monitor id
UNIV_INLINE mon_type_t srv_mon_calc_min_since_start ( monitor_id_t  monitor)

This function is used to calculate the minimum counter value since the start of monitor counter

Returns
min counter value since start. in: monitor id

This function is used to calculate the minimum counter value since the start of monitor counter

Returns
min counter value since start.
Parameters
monitorin: monitor id
UNIV_INTERN void srv_mon_create ( void  )

Initialize the monitor subsystem.

UNIV_INTERN void srv_mon_default_on ( void  )

Turn on monitor counters that are marked as default ON.

UNIV_INTERN void srv_mon_free ( void  )

Close the monitor subsystem.

UNIV_INTERN monitor_info_t* srv_mon_get_info ( monitor_id_t  monitor_id)

Get monitor's monitor_info_t by its monitor id (index into the innodb_counter_info array

Returns
Point to corresponding monitor_info_t, or NULL if no such monitor id index into the innodb_counter_info array
UNIV_INTERN const char* srv_mon_get_name ( monitor_id_t  monitor_id)

Get monitor's name by its monitor id (index into the innodb_counter_info array

Returns
corresponding monitor name, or NULL if no such monitor id index into the innodb_counter_info array
UNIV_INTERN void srv_mon_process_existing_counter ( monitor_id_t  monitor_id,
mon_option_t  set_option 
)

This function consolidates some existing server counters used by "system status variables". These existing system variables do not have mechanism to start/stop and reset the counters, so we simulate these controls by remembering the corresponding counter values when the corresponding monitors are turned on/off/reset, and do appropriate mathematics to deduct the actual value. in: Turn on/off reset the counter

Parameters
monitor_idin: the monitor's ID as in monitor_counter_id
UNIV_INTERN void srv_mon_reset ( monitor_id_t  monitor)

Reset a monitor, create a new base line with the current monitor value. This baseline is recorded by MONITOR_VALUE_RESET(monitor) in: monitor id

UNIV_INLINE void srv_mon_reset_all ( monitor_id_t  monitor)

This function resets all values of a monitor counter in: monitor id

This function resets all values of a monitor counter

Parameters
monitorin: monitor id
UNIV_INTERN void srv_mon_set_module_control ( monitor_id_t  module_id,
mon_option_t  set_option 
)

Turn on/off/reset monitor counters in a module. If module_value is NUM_MONITOR then turn on all monitor counters.

Returns
0 if successful, or the first monitor that cannot be turned on because it is already turned on. in: Turn on/off reset the counter
Parameters
module_idin: Module ID as in monitor_counter_id. If it is set to NUM_MONITOR, this means we shall turn on all the counters

Variable Documentation

monitor_value_t innodb_counter_value[NUM_MONITOR]
The actual monitor counter array that records each monintor counter

value

ib_mutex_t monitor_mutex
Mutex protecting atomic operations on platforms that lack

built-in operations for atomic memory access

ulint monitor_set_tbl[(NUM_MONITOR+NUM_BITS_ULINT-1)/NUM_BITS_ULINT]
This "monitor_set_tbl" is a bitmap records whether a particular monitor

counter has been turned on or off