[CONJ-151] performance degraded after upgrading from 1.1.7 to 1.1.8 Created: 2015-04-24 Updated: 2015-06-23 Resolved: 2015-06-23 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | Other |
| Affects Version/s: | 1.1.8 |
| Fix Version/s: | 1.1.9 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Alan Frazier | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux |
||
| Description |
|
After upgrading from 1.1.7 to 1.1.8, I noticed a performance decrease. The CPU Sampler in VisualVM pointed to MySQLParameterizedQuery.toSQL2() being the issue. I modified this method to use a StringBuilder instead of += which seems to have addressed the issue. Updated Code: private String toSQL2() throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(new String(queryPartsArray[0], "UTF-8")); for(int i = 1; i<queryPartsArray.length; i++) { sb.append(parameters[i-1]); if(queryPartsArray[i].length != 0) sb.append(new String(queryPartsArray[i], "UTF-8")); } return sb.toString(); |
| Comments |
| Comment by Vladislav Vaintroub [ 2015-05-10 ] |
|
The commit https://github.com/MariaDB/mariadb-connector-j/commit/8e507c416ef17b3b556b16d4cbff0bca59ebd233 was a mistake. |
| Comment by Diego Dupin [ 2015-05-29 ] |
|
same as Vladislav, each query implementation has a write method based on byte arrays. There is no need for transformation to have the write size. |
| Comment by Diego Dupin [ 2015-05-29 ] |
|
merge https://github.com/MariaDB/mariadb-connector-j/commit/a163bdbb0d01123095634593047873273fb2bb9f |
| Comment by Vladislav Vaintroub [ 2015-05-29 ] |
|
Commented about the merge proposal on github. |
| Comment by Vladislav Vaintroub [ 2015-05-30 ] |
|
Gave it a try here It turns out a bit more complicated with max_allowed_packet over 16MB, where query splits into multiple packets. In that case, terminate the connection whenever max_allowed_packet would overflow seems ok. also removed methods that materialize prepared statement toSQL() and toByteArray()as string rsp bytes in my patch, hope this is ok |
| Comment by Diego Dupin [ 2015-06-23 ] |
|
method toSQL replaced, because, not only perf degradation, but buggy. |