Bug #93281 Odd memory load/increase when using --performance-schema-max-digest-length=large
Submitted: 22 Nov 2018 4:03 Modified: 30 Nov 2018 14:26
Reporter: Roel Van de Paar Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S1 (Critical)
Version:8.0.12 OS:Any
Assigned to: CPU Architecture:Any

[22 Nov 2018 4:03] Roel Van de Paar
Description:
See Before.png and After.png attached. The server still starts, but memory use is high, apparently in all threads. Threads in the top output are sorted by PERCENT_MEM.

How to repeat:
--performance-schema-max-digest-length=1125899906842624
[22 Nov 2018 4:03] Roel Van de Paar
Before starting the server

Attachment: Before.png (image/png, text), 163.05 KiB.

[22 Nov 2018 4:03] Roel Van de Paar
After the server is started / during server startup

Attachment: After.png (image/png, text), 171.69 KiB.

[22 Nov 2018 9:38] Marc ALFF
Hi Roel,

This variable is -- per query --, not global for the server.
It is the amount of memory used for each query when storing a digest.

This:
--performance-schema-max-digest-length=1125899906842624
makes no sense, and here the value was truncated to the MAX for this variable,
which is 1048576 (1 Mib).

See the manual for this variable:
https://dev.mysql.com/doc/refman/8.0/en/performance-schema-system-variables.html#sysvar_pe...

Still with 1 Mib per query, and with a lot of queries stored in:
- each thread statement history
- the global statement history long
- the global statement digest table
this results in a huge memory consumption.

Accepting the bug as a documentation bug, because the doc is unclear,
misleading users to think this setting is a global amount of memory,
resulting in incorrect configuration.

Regards,
-- Marc Alff
[22 Nov 2018 20:32] Roel Van de Paar
Hi Marc,

Did you test it? A blank server, just init-ed, with this option, will consume a HUGE amount of memory (think 20+ GB), when started.
[30 Nov 2018 14:26] Paul DuBois
Posted by developer:
 
The variable is per session, not global to the server. Updated
https://dev.mysql.com/doc/refman/8.0/en/performance-schema-system-variables.html#sysvar_pe...
to clarify:

The maximum number of bytes of memory reserved per session for computation of normalized statement digest values in the Performance Schema.
[17 Dec 2018 23:09] Paul DuBois
Posted by developer:
 
https://dev.mysql.com/doc/refman/8.0/en/performance-schema-system-variables.html#sysvar_pe...

The maximum number of bytes of memory reserved per statement for computation of normalized statement digest values in the Performance Schema. This variable is related to max_digest_length; see the description of that variable in Section 5.1.8, “Server System Variables”

https://dev.mysql.com/doc/refman/8.0/en/performance-schema-statement-digests.html#statemen...

The performance_schema_max_digest_length setting is not per session, it is per statement, and a session can store multiple statements in the events_statements_history table. A typical number of statements in this table is 10 per session, so each session will consume 10 times the memory indicated by the performance_schema_max_digest_length value, for this table alone.

Also, there are many statements (and digests) collected globally, most notably in the events_statements_history_long table. Here, too, N statements stored will consume N times the memory indicated by the performance_schema_max_digest_length value.