It seems MariaDB 10.4.x (and maybe 10.3.x and 10.2.x) uses more memory for performance_schema (in average, per connection) with default setting comparing to MariaDB 10.1.x or MySQL 5.6, We can estimate is as 250K or so comparing to 176K or so in MySQL 5.6 or MariaDB 10.1.
we see about 177K is used per connection at the same "scale". So, where this increase comes from in MariaDB 10.4.x and can it be reduced?
Upstream MySQL introduced dynamic memory allocation in 5.7 (see https://bugs.mysql.com/bug.php?id=68514), but until we port that it would be still useful to find out why more memory is used in recent versions (while the features are still mostly those of MySQL 5.6) and is there any way to reduce memory footprint. For "large" instances (with max_connections, max_open_files and/or table_open_cache/table_definition_cache set to 10-15K or more) the impact of performance_schema's default sizing is too high and may cause unexpected OOM killing of MariaDB server.
Hi valerii. I was able to reproduce your numbers on fresh 10.1 and 10.4, the memory consumption is indeed higher. Sergey and I did some analysis and it seems the sizes of PFS arrays were increased by this revision c9f612db (m_events_waits_history_sizing, m_events_stages_history_sizing, m_events_statements_history_sizing).
Reverting those sizes in 10.4 seems to reduce the PFS memory consumption considerably.
You reported 10.1 uses around 177k per connection and 10.4 around 250k. In my local setup 10.4 with reverted PFS sizes seems to use around 186k per connection. This explains more than 80% of the memory consumption difference.
I attached here a diff of the PFS memory counters for max_connections=500. Left column is fresh 10.1, middle column fresh 10.4 and right column is 10.4 with reverted PFS array sizes.
Robert Bindar
added a comment - - edited Hi valerii . I was able to reproduce your numbers on fresh 10.1 and 10.4, the memory consumption is indeed higher. Sergey and I did some analysis and it seems the sizes of PFS arrays were increased by this revision c9f612db (m_events_waits_history_sizing, m_events_stages_history_sizing, m_events_statements_history_sizing).
Reverting those sizes in 10.4 seems to reduce the PFS memory consumption considerably.
You reported 10.1 uses around 177k per connection and 10.4 around 250k. In my local setup 10.4 with reverted PFS sizes seems to use around 186k per connection. This explains more than 80% of the memory consumption difference.
I attached here a diff of the PFS memory counters for max_connections=500. Left column is fresh 10.1, middle column fresh 10.4 and right column is 10.4 with reverted PFS array sizes.
In other words increased PFS memory usage was caused by adding more "stages". Though it is unclear why "waits" and "statements" histories had to be updated.
valerii, is it acceptable to lower down relevant variables (on the customer's side), or do you feel like we should try spending more time on this and coming up with some other solution?
Sergey Vojtovich
added a comment - - edited In other words increased PFS memory usage was caused by adding more "stages". Though it is unclear why "waits" and "statements" histories had to be updated.
valerii , is it acceptable to lower down relevant variables (on the customer's side), or do you feel like we should try spending more time on this and coming up with some other solution?
Surely tuning P_S settings to decrease memory consumption is an option and it would be a good workaround for specific cases. But I'd prefer to see less usage in 10.4 vs 10.1 (or MySQL 5.6) by default (as this is what the majority of customers use when they enable P_S). Maybe defaults have to be changed for this. If there is anything you can do to use less memory with the same settings, that would be great and positive improvement.
In this specific issue associated customer explicitly complained that MariaDB's memory usage (in all versions, 10.2 to 10.4) with the same explicit settings and high max_connections value is notably higher than for MySQL 5.5 or 5.7.
Long term I'd prefer to see dynamic allocation improvements similar to what was done in MySQL.
Valerii Kravchuk
added a comment - - edited Surely tuning P_S settings to decrease memory consumption is an option and it would be a good workaround for specific cases. But I'd prefer to see less usage in 10.4 vs 10.1 (or MySQL 5.6) by default (as this is what the majority of customers use when they enable P_S). Maybe defaults have to be changed for this. If there is anything you can do to use less memory with the same settings, that would be great and positive improvement.
In this specific issue associated customer explicitly complained that MariaDB's memory usage (in all versions, 10.2 to 10.4) with the same explicit settings and high max_connections value is notably higher than for MySQL 5.5 or 5.7.
Long term I'd prefer to see dynamic allocation improvements similar to what was done in MySQL.
It's fixed in 10.5 that has both smaller autosize defaults and dynamic P_S allocation like in 5.7.
We won't change defaults in in the old GA version, that is 10.4. Particularly as there is a very simple workaround — just set these table sizes manually from your my.cnf
Sergei Golubchik
added a comment - It's fixed in 10.5 that has both smaller autosize defaults and dynamic P_S allocation like in 5.7.
We won't change defaults in in the old GA version, that is 10.4. Particularly as there is a very simple workaround — just set these table sizes manually from your my.cnf
People
Sergei Golubchik
Valerii Kravchuk
Votes:
0Vote for this issue
Watchers:
8Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1535.1999998092651,"ttfb":590.5999994277954,"pageVisibility":"visible","entityId":77897,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"1cd4cb66-9654-4802-be2f-f3b85b1a9f06","navigationType":0,"readyForUser":1702.8999996185303,"redirectCount":0,"resourceLoadedEnd":2185.8999996185303,"resourceLoadedStart":596.1999998092651,"resourceTiming":[{"duration":312.5999994277954,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":596.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":596.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":908.7999992370605,"responseStart":0,"secureConnectionStart":0},{"duration":312.8999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":596.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":596.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":909.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":379.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":596.5999994277954,"connectEnd":596.5999994277954,"connectStart":596.5999994277954,"domainLookupEnd":596.5999994277954,"domainLookupStart":596.5999994277954,"fetchStart":596.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":596.5999994277954,"responseEnd":976.0999994277954,"responseStart":976.0999994277954,"secureConnectionStart":596.5999994277954},{"duration":439.1000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":596.7999992370605,"connectEnd":596.7999992370605,"connectStart":596.7999992370605,"domainLookupEnd":596.7999992370605,"domainLookupStart":596.7999992370605,"fetchStart":596.7999992370605,"redirectEnd":0,"redirectStart":0,"requestStart":596.7999992370605,"responseEnd":1035.8999996185303,"responseStart":1035.8999996185303,"secureConnectionStart":596.7999992370605},{"duration":444,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":597.0999994277954,"connectEnd":597.0999994277954,"connectStart":597.0999994277954,"domainLookupEnd":597.0999994277954,"domainLookupStart":597.0999994277954,"fetchStart":597.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":597.0999994277954,"responseEnd":1041.0999994277954,"responseStart":1041.0999994277954,"secureConnectionStart":597.0999994277954},{"duration":444.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":597.2999992370605,"connectEnd":597.2999992370605,"connectStart":597.2999992370605,"domainLookupEnd":597.2999992370605,"domainLookupStart":597.2999992370605,"fetchStart":597.2999992370605,"redirectEnd":0,"redirectStart":0,"requestStart":597.2999992370605,"responseEnd":1041.5999994277954,"responseStart":1041.5999994277954,"secureConnectionStart":597.2999992370605},{"duration":447.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":597.5,"connectEnd":597.5,"connectStart":597.5,"domainLookupEnd":597.5,"domainLookupStart":597.5,"fetchStart":597.5,"redirectEnd":0,"redirectStart":0,"requestStart":597.5,"responseEnd":1045.3999996185303,"responseStart":1045.3999996185303,"secureConnectionStart":597.5},{"duration":546.5999994277954,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":597.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":597.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1144.2999992370605,"responseStart":0,"secureConnectionStart":0},{"duration":448,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":597.8999996185303,"connectEnd":597.8999996185303,"connectStart":597.8999996185303,"domainLookupEnd":597.8999996185303,"domainLookupStart":597.8999996185303,"fetchStart":597.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":597.8999996185303,"responseEnd":1045.8999996185303,"responseStart":1045.8999996185303,"secureConnectionStart":597.8999996185303},{"duration":546.6999998092651,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":598,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":598,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1144.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":448.3999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":598.1999998092651,"connectEnd":598.1999998092651,"connectStart":598.1999998092651,"domainLookupEnd":598.1999998092651,"domainLookupStart":598.1999998092651,"fetchStart":598.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":598.1999998092651,"responseEnd":1046.5999994277954,"responseStart":1046.5999994277954,"secureConnectionStart":598.1999998092651},{"duration":1349.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":607.5999994277954,"connectEnd":607.5999994277954,"connectStart":607.5999994277954,"domainLookupEnd":607.5999994277954,"domainLookupStart":607.5999994277954,"fetchStart":607.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":607.5999994277954,"responseEnd":1956.8999996185303,"responseStart":1956.8999996185303,"secureConnectionStart":607.5999994277954},{"duration":1578.3000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":607.5999994277954,"connectEnd":607.5999994277954,"connectStart":607.5999994277954,"domainLookupEnd":607.5999994277954,"domainLookupStart":607.5999994277954,"fetchStart":607.5999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":607.5999994277954,"responseEnd":2185.8999996185303,"responseStart":2185.8999996185303,"secureConnectionStart":607.5999994277954},{"duration":777.9000005722046,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1181.7999992370605,"connectEnd":1181.7999992370605,"connectStart":1181.7999992370605,"domainLookupEnd":1181.7999992370605,"domainLookupStart":1181.7999992370605,"fetchStart":1181.7999992370605,"redirectEnd":0,"redirectStart":0,"requestStart":1181.7999992370605,"responseEnd":1959.6999998092651,"responseStart":1959.6999998092651,"secureConnectionStart":1181.7999992370605},{"duration":687.5,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1527.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1527.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2215,"responseStart":0,"secureConnectionStart":0},{"duration":303.5999994277954,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1963.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1963.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2267.0999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":288.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":1964.5,"connectEnd":1964.5,"connectStart":1964.5,"domainLookupEnd":1964.5,"domainLookupStart":1964.5,"fetchStart":1964.5,"redirectEnd":0,"redirectStart":0,"requestStart":1964.5,"responseEnd":2253,"responseStart":2253,"secureConnectionStart":1964.5}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":411,"responseStart":591,"responseEnd":604,"domLoading":594,"domInteractive":2217,"domContentLoadedEventStart":2217,"domContentLoadedEventEnd":2267,"domComplete":2598,"loadEventStart":2598,"loadEventEnd":2599,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2188.5},{"name":"bigPipe.sidebar-id.end","time":2190.8999996185303},{"name":"bigPipe.activity-panel-pipe-id.start","time":2191.0999994277954},{"name":"bigPipe.activity-panel-pipe-id.end","time":2194.699999809265},{"name":"activityTabFullyLoaded","time":2304.0999994277954}],"measures":[],"correlationId":"732f085ad69674","effectiveType":"4g","downlink":9.2,"rtt":0,"serverDuration":110,"dbReadsTimeInMs":12,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Hi valerii. I was able to reproduce your numbers on fresh 10.1 and 10.4, the memory consumption is indeed higher. Sergey and I did some analysis and it seems the sizes of PFS arrays were increased by this revision c9f612db (m_events_waits_history_sizing, m_events_stages_history_sizing, m_events_statements_history_sizing).
Reverting those sizes in 10.4 seems to reduce the PFS memory consumption considerably.
You reported 10.1 uses around 177k per connection and 10.4 around 250k. In my local setup 10.4 with reverted PFS sizes seems to use around 186k per connection. This explains more than 80% of the memory consumption difference.
I attached here a diff of the PFS memory counters for max_connections=500. Left column is fresh 10.1, middle column fresh 10.4 and right column is 10.4 with reverted PFS array sizes.