Bug #71861 Avoid manual array copy in MysqlIO and LoadBalancingConnectionProxy
Submitted: 27 Feb 2014 9:52 Modified: 10 Mar 2014 16:07
Reporter: Andrej Golovnin (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S5 (Performance)
Version:5.1.29 OS:Any
Assigned to: Filipe Silva CPU Architecture:Any
Tags: jdbc, LoadBalancingConnectionProxy, MysqlIO

[27 Feb 2014 9:52] Andrej Golovnin
Description:
In the methods MysqlIO#unpackNativeEncodedColumn and LoadBalancingConnectionProxy#addHost a manual loop is used to copy array values. To improve the performance System#arraycopy should be used instead. Oracle's HotSpot hast intrinsics for System#arraycopy which results in better performance.

How to repeat:
Just review the code of the methods MysqlIO#unpackNativeEncodedColumn and LoadBalancingConnectionProxy#addHost.

Suggested fix:
See attached patch.
[27 Feb 2014 9:53] Andrej Golovnin
Patch for this issue.

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: manual_array_copy.patch (application/octet-stream, text), 1.30 KiB.

[28 Feb 2014 9:54] Filipe Silva
Hi Andrej,

Thank you for this bug report.
[28 Feb 2014 9:56] Filipe Silva
Verified by code review and patch accepted. Thanks.
[28 Feb 2014 10:46] Alexander Soklakov
Hi Andrej,

Contribution accepted, thank you!
[10 Mar 2014 16:07] Daniel So
Added the following entry into the Connector/J 5.1.30 changelog:

"Replaced a for loop with the System.arraycopy() method for copying array values in the MysqlIO.unpackNativeEncodedColumn() and LoadBalancingConnectionProxy.addHost() methods, in order to improve the two methods' performance."