WL#3249: PERFORMANCE SCHEMA, Instrument memory usage

Affects: Server-5.7   —   Status: Complete

The performance schema instruments memory usage,
and aggregates memory usage statistics detailed by:
- type of memory used (various caches, internal buffers, etc)
- thread/account/user/host indirectly performing the memory operation.

The following aspects are instrumented:
- memory sizes used
- counts of operations
- low / high water marks.

Memory sizes are important to understand / tune the memory consumption of a 
server.

Counts of operations are important to understand / tune the overall pressure the
server is putting on the memory allocator, which has an impact of performances.
Allocating 1 byte 1 million times is not the same as allocating 1 Million bytes,
and only keeping track of both counts and sizes can expose the difference.

Low and high water marks are critical to detect spikes in workload, the overall
stability of a workload, and possible leaks.

Target audience

* Production engineers

Production engineers are the primary audience for this instrumentation.

Production engineers are expected to use the memory instrumentation for:
- configuring a server,
- monitoring a server,
- capacity planning

* Server developers

Server developers are the secondary audience for this instrumentation.

Implementers of the server, for either the core server or plugins, can leverage
this instrumentation to understand the memory behavior of some code. This is
useful to evaluate different code or designs, to detect early potential
performance or consumption problems.

* Application developers

In most cases, application developers have little control on memory allocation
done inside the server itself.
Either the code is not configurable, in which case server developers are
responsible for how the code allocates memory,
or the code behavior is configurable, in which case the DBA has control on the
server with the my.cnf file.

In some cases however, in particular when some sizing parameters can be
specified by session, application developers have some control on the server
memory usage, and will benefit from this instrumentation.


User Documentation
==================

http://dev.mysql.com/doc/refman/5.7/en/memory-summary-tables.html