Type:
Bug
Priority:
Major
Resolution:
Fixed
Affects Version/s:
None
Fix Version/s:
None
Component/s:
None
Performance issue with client library when used with more connections.
Logging resource consumption output using getrusage() http://linux.die.net/man/2/getrusage
With 400 threads, each thread querying 1000 times here is the result:
user time (ms): 25589
system time (ms): 80732
page reclaims (soft page faults) : 2072
voluntary context switches : 263758
involuntary context switches : 3026
Since there a lot of context switches involved and high system time, degraded performance can be observed when used for long periods of time.
The same test with MySQL client results in
user time (ms): 21503
system time (ms): 3793
page reclaims (soft page faults) : 3213
voluntary context switches : 265321
involuntary context switches : 73
How to reproduce:
A simple c/c++ app which does the following will recreate the issue:
1. initializes client library, mysql_library_init().
2. spawns threads defined in "THREADS_TO_CREATE".
3. waits for all the threads to finish execution
4. clears the resources, mysql_library_end()
5. exits the application
every thread does the following:
1. starts with mysql_thread_init()
2. initializes a MYSQL* object, mysql_init()
3. set's the client connect timeout to 30 seconds, mysql_options()
4. attempts to connect to MySQL server, mysql_real_connect()
5. if connected, it executes a query, mysql_query()
6. loop through the result set, mysql_fetch_row()
7. free the reources and loop through for the specified times in
TIMES_TO_SELECT
8. mysql_close() is called
9. lastly, before exiting the thread, mysql_thread_end() is called.
Attaching a sample code that describes the problem:
To use the sample application:
1. compile: g++ -g app.cpp -o mariadbapp -I./mariadb/include -L./mariadb -lpthread -lmariadbclient -ldl -lssl
2. to run the binary: ./mariadbapp
P.S: I am using the rev 117 for testing.
Transition
Time In Source Status
Execution Times
Open
In Progress
5d 17h 30m
1
In Progress
Closed
10d 8h 32m
1
{"report":{"fcp":1696.9000000953674,"ttfb":427.80000019073486,"pageVisibility":"visible","entityId":30920,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"e2b7b5ee-fbe1-42d9-bd04-807cd240001a","navigationType":0,"readyForUser":1766.4000000953674,"redirectCount":0,"resourceLoadedEnd":2081.9000000953674,"resourceLoadedStart":433.40000009536743,"resourceTiming":[{"duration":671.9000000953674,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":433.40000009536743,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":433.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1105.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":673,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":433.60000014305115,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":433.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1106.6000001430511,"responseStart":0,"secureConnectionStart":0},{"duration":705.0999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":433.90000009536743,"connectEnd":433.90000009536743,"connectStart":433.90000009536743,"domainLookupEnd":433.90000009536743,"domainLookupStart":433.90000009536743,"fetchStart":433.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":433.90000009536743,"responseEnd":1139,"responseStart":1139,"secureConnectionStart":433.90000009536743},{"duration":779.7999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":434.10000014305115,"connectEnd":434.10000014305115,"connectStart":434.10000014305115,"domainLookupEnd":434.10000014305115,"domainLookupStart":434.10000014305115,"fetchStart":434.10000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":434.10000014305115,"responseEnd":1213.9000000953674,"responseStart":1213.9000000953674,"secureConnectionStart":434.10000014305115},{"duration":784.0999999046326,"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":434.30000019073486,"connectEnd":434.30000019073486,"connectStart":434.30000019073486,"domainLookupEnd":434.30000019073486,"domainLookupStart":434.30000019073486,"fetchStart":434.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":434.30000019073486,"responseEnd":1218.4000000953674,"responseStart":1218.4000000953674,"secureConnectionStart":434.30000019073486},{"duration":784.2999999523163,"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":434.60000014305115,"connectEnd":434.60000014305115,"connectStart":434.60000014305115,"domainLookupEnd":434.60000014305115,"domainLookupStart":434.60000014305115,"fetchStart":434.60000014305115,"redirectEnd":0,"redirectStart":0,"requestStart":434.60000014305115,"responseEnd":1218.9000000953674,"responseStart":1218.9000000953674,"secureConnectionStart":434.60000014305115},{"duration":784.6000001430511,"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":434.7000000476837,"connectEnd":434.7000000476837,"connectStart":434.7000000476837,"domainLookupEnd":434.7000000476837,"domainLookupStart":434.7000000476837,"fetchStart":434.7000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":434.7000000476837,"responseEnd":1219.3000001907349,"responseStart":1219.3000001907349,"secureConnectionStart":434.7000000476837},{"duration":903.7999999523163,"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":434.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":434.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1338.6000001430511,"responseStart":0,"secureConnectionStart":0},{"duration":784.8000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":435,"connectEnd":435,"connectStart":435,"domainLookupEnd":435,"domainLookupStart":435,"fetchStart":435,"redirectEnd":0,"redirectStart":0,"requestStart":435,"responseEnd":1219.8000001907349,"responseStart":1219.8000001907349,"secureConnectionStart":435},{"duration":903.6000001430511,"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":435.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":435.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1338.8000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":785,"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":435.40000009536743,"connectEnd":435.40000009536743,"connectStart":435.40000009536743,"domainLookupEnd":435.40000009536743,"domainLookupStart":435.40000009536743,"fetchStart":435.40000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":435.40000009536743,"responseEnd":1220.4000000953674,"responseStart":1220.4000000953674,"secureConnectionStart":435.40000009536743},{"duration":1005.6000001430511,"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":452.2000000476837,"connectEnd":452.2000000476837,"connectStart":452.2000000476837,"domainLookupEnd":452.2000000476837,"domainLookupStart":452.2000000476837,"fetchStart":452.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":452.2000000476837,"responseEnd":1457.8000001907349,"responseStart":1457.8000001907349,"secureConnectionStart":452.2000000476837},{"duration":1562.9000000953674,"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":452.2000000476837,"connectEnd":452.2000000476837,"connectStart":452.2000000476837,"domainLookupEnd":452.2000000476837,"domainLookupStart":452.2000000476837,"fetchStart":452.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":452.2000000476837,"responseEnd":2015.1000001430511,"responseStart":2015.1000001430511,"secureConnectionStart":452.2000000476837},{"duration":126.60000014305115,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1351,"connectEnd":1351,"connectStart":1351,"domainLookupEnd":1351,"domainLookupStart":1351,"fetchStart":1351,"redirectEnd":0,"redirectStart":0,"requestStart":1351,"responseEnd":1477.6000001430511,"responseStart":1477.6000001430511,"secureConnectionStart":1351},{"duration":443,"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","startTime":1628.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1628.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2071.5,"responseStart":0,"secureConnectionStart":0},{"duration":402.10000014305115,"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","startTime":1629.5,"connectEnd":1629.5,"connectStart":1629.5,"domainLookupEnd":1629.5,"domainLookupStart":1629.5,"fetchStart":1629.5,"redirectEnd":0,"redirectStart":0,"requestStart":1629.5,"responseEnd":2031.6000001430511,"responseStart":2031.6000001430511,"secureConnectionStart":1629.5},{"duration":452.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/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.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":1629.8000001907349,"connectEnd":1629.8000001907349,"connectStart":1629.8000001907349,"domainLookupEnd":1629.8000001907349,"domainLookupStart":1629.8000001907349,"fetchStart":1629.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1629.8000001907349,"responseEnd":2081.9000000953674,"responseStart":2081.9000000953674,"secureConnectionStart":1629.8000001907349},{"duration":417,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1690.2000000476837,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1690.2000000476837,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2107.2000000476837,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":289,"responseStart":428,"responseEnd":451,"domLoading":432,"domInteractive":2109,"domContentLoadedEventStart":2109,"domContentLoadedEventEnd":2156,"domComplete":2801,"loadEventStart":2801,"loadEventEnd":2802,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2027.8000001907349},{"name":"bigPipe.sidebar-id.end","time":2028.7000000476837},{"name":"bigPipe.activity-panel-pipe-id.start","time":2028.8000001907349},{"name":"bigPipe.activity-panel-pipe-id.end","time":2029.9000000953674},{"name":"activityTabFullyLoaded","time":2172.800000190735}],"measures":[],"correlationId":"8d3a85b069efa3","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":87,"dbReadsTimeInMs":11,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}