Bug #22947 Performance regression in C API 4.1 versus 4.0
Submitted: 3 Oct 2006 16:16 Modified: 3 Oct 2006 16:20
Reporter: Shawn Green Email Updates:
Status: Duplicate Impact on me:
Category:MySQL Server: General Severity:S2 (Serious)
Version:4.1.21 OS: Linux 2.4.18 SMP kernel
Assigned to: CPU Architecture:Any
Tags: performance, regression, setsockopt

[3 Oct 2006 16:16] Shawn Green
Quoted from CSC issue #11886

An application I have been monitoring for performance uses ~25% more system time when changed to use the 4.1.21 MySQL client library rather than 4.1.14. This increase makes the application ~5% slower. It is already CPU bound and the extra system calls make that worse.

How to repeat:
Quoted from CSC issue # 11886

strace -c mysql -ume -p -e 'select * from Criteria' > /dev/null
to find the difference in the number of system calls. 4.1.21 calls setsockopt much more frequently (1 call for every 2 calls to read).

Is this a known problem? Can it be avoided?

I prefer to use 4.1.21 because I also want to use a recent MySQL patch for read/write timeouts and that is much easier to apply to 4.1.21.

I have attached files with the summarized strace output. o.21 has the output from the 4.1.21 client library. o.14 has the output from 4.1.14. I am also aware that the 5.0 client library is much faster because it uses fewer read system calls, but it will take me a while to upgrade to that version.

The database server is 4.0.26

Suggested fix:
Reduce or optimize the use of setsockopt call to improve network throughput.
[3 Oct 2006 16:17] Shawn Green
Trace file for 4.1.14 library

Attachment: o.14 (application/octet-stream, text), 2.09 KiB.

[3 Oct 2006 16:17] Shawn Green
trace file for 4.1.21 library

Attachment: o.21 (application/octet-stream, text), 2.09 KiB.

[3 Oct 2006 16:20] Jim Winstead
This is a duplicate of Bug #22943.
[3 Oct 2006 16:22] Jim Winstead
Note is that it may be the patch to implement read/write timeouts that is causing the extra setsockopt() calls.