krummas / DrizzleJDBC

A BSD licensed JDBC driver for Drizzle and MySQL
BSD 3-Clause "New" or "Revised" License
31 stars 22 forks source link

MySQLProtocol.hexdump() in every query execution. #21

Closed vvaintroub closed 11 years ago

vvaintroub commented 11 years ago

In a simplistic benchmark that I run (consisting of "do 1" and "select 1" queries, running in a loop against local server), NetBeans profiler (CPU, instrumentation, all classes) says this line in jdbc\internal\common\packet\commands\StreamedQueryPacket.java takes takes about half of the CPU time

log.finest("Sending : " + MySQLProtocol.hexdump(byteHeader, 0));

Indeed, even if hexdump is not going to be output, MySQLProtocol.hexdump is still called, and it creates a hex string (in a rather expensive manner), and also concatenated this string with "Sending :". But the "Sending : hex" string is not going to be used, unless log level is set to FINEST. I'm able to increase the QPS by wide margin, just by removing this string, or by placing it under if (log.getLevel() == java.util.logging.Level.FINEST) condition.

krummas commented 11 years ago

holy crap, nice catch!