Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
CONJ-151 - performance degraded after upgrading from 1.1.7 to 1.1.8
- Loading branch information
Showing
6 changed files
with
51 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a163bdbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is no need in sqlToByteArray() eithe (apart from possibly debugging), and no need in toSQL()..
If you have prepared statement with multimegabyte input streams, materializing them in memory is probably not a good idea. Also, converting to byte array adds an unneeded copy of the data, which affects performance.
a163bdbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If is a need to check for packet length, to "beautify" the exception, and avoid server closing the socket, this is best done when the actual packet is sent. This is in
https://github.com/MariaDB/mariadb-connector-j/blob/master/src/main/java/org/mariadb/jdbc/internal/common/packet/PacketOutputStream.java
in internalFlush(), you can check for datalen > max packet length. Before you throw an exception, you'd need to reset the PacketOutputStream's buffer (position to 0) and seqNo to 0, so that stream remains usable after the exception, i you do not want this exception to be fatal.
if you want this exception to be fatal, you'd probably need to close the connection
a163bdbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, truly, your solution is more effective (code length and perf), I'll change that.
a163bdbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!