WL#2360: Performance Schema

Affects: Server-5.5   —   Status: Complete

Example                
-------                
                
Leaving out many details and variations, this is what might happen ...         

The DBA uses an SQL statement to "enable MUTEXES instrumentation".
This statement requires special privileges because global                
monitoring has a slight impact on performance of all jobs.
MUTEXES is a class of performance events that we can monitor.
                
When a MySQL thread is about to acquire a mutex, it sets variables in       
its own area (possibly THD), including "start time" based on a        
low-overhead timer/counter.                
Whenever a thread has finished acquiring a mutex, it sets variables                
in the same structure, such as: "end time".                
                
A user says SELECT ... FROM PERFORMANCE_SCHEMA.EVENTS_WAITS_CURRENT.
The thread which is handling this knows that all PERFORMANCE_SCHEMA
information is in the memory of other threads. It scans them and makes rows:   
            
Thread ID      Event Name     Timer Wait              
---------      ----------     ----------               
1              "...mutex..."  11               
2              "...mutex..."  NULL                  /* (still waiting) */    

The HLS has the variations and some implementation details.                

Terminology: the job which sets the mutexes  is "Provider",
the job which reads PERFORMANCE_SCHEMA.EVENTS_WAITS_CURRENT
is a "Consumer".