Bug #71679 Avoid iterator creation when invoking statement interceptors in MysqlIO.
| Submitted: | 12 Feb 2014 7:47 | Modified: | 10 Mar 2014 16:28 |
|---|---|---|---|
| Reporter: | Andrej Golovnin (OCA) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / J | Severity: | S5 (Performance) |
| Version: | 5.1.29 | OS: | Any |
| Assigned to: | Filipe Silva | CPU Architecture: | Any |
| Tags: | interceptors, jdbc, MysqlIO | ||
[12 Feb 2014 7:48]
Andrej Golovnin
Patch for this issue.
Attachment: MysqlIO.patch (application/octet-stream, text), 1.78 KiB.
[12 Feb 2014 12:23]
Filipe Silva
Hi Andrej, Thank you for this bug report. Verified by code review. Thanks for noticing the duplicated line too.
[18 Feb 2014 13:48]
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: MysqlIO.patch (application/octet-stream, text), 1.78 KiB.
[21 Feb 2014 10:13]
Alexander Soklakov
Thanks Andrej, accepted.
[10 Mar 2014 16:28]
Daniel So
Added the following entry into the Connector/J 5.1.30 changelog: "Avoided the use of an iterator over the list of statement interceptors in the methods MysqlIO.invokeStatementInterceptorsPost() and MysqlIO.invokeStatementInterceptorsPre(), so that Connector/J does not increase the stack size unnecessarily."
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.054 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: In the methods MysqlIO#invokeStatementInterceptorsPost and MysqlIO#invokeStatementInterceptorsPre an iterator is used to loop over the list of statement interceptors. As far as I can tell, the list of the statement interceptors is always an ArrayList. So using the old-school for-loop should be the preferable way there to loop over the list. Even if the Hotspot would allocate the iterator on the thread's stack (and he does that), I think MySQL Connector/J should still avoid creation of the iterator, because the size of the thread stack is limited and I would prefer to see that objects from my application are allocated on the stack and not those from MySQL Connector/J. One more thing. I won't submit a patch for this. But could you please review the method ConnectionImpl#isSameResource(Connection), lines 4030-4031: if (!nullSafeCompare(otherOrigDatabase, this.origDatabaseToConnectTo)) { directCompare = false; directCompare = false; I think the assignment "directCompare = false;" in the line 4030 can be removed. :-) How to repeat: See my patch. Suggested fix: Use the old-school for-loop to iterate over the list.