numbers used for autosizing are valid for my host, not sure if they'll work properly for others
we do trylock() and then lock() rather often: up to 30% of cases (performance concern)
additional code on rather a hot path (performance concern)
I couldn't get perfect 3 instances for my host with autosizing: it either gets 2 or raising number of instances up to limit (everything under 480 for waits)
we can't avoid warm-up (bad for benchmarks)
Sergey Vojtovich
added a comment - serg , please review 2 last patches for this task.
I'm still not happy with autosizing:
numbers used for autosizing are valid for my host, not sure if they'll work properly for others
we do trylock() and then lock() rather often: up to 30% of cases (performance concern)
additional code on rather a hot path (performance concern)
I couldn't get perfect 3 instances for my host with autosizing: it either gets 2 or raising number of instances up to limit (everything under 480 for waits)
we can't avoid warm-up (bad for benchmarks)
we do trylock() and then lock() rather often: up to 30% of cases (performance concern)
You increase the number of instances when lock/trylock ratio reaches 50%. May be you should do it earlier? At 30%, may be?
additional code on rather a hot path (performance concern)
That should normally be just ++mutex_nowaits, shouldn't it?
I couldn't get perfect 3 instances for my host with autosizing: it either gets 2 or raising number of instances up to limit (everything under 480 for waits)
Interesting. Why would you think is that? What did you do in your benchmarks? You've never had only 1 instance?
we can't avoid warm-up (bad for benchmarks)
True. How long a warm-up is needed, what was your impression?
Anyway, any proper benchmark does a warm-up anyway, so it this your warm-up with shorter than what benchmarks typically do, it should be fine.
Sergei Golubchik
added a comment - we do trylock() and then lock() rather often: up to 30% of cases (performance concern)
You increase the number of instances when lock/trylock ratio reaches 50%. May be you should do it earlier? At 30%, may be?
additional code on rather a hot path (performance concern)
That should normally be just ++mutex_nowaits , shouldn't it?
I couldn't get perfect 3 instances for my host with autosizing: it either gets 2 or raising number of instances up to limit (everything under 480 for waits)
Interesting. Why would you think is that? What did you do in your benchmarks? You've never had only 1 instance?
we can't avoid warm-up (bad for benchmarks)
True. How long a warm-up is needed, what was your impression?
Anyway, any proper benchmark does a warm-up anyway, so it this your warm-up with shorter than what benchmarks typically do, it should be fine.
Yes, number of instances is increased at 50%. As I mentioned, if I increase it at 48%, number of instances is quickly raising up to the limit.
It's a bit more than ++mutex_nowaits, but close enough.
It was multi-table OLTP RO benchmark with 40 threads. I had 1 instance initially.
With current numbers warm-up up to 2 instances takes under 5 seconds. With lower numbers it was raising up to the limit in under 1 minute.
There's another option, but it's a bit more expensive: count number of waiting threads and activate instances when there're e.g. 10 waiters. This will add 2 atomic adds per lock.
Sergey Vojtovich
added a comment - Yes, number of instances is increased at 50%. As I mentioned, if I increase it at 48%, number of instances is quickly raising up to the limit.
It's a bit more than ++mutex_nowaits, but close enough.
It was multi-table OLTP RO benchmark with 40 threads. I had 1 instance initially.
With current numbers warm-up up to 2 instances takes under 5 seconds. With lower numbers it was raising up to the limit in under 1 minute.
There's another option, but it's a bit more expensive: count number of waiting threads and activate instances when there're e.g. 10 waiters. This will add 2 atomic adds per lock.
Instance is considered contested if more than 20% of mutex acquisiotions
can't be served immediately. Up to 100 000 probes may be performed to avoid
instance activation on short sporadic peaks. 100 000 is estimated maximum
number of queries one instance can serve in one second.
These numbers work well on a 2 socket / 20 core / 40 threads Intel Broadwell
system, that is expected number of instances is activated within reasonable
warmup time. It may have to be adjusted for other systems.
Only TABLE object acquistion is instrumented. We intentionally avoid this
overhead on TABLE object release. All other table cache mutex acquistions
are considered out of hot path and are not instrumented either.
Sergey Vojtovich
added a comment - Final autosizing implementation:
Instance is considered contested if more than 20% of mutex acquisiotions
can't be served immediately. Up to 100 000 probes may be performed to avoid
instance activation on short sporadic peaks. 100 000 is estimated maximum
number of queries one instance can serve in one second.
These numbers work well on a 2 socket / 20 core / 40 threads Intel Broadwell
system, that is expected number of instances is activated within reasonable
warmup time. It may have to be adjusted for other systems.
Only TABLE object acquistion is instrumented. We intentionally avoid this
overhead on TABLE object release. All other table cache mutex acquistions
are considered out of hot path and are not instrumented either.
People
Sergey Vojtovich
Sergey Vojtovich
Votes:
1Vote for this issue
Watchers:
3Start 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":793.5,"ttfb":216.7999997138977,"pageVisibility":"visible","entityId":57247,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"27988517-5ba3-4f61-a896-67a5473748a3","navigationType":0,"readyForUser":845.7999997138977,"redirectCount":0,"resourceLoadedEnd":325.69999980926514,"resourceLoadedStart":225.69999980926514,"resourceTiming":[{"duration":17.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":225.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":225.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":243.19999980926514,"responseStart":0,"secureConnectionStart":0},{"duration":17.5,"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":226,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":226,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":243.5,"responseStart":0,"secureConnectionStart":0},{"duration":83.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":226.09999990463257,"connectEnd":226.09999990463257,"connectStart":226.09999990463257,"domainLookupEnd":226.09999990463257,"domainLookupStart":226.09999990463257,"fetchStart":226.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":236.19999980926514,"responseEnd":309.7999997138977,"responseStart":251.19999980926514,"secureConnectionStart":226.09999990463257},{"duration":96.80000019073486,"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":226.39999961853027,"connectEnd":226.39999961853027,"connectStart":226.39999961853027,"domainLookupEnd":226.39999961853027,"domainLookupStart":226.39999961853027,"fetchStart":226.39999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":237.09999990463257,"responseEnd":323.19999980926514,"responseStart":268.09999990463257,"secureConnectionStart":226.39999961853027},{"duration":70.39999961853027,"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":226.5,"connectEnd":226.5,"connectStart":226.5,"domainLookupEnd":226.5,"domainLookupStart":226.5,"fetchStart":226.5,"redirectEnd":0,"redirectStart":0,"requestStart":245.69999980926514,"responseEnd":296.8999996185303,"responseStart":293.5,"secureConnectionStart":226.5},{"duration":71,"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":226.69999980926514,"connectEnd":226.69999980926514,"connectStart":226.69999980926514,"domainLookupEnd":226.69999980926514,"domainLookupStart":226.69999980926514,"fetchStart":226.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":246.39999961853027,"responseEnd":297.69999980926514,"responseStart":297,"secureConnectionStart":226.69999980926514},{"duration":71.40000009536743,"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":226.7999997138977,"connectEnd":226.7999997138977,"connectStart":226.7999997138977,"domainLookupEnd":226.7999997138977,"domainLookupStart":226.7999997138977,"fetchStart":226.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":246.5,"responseEnd":298.19999980926514,"responseStart":297.69999980926514,"secureConnectionStart":226.7999997138977},{"duration":18.799999713897705,"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":227.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":227.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":245.89999961853027,"responseStart":0,"secureConnectionStart":0},{"duration":71.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":227.19999980926514,"connectEnd":227.19999980926514,"connectStart":227.19999980926514,"domainLookupEnd":227.19999980926514,"domainLookupStart":227.19999980926514,"fetchStart":227.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":246.69999980926514,"responseEnd":298.8999996185303,"responseStart":298.2999997138977,"secureConnectionStart":227.19999980926514},{"duration":19.600000381469727,"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":227.39999961853027,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":227.39999961853027,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":247,"responseStart":0,"secureConnectionStart":0},{"duration":72,"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":227.59999990463257,"connectEnd":227.59999990463257,"connectStart":227.59999990463257,"domainLookupEnd":227.59999990463257,"domainLookupStart":227.59999990463257,"fetchStart":227.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":247.19999980926514,"responseEnd":299.59999990463257,"responseStart":299,"secureConnectionStart":227.59999990463257},{"duration":71.90000009536743,"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":245.69999980926514,"connectEnd":300.8999996185303,"connectStart":300.8999996185303,"domainLookupEnd":300.8999996185303,"domainLookupStart":300.8999996185303,"fetchStart":245.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":302.09999990463257,"responseEnd":317.59999990463257,"responseStart":316.3999996185303,"secureConnectionStart":300.8999996185303},{"duration":79.90000009536743,"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":245.7999997138977,"connectEnd":245.7999997138977,"connectStart":245.7999997138977,"domainLookupEnd":245.7999997138977,"domainLookupStart":245.7999997138977,"fetchStart":245.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":311.8999996185303,"responseEnd":325.69999980926514,"responseStart":325.19999980926514,"secureConnectionStart":245.7999997138977},{"duration":207.90000009536743,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":525.0999999046326,"connectEnd":525.0999999046326,"connectStart":525.0999999046326,"domainLookupEnd":525.0999999046326,"domainLookupStart":525.0999999046326,"fetchStart":525.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":690.2999997138977,"responseEnd":733,"responseStart":732.1999998092651,"secureConnectionStart":525.0999999046326},{"duration":109,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":766,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":766,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":875,"responseStart":0,"secureConnectionStart":0},{"duration":122,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":786.1999998092651,"connectEnd":786.1999998092651,"connectStart":786.1999998092651,"domainLookupEnd":786.1999998092651,"domainLookupStart":786.1999998092651,"fetchStart":786.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":867.2999997138977,"responseEnd":908.1999998092651,"responseStart":907.5,"secureConnectionStart":786.1999998092651}],"fetchStart":0,"domainLookupStart":12,"domainLookupEnd":12,"connectStart":12,"connectEnd":36,"secureConnectionStart":23,"requestStart":37,"responseStart":217,"responseEnd":244,"domLoading":224,"domInteractive":911,"domContentLoadedEventStart":918,"domContentLoadedEventEnd":970,"domComplete":1209,"loadEventStart":1209,"loadEventEnd":1209,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":877.8999996185303},{"name":"bigPipe.sidebar-id.end","time":878.6999998092651},{"name":"bigPipe.activity-panel-pipe-id.start","time":879},{"name":"bigPipe.activity-panel-pipe-id.end","time":881.5},{"name":"activityTabFullyLoaded","time":991.0999999046326}],"measures":[],"correlationId":"63973a1838cb29","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":118,"dbReadsTimeInMs":13,"dbConnsTimeInMs":23,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
serg, please review patch for this task.