There are several status variables associated with the Performance Schema:
mysql> SHOW STATUS LIKE 'perf%'; +-----------------------------------------------+-------+ | Variable_name | Value | +-----------------------------------------------+-------+ | Performance_schema_accounts_lost | 0 | | Performance_schema_cond_classes_lost | 0 | | Performance_schema_cond_instances_lost | 0 | | Performance_schema_digest_lost | 0 | | Performance_schema_file_classes_lost | 0 | | Performance_schema_file_handles_lost | 0 | | Performance_schema_file_instances_lost | 0 | | Performance_schema_hosts_lost | 0 | | Performance_schema_locker_lost | 0 | | Performance_schema_memory_classes_lost | 0 | | Performance_schema_metadata_lock_lost | 0 | | Performance_schema_mutex_classes_lost | 0 | | Performance_schema_mutex_instances_lost | 0 | | Performance_schema_nested_statement_lost | 0 | | Performance_schema_program_lost | 0 | | Performance_schema_rwlock_classes_lost | 0 | | Performance_schema_rwlock_instances_lost | 0 | | Performance_schema_session_connect_attrs_lost | 0 | | Performance_schema_socket_classes_lost | 0 | | Performance_schema_socket_instances_lost | 0 | | Performance_schema_stage_classes_lost | 0 | | Performance_schema_statement_classes_lost | 0 | | Performance_schema_table_handles_lost | 0 | | Performance_schema_table_instances_lost | 0 | | Performance_schema_thread_classes_lost | 0 | | Performance_schema_thread_instances_lost | 0 | | Performance_schema_users_lost | 0 | +-----------------------------------------------+-------+
The Performance Schema status variables provide information about instrumentation that could not be loaded or created due to memory constraints. Names for these variables have several forms:
Performance_schema_indicates how many instruments of type
xxxcould not be loaded.
Performance_schema_indicates how many instances of object type
xxxcould not be created.
Performance_schema_indicates how many instances of object type
xxxcould not be opened.
Performance_schema_locker_lostindicates how many events are “lost” or not recorded.
For example, if a mutex is instrumented in the server source but
the server cannot allocate memory for the instrumentation at
runtime, it increments
The mutex still functions as a synchronization object (that is,
the server continues to function normally), but performance data
for it is not collected. If the instrument can be allocated, it
can be used for initializing instrumented mutex instances. For a
singleton mutex such as a global mutex, there is only one
instance. Other mutexes have an instance per connection, or per
page in various caches and data buffers, so the number of
instances varies over time. Increasing the maximum number of
connections or the maximum size of some buffers increases the
maximum number of instances that might be allocated at once. If
the server cannot create a given instrumented mutex instance, it
Suppose that the following conditions hold:
The server was started with the
--performance_schema_max_mutex_classes=200option and thus has room for 200 mutex instruments.
150 mutex instruments have been loaded already.
The plugin named
plugin_acontains 40 mutex instruments.
The plugin named
plugin_bcontains 20 mutex instruments.
The server allocates mutex instruments for the plugins depending on how many they need and how many are available, as illustrated by the following sequence of statements:
INSTALL PLUGIN plugin_a
The server now has 150+40 = 190 mutex instruments.
UNINSTALL PLUGIN plugin_a;
The server still has 190 instruments. All the historical data generated by the plugin code is still available, but new events for the instruments are not collected.
INSTALL PLUGIN plugin_a;
The server detects that the 40 instruments are already defined, so no new instruments are created, and previously assigned internal memory buffers are reused. The server still has 190 instruments.
INSTALL PLUGIN plugin_b;
The server has room for 200-190 = 10 instruments (in this case,
mutex classes), and sees that the plugin contains 20 new
instruments. 10 instruments are loaded, and 10 are discarded or
indicates the number of instruments (mutex classes) lost:
mysql> SHOW STATUS LIKE "perf%mutex_classes_lost"; +---------------------------------------+-------+ | Variable_name | Value | +---------------------------------------+-------+ | Performance_schema_mutex_classes_lost | 10 | +---------------------------------------+-------+ 1 row in set (0.10 sec)
The instrumentation still works and collects (partial) data for
When the server cannot create a mutex instrument, these results occur:
The pattern just described applies to all types of instruments, not just mutexes.
A value of
greater than 0 can happen in two cases:
To save a few bytes of memory, you start the server with
Nis less than the default value. The default value is chosen to be sufficient to load all the plugins provided in the MySQL distribution, but this can be reduced if some plugins are never loaded. For example, you might choose not to load some of the storage engines in the distribution.
You load a third-party plugin that is instrumented for the Performance Schema but do not allow for the plugin's instrumentation memory requirements when you start the server. Because it comes from a third party, the instrument memory consumption of this engine is not accounted for in the default value chosen for
If the server has insufficient resources for the plugin's instruments and you do not explicitly allocate more using
--performance_schema_max_mutex_classes=, loading the plugin leads to starvation of instruments.
If the value chosen for
is too small, no error is reported in the error log and there is
no failure at runtime. However, the content of the tables in the
performance_schema database misses events. The
status variable is the only visible sign to indicate that some
events were dropped internally due to failure to create
If an instrument is not lost, it is known to the Performance
Schema, and is used when instrumenting instances. For example,
wait/synch/mutex/sql/LOCK_delete is the name of
a mutex instrument in the
setup_instruments table. This single
instrument is used when creating a mutex in the code (in
THD::LOCK_delete) however many instances of the
mutex are needed as the server runs. In this case,
LOCK_delete is a mutex that is per connection
THD), so if a server has 1000 connections,
there are 1000 threads, and 1000 instrumented
LOCK_delete mutex instances
If the server does not have room for all these 1000 instrumented
mutexes (instances), some mutexes are created with
instrumentation, and some are created without instrumentation. If
the server can create only 800 instances, 200 instances are lost.
The server continues to run, but increments
by 200 to indicate that instances could not be created.
The bottom line is that if
SHOW STATUS LIKE
'perf%' says that nothing was lost (all values are
zero), the Performance Schema data is accurate and can be relied
upon. If something was lost, the data is incomplete, and the
Performance Schema could not record everything given the
insufficient amount of memory it was given to use. In this case,
variable indicates the problem area.
It might be appropriate in some cases to cause deliberate instrument starvation. For example, if you do not care about performance data for file I/O, you can start the server with all Performance Schema parameters related to file I/O set to 0. No memory is allocated for file-related classes, instances, or handles, and all file events are lost.
PERFORMANCE_SCHEMA STATUS to inspect the internal
operation of the Performance Schema code:
mysql> SHOW ENGINE PERFORMANCE_SCHEMA STATUS\G ... *************************** 3. row *************************** Type: performance_schema Name: events_waits_history.size Status: 76 *************************** 4. row *************************** Type: performance_schema Name: events_waits_history.count Status: 10000 *************************** 5. row *************************** Type: performance_schema Name: events_waits_history.memory Status: 760000 ... *************************** 57. row *************************** Type: performance_schema Name: performance_schema.memory Status: 26459600 ...
This statement is intended to help the DBA understand the effects that different Performance Schema options have on memory requirements. For a description of the field meanings, see Section 18.104.22.168, “SHOW ENGINE Statement”.