summaryrefslogtreecommitdiff
path: root/sql/sys_vars.cc
diff options
context:
space:
mode:
authorMarc Alff <marc.alff@sun.com>2010-01-06 22:42:07 -0700
committerMarc Alff <marc.alff@sun.com>2010-01-06 22:42:07 -0700
commit3d915225611a921fad03934e58bf281b48fc15b0 (patch)
treeea8cbc9d70015a17aad75df30e7d223476eaa4da /sql/sys_vars.cc
parent4b559b912f5a3aa02a226fdacddaa3b80a8ade42 (diff)
downloadmariadb-git-3d915225611a921fad03934e58bf281b48fc15b0.tar.gz
WL#2360 Performance schema
Part IV: sql instrumentation
Diffstat (limited to 'sql/sys_vars.cc')
-rw-r--r--sql/sys_vars.cc191
1 files changed, 165 insertions, 26 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index da507edbdb4..1bac48d053f 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2006 MySQL AB, 2009 Sun Microsystems, Inc.
+/* Copyright (C) 2002-2006 MySQL AB, 2009-2010 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -34,6 +34,10 @@
#include "slave.h"
#include "rpl_mi.h"
+#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
+#include "../storage/perfschema/pfs_server.h"
+#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
+
/*
The rule for this file: everything should be 'static'. When a sys_var
variable or a function from this file is - in very rare cases - needed
@@ -42,6 +46,141 @@
*/
#define export /* not static */
+#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
+
+#define PFS_TRAILING_PROPERTIES \
+ NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), ON_UPDATE(NULL), \
+ 0, NULL, sys_var::PARSE_EARLY
+
+static Sys_var_mybool Sys_pfs_enabled(
+ "performance_schema",
+ "Enable the performance schema.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_enabled),
+ CMD_LINE(OPT_ARG), DEFAULT(FALSE),
+ PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_events_waits_history_long_size(
+ "performance_schema_events_waits_history_long_size",
+ "Number of rows in EVENTS_WAITS_HISTORY_LONG.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_events_waits_history_long_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+ DEFAULT(PFS_WAITS_HISTORY_LONG_SIZE),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_events_waits_history_size(
+ "performance_schema_events_waits_history_size",
+ "Number of rows per thread in EVENTS_WAITS_HISTORY.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_events_waits_history_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024),
+ DEFAULT(PFS_WAITS_HISTORY_SIZE),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_cond_classes(
+ "performance_schema_max_cond_classes",
+ "Maximum number of condition instruments.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_cond_class_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256),
+ DEFAULT(PFS_MAX_COND_CLASS),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_cond_instances(
+ "performance_schema_max_cond_instances",
+ "Maximum number of instrumented condition objects.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_cond_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+ DEFAULT(PFS_MAX_COND),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_file_classes(
+ "performance_schema_max_file_classes",
+ "Maximum number of file instruments.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_file_class_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256),
+ DEFAULT(PFS_MAX_FILE_CLASS),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_file_handles(
+ "performance_schema_max_file_handles",
+ "Maximum number of opened instrumented files.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_file_handle_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+ DEFAULT(PFS_MAX_FILE_HANDLE),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_file_instances(
+ "performance_schema_max_file_instances",
+ "Maximum number of instrumented files.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_file_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+ DEFAULT(PFS_MAX_FILE),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_mutex_classes(
+ "performance_schema_max_mutex_classes",
+ "Maximum number of mutex instruments.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_mutex_class_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256),
+ DEFAULT(PFS_MAX_MUTEX_CLASS),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_mutex_instances(
+ "performance_schema_max_mutex_instances",
+ "Maximum number of instrumented MUTEX objects.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_mutex_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+ DEFAULT(PFS_MAX_MUTEX),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_rwlock_classes(
+ "performance_schema_max_rwlock_classes",
+ "Maximum number of rwlock instruments.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_rwlock_class_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256),
+ DEFAULT(PFS_MAX_RWLOCK_CLASS),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_rwlock_instances(
+ "performance_schema_max_rwlock_instances",
+ "Maximum number of instrumented RWLOCK objects.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_rwlock_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+ DEFAULT(PFS_MAX_RWLOCK),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_table_handles(
+ "performance_schema_max_table_handles",
+ "Maximum number of opened instrumented tables.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_table_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+ DEFAULT(PFS_MAX_TABLE),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_table_instances(
+ "performance_schema_max_table_instances",
+ "Maximum number of instrumented tables.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_table_share_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+ DEFAULT(PFS_MAX_TABLE_SHARE),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_thread_classes(
+ "performance_schema_max_thread_classes",
+ "Maximum number of thread instruments.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_thread_class_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 256),
+ DEFAULT(PFS_MAX_THREAD_CLASS),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+static Sys_var_ulong Sys_pfs_max_thread_instances(
+ "performance_schema_max_thread_instances",
+ "Maximum number of instrumented threads.",
+ READ_ONLY GLOBAL_VAR(pfs_param.m_thread_sizing),
+ CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+ DEFAULT(PFS_MAX_THREAD),
+ BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
+#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
+
static Sys_var_ulong Sys_auto_increment_increment(
"auto_increment_increment",
"Auto-increment columns are incremented by this",
@@ -446,7 +585,7 @@ static bool event_scheduler_check(sys_var *self, THD *thd, set_var *var)
}
static bool event_scheduler_update(sys_var *self, THD *thd, enum_var_type type)
{
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ mysql_mutex_unlock(&LOCK_global_system_variables);
/*
Events::start() is heavyweight. In particular it creates a new THD,
which takes LOCK_global_system_variables internally.
@@ -457,9 +596,9 @@ static bool event_scheduler_update(sys_var *self, THD *thd, enum_var_type type)
bool ret= Events::opt_event_scheduler == Events::EVENTS_ON
? Events::start()
: Events::stop();
- pthread_mutex_unlock(&Events::LOCK_event_metadata);
- pthread_mutex_lock(&LOCK_global_system_variables);
- pthread_mutex_lock(&Events::LOCK_event_metadata);
+ mysql_mutex_unlock(&Events::LOCK_event_metadata);
+ mysql_mutex_lock(&LOCK_global_system_variables);
+ mysql_mutex_lock(&Events::LOCK_event_metadata);
if (ret)
my_error(ER_EVENT_SET_VAR_ERROR, MYF(0));
return ret;
@@ -1217,7 +1356,7 @@ static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type)
*/
read_only= opt_readonly;
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ mysql_mutex_unlock(&LOCK_global_system_variables);
if (lock_global_read_lock(thd))
goto end_with_mutex_unlock;
@@ -1245,7 +1384,7 @@ static bool fix_read_only(sys_var *self, THD *thd, enum_var_type type)
/* Release the lock */
unlock_global_read_lock(thd);
end_with_mutex_unlock:
- pthread_mutex_lock(&LOCK_global_system_variables);
+ mysql_mutex_lock(&LOCK_global_system_variables);
end:
read_only= opt_readonly;
DBUG_RETURN(result);
@@ -2327,11 +2466,11 @@ static bool fix_log(char** logname, const char* default_logname,
return true;
}
logger.lock_exclusive();
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ mysql_mutex_unlock(&LOCK_global_system_variables);
if (enabled)
reopen(*logname);
logger.unlock();
- pthread_mutex_lock(&LOCK_global_system_variables);
+ mysql_mutex_lock(&LOCK_global_system_variables);
return false;
}
static void reopen_general_log(char* name)
@@ -2487,7 +2626,7 @@ static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type)
*newvalptr= oldval; // [de]activate_log_handler works that way (sigh)
- pthread_mutex_unlock(&LOCK_global_system_variables);
+ mysql_mutex_unlock(&LOCK_global_system_variables);
if (!newval)
{
logger.deactivate_log_handler(thd, log_type);
@@ -2495,7 +2634,7 @@ static bool fix_log_state(sys_var *self, THD *thd, enum_var_type type)
}
else
res= logger.activate_log_handler(thd, log_type);
- pthread_mutex_lock(&LOCK_global_system_variables);
+ mysql_mutex_lock(&LOCK_global_system_variables);
return res;
}
@@ -2564,7 +2703,7 @@ static Sys_var_charptr Sys_slave_load_tmpdir(
static bool fix_slave_net_timeout(sys_var *self, THD *thd, enum_var_type type)
{
- pthread_mutex_lock(&LOCK_active_mi);
+ mysql_mutex_lock(&LOCK_active_mi);
DBUG_PRINT("info", ("slave_net_timeout=%lu mi->heartbeat_period=%.3f",
slave_net_timeout,
(active_mi? active_mi->heartbeat_period : 0.0)));
@@ -2575,7 +2714,7 @@ static bool fix_slave_net_timeout(sys_var *self, THD *thd, enum_var_type type)
" exceeds the new value of `slave_net_timeout' sec."
" A sensible value for the period should be"
" less than the timeout.");
- pthread_mutex_unlock(&LOCK_active_mi);
+ mysql_mutex_unlock(&LOCK_active_mi);
return false;
}
static Sys_var_ulong Sys_slave_net_timeout(
@@ -2589,21 +2728,21 @@ static Sys_var_ulong Sys_slave_net_timeout(
static bool check_slave_skip_counter(sys_var *self, THD *thd, set_var *var)
{
bool result= false;
- pthread_mutex_lock(&LOCK_active_mi);
- pthread_mutex_lock(&active_mi->rli.run_lock);
+ mysql_mutex_lock(&LOCK_active_mi);
+ mysql_mutex_lock(&active_mi->rli.run_lock);
if (active_mi->rli.slave_running)
{
my_message(ER_SLAVE_MUST_STOP, ER(ER_SLAVE_MUST_STOP), MYF(0));
result= true;
}
- pthread_mutex_unlock(&active_mi->rli.run_lock);
- pthread_mutex_unlock(&LOCK_active_mi);
+ mysql_mutex_unlock(&active_mi->rli.run_lock);
+ mysql_mutex_unlock(&LOCK_active_mi);
return result;
}
static bool fix_slave_skip_counter(sys_var *self, THD *thd, enum_var_type type)
{
- pthread_mutex_lock(&LOCK_active_mi);
- pthread_mutex_lock(&active_mi->rli.run_lock);
+ mysql_mutex_lock(&LOCK_active_mi);
+ mysql_mutex_lock(&active_mi->rli.run_lock);
/*
The following test should normally never be true as we test this
in the check function; To be safe against multiple
@@ -2611,12 +2750,12 @@ static bool fix_slave_skip_counter(sys_var *self, THD *thd, enum_var_type type)
*/
if (!active_mi->rli.slave_running)
{
- pthread_mutex_lock(&active_mi->rli.data_lock);
+ mysql_mutex_lock(&active_mi->rli.data_lock);
active_mi->rli.slave_skip_counter= sql_slave_skip_counter;
- pthread_mutex_unlock(&active_mi->rli.data_lock);
+ mysql_mutex_unlock(&active_mi->rli.data_lock);
}
- pthread_mutex_unlock(&active_mi->rli.run_lock);
- pthread_mutex_unlock(&LOCK_active_mi);
+ mysql_mutex_unlock(&active_mi->rli.run_lock);
+ mysql_mutex_unlock(&LOCK_active_mi);
return 0;
}
static Sys_var_uint Sys_slave_skip_counter(
@@ -2708,7 +2847,7 @@ static bool check_locale(sys_var *self, THD *thd, set_var *var)
if (!locale->errmsgs->errmsgs)
{
- pthread_mutex_lock(&LOCK_error_messages);
+ mysql_mutex_lock(&LOCK_error_messages);
if (!locale->errmsgs->errmsgs &&
read_texts(ERRMSG_FILE, locale->errmsgs->language,
&locale->errmsgs->errmsgs,
@@ -2717,10 +2856,10 @@ static bool check_locale(sys_var *self, THD *thd, set_var *var)
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
"Can't process error message file for locale '%s'",
locale->name);
- pthread_mutex_unlock(&LOCK_error_messages);
+ mysql_mutex_unlock(&LOCK_error_messages);
return true;
}
- pthread_mutex_unlock(&LOCK_error_messages);
+ mysql_mutex_unlock(&LOCK_error_messages);
}
return false;
}