Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-79

Performance issue with c client library

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • Linux

    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.

      Attachments

        Activity

          People

            georg Georg Richter
            ashwinkumar Ashwin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start 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.