longzenvo / log4jdbc

Automatically exported from code.google.com/p/log4jdbc
0 stars 0 forks source link

Performance Enhancement when Logging not Enabled #29

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using log4jdbc 1.2 beta 2.

When I was doing performance profiling for unrelated reasons, I noticed that 
log4jdbc was using a little over 1% of my CPU time, which surprised me since I 
had almost all the log4jdbc loggers turned off and nothing was actually being 
logged. 

It looks like in the Slf4jSpyLogDelegator.sqlOccurred() method, it's calling 
processSql() before it checks if the logger is enabled.  It would be more 
efficient to check if the loggers are enabled first to avoid unnecessary 
tokenization of the SQL statement.

Original issue reported on code.google.com by dtar...@gmail.com on 7 Sep 2010 at 9:59

GoogleCodeExporter commented 9 years ago
Nice catch.  Fixed on SVN Rev. 92.  Let me know what kind of gain your profiler 
shows with this change.  I noticed that I might also be able to remove one 
extra conditional check in that method too because I believe that 
isDebugEnabled *always* implies isInfoEnabled.  I didn't make that change 
though because I don't have time to verify if that is true in all the slf4j 
supported loggers ... and the performance improvement would be very minimal.  
There are many other areas where performance could be improved.  At some point 
I will rework the design for much more performance.
Thanks!

Original comment by arthur.b...@gmail.com on 8 Sep 2010 at 2:02

GoogleCodeExporter commented 9 years ago
Looks fixed! Log4jdbc doesn't show up in the profile report any more.  I 
wouldn't worry about the extra conditional check since it seems to be 
negligible. Thanks for the quick response.

Original comment by dtar...@gmail.com on 13 Sep 2010 at 12:23