Type:
Task
Priority:
Major
Resolution:
Won't Fix
In MDEV-8684 we saw a large potion of CPU in the mutex implementation.
The top calls on high CPU for mutex_spin_wait, _raw_spin_lock(kernel), ut_delay are all due to a single global lock trx_sys->mutex.
All these go back to the mutex use in:
trx_start_low;
read_view_open_now; and
trx_commit_low.
Every read only select query hits this global mutex 3 times.
The first two are called from row_search_for_mysql and the trx_commit_low is the clean up of JOIN::optimize_inner within the same SELECT handler.
trx_start_low needs the mutex for trx_sys_get_new_trx_id() and addition on trx_sys->ro_trx_list (or trx_sys->rw_trx_list) and trx_reserve_descriptor
read_view_open_now(,_low) needs the lock for trx_find_descriptor and for inserting into trx_sys->view_list. This is called shortly via trx_assign_read_view after trx_start_if_not_started(ends up in trx_start_low) in the Phase 3 in row_search_for_mysql.
trx_commit_low needs the mutex for removing from the above lists and also from trx->global_read_view.
It might be possible to group trx_start_low and read_view_open_now update the same mutex.
MySQL-5.7 has mitigated this with http://dev.mysql.com/worklog/task/?id=6047
This removes the mutex in trx_start_low, trx_sys_get_new_trx_id and tx_commit_low for read only queries by not allocating a trx_id.
It has fairly invasive patches like https://github.com/mysql/mysql-server/commit/ed460aae81f9897984157bfe7759075182efb2b7
and the worklog task references previous commits that I'll need to port too.
I'll attempt to do this porting.
relates to
MDEV-8684
UT_RELAX_CPU isn't at all relaxing
Closed
links to
{"report":{"fcp":833.6000000238419,"ttfb":211.70000004768372,"pageVisibility":"visible","entityId":56362,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"e97189b7-650a-4036-ad56-504691583730","navigationType":0,"readyForUser":894.7000000476837,"redirectCount":0,"resourceLoadedEnd":410.30000001192093,"resourceLoadedStart":216.9000000357628,"resourceTiming":[{"duration":8.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":216.9000000357628,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":216.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":225.4000000357628,"responseStart":0,"secureConnectionStart":0},{"duration":10.199999988079071,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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","startTime":217.20000004768372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":217.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":227.4000000357628,"responseStart":0,"secureConnectionStart":0},{"duration":143.9000000357628,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":217.5,"connectEnd":217.5,"connectStart":217.5,"domainLookupEnd":217.5,"domainLookupStart":217.5,"fetchStart":217.5,"redirectEnd":0,"redirectStart":0,"requestStart":232.4000000357628,"responseEnd":361.4000000357628,"responseStart":244.30000001192093,"secureConnectionStart":217.5},{"duration":192.69999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/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","startTime":217.60000002384186,"connectEnd":217.60000002384186,"connectStart":217.60000002384186,"domainLookupEnd":217.60000002384186,"domainLookupStart":217.60000002384186,"fetchStart":217.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":232.9000000357628,"responseEnd":410.30000001192093,"responseStart":262.4000000357628,"secureConnectionStart":217.60000002384186},{"duration":54.69999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":217.80000001192093,"connectEnd":217.80000001192093,"connectStart":217.80000001192093,"domainLookupEnd":217.80000001192093,"domainLookupStart":217.80000001192093,"fetchStart":217.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":234.20000004768372,"responseEnd":272.5,"responseStart":271.7000000476837,"secureConnectionStart":217.80000001192093},{"duration":53.69999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":217.9000000357628,"connectEnd":243.4000000357628,"connectStart":243.4000000357628,"domainLookupEnd":243.4000000357628,"domainLookupStart":243.4000000357628,"fetchStart":217.9000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":246,"responseEnd":271.60000002384186,"responseStart":261.60000002384186,"secureConnectionStart":243.4000000357628},{"duration":54.69999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":218.10000002384186,"connectEnd":218.10000002384186,"connectStart":218.10000002384186,"domainLookupEnd":218.10000002384186,"domainLookupStart":218.10000002384186,"fetchStart":218.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":246.20000004768372,"responseEnd":272.80000001192093,"responseStart":262.9000000357628,"secureConnectionStart":218.10000002384186},{"duration":27,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":218.30000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":218.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":245.30000001192093,"responseStart":0,"secureConnectionStart":0},{"duration":57.69999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":218.4000000357628,"connectEnd":218.4000000357628,"connectStart":218.4000000357628,"domainLookupEnd":218.4000000357628,"domainLookupStart":218.4000000357628,"fetchStart":218.4000000357628,"redirectEnd":0,"redirectStart":0,"requestStart":246.4000000357628,"responseEnd":276.10000002384186,"responseStart":273,"secureConnectionStart":218.4000000357628},{"duration":26.80000001192093,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/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":218.60000002384186,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":218.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":245.4000000357628,"responseStart":0,"secureConnectionStart":0},{"duration":56.80000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/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":218.80000001192093,"connectEnd":218.80000001192093,"connectStart":218.80000001192093,"domainLookupEnd":218.80000001192093,"domainLookupStart":218.80000001192093,"fetchStart":218.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":246.5,"responseEnd":275.60000002384186,"responseStart":263.80000001192093,"secureConnectionStart":218.80000001192093},{"duration":92.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":227.10000002384186,"connectEnd":227.10000002384186,"connectStart":227.10000002384186,"domainLookupEnd":227.10000002384186,"domainLookupStart":227.10000002384186,"fetchStart":227.10000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":285.4000000357628,"responseEnd":319.7000000476837,"responseStart":317.4000000357628,"secureConnectionStart":227.10000002384186},{"duration":103.59999996423721,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":227.20000004768372,"connectEnd":227.20000004768372,"connectStart":227.20000004768372,"domainLookupEnd":227.20000004768372,"domainLookupStart":227.20000004768372,"fetchStart":227.20000004768372,"redirectEnd":0,"redirectStart":0,"requestStart":315.7000000476837,"responseEnd":330.80000001192093,"responseStart":327.5,"secureConnectionStart":227.20000004768372},{"duration":220.69999998807907,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":578.6000000238419,"connectEnd":578.6000000238419,"connectStart":578.6000000238419,"domainLookupEnd":578.6000000238419,"domainLookupStart":578.6000000238419,"fetchStart":578.6000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":768.1000000238419,"responseEnd":799.3000000119209,"responseStart":798.5,"secureConnectionStart":578.6000000238419}],"fetchStart":0,"domainLookupStart":16,"domainLookupEnd":39,"connectStart":39,"connectEnd":59,"secureConnectionStart":48,"requestStart":59,"responseStart":212,"responseEnd":226,"domLoading":215,"domInteractive":963,"domContentLoadedEventStart":963,"domContentLoadedEventEnd":1025,"domComplete":2000,"loadEventStart":2000,"loadEventEnd":2001,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":938.2000000476837},{"name":"bigPipe.sidebar-id.end","time":939.1000000238419},{"name":"bigPipe.activity-panel-pipe-id.start","time":939.2000000476837},{"name":"bigPipe.activity-panel-pipe-id.end","time":941.7000000476837},{"name":"activityTabFullyLoaded","time":1032.5}],"measures":[],"correlationId":"1061364fe89836","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":92,"dbReadsTimeInMs":12,"dbConnsTimeInMs":19,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}