[CONC-79] Performance issue with c client library Created: 2014-02-14  Updated: 2014-03-03  Resolved: 2014-03-02

Status: Closed
Project: MariaDB Connector/C
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Ashwin Assignee: Georg Richter
Resolution: Fixed Votes: 0
Labels: performance
Environment:

Linux


Attachments: File MariaDB_sample_code.tar.gz    

 Description   

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.



 Comments   
Comment by Georg Richter [ 2014-03-02 ]

fixed in rev. 119

Generated at Thu Feb 08 03:02:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.