Thread: 42.0.0.jre7, driver logging takes 30-40% of my server's time
I tried to paste an image with a profile, but my email was rejected. It seems logging is called in places like row.getInt(), row.getString() etc without a check for the logging level. Then it takes a lot of time for those to be processed, especially for queries that get a lot of data. It goes down to parsing strings and locale and it just is slow. I see postgres processing a query for 1 sec but on the java side it takes 5 secs to get the data back to my code. Part of this slowdown is due to the logging. Can it be optimized, i.e. having a boolean to true/false if logging is enabled and then do the calls? Thanks
Hi Vladimir, here are the results from my test of PosgtresSQL JDBC 9.4.1212 vs 42.0.0 (as I mentioned on github). It is a single run in a VM but it is ease to have several runs. IMO the results don't show performance degradation at least for the tested simple testcases - yes, there are some fluctuations but nothing significant. The computer I'm running the VM is using very modest Intel Celeron N3150. If someone has access to more powerful hardware it will be good to run the tests also - the current setup is not so good in detecting small changes in performance - too much time is spend in CPU emulation in the VM. I'm using the code base of TFB and particularly the Java/servlet implementation. The code is NOT having a logging framework in the classpath. At least I'm not aware of it and I've checked the maven dependencies. The servlet container is Resin 4.0.48. If anyone wish to take a look don't forget to provide the correct maven profile (-P v42 or -P v9). The logs of the run are here: https://github.com/zloster/logs/tree/master/FrameworkBenchmarks/postgreJDBC-9.4.1212-vs-42.0.0 The numbers are here: https://github.com/zloster/logs/blob/master/FrameworkBenchmarks/postgreJDBC-9.4.1212-vs-42.0.0/results.json The servlet implementation is here: https://github.com/zloster/FrameworkBenchmarks/tree/postgrejdbc/frameworks/Java/servlet The branch is here: https://github.com/zloster/FrameworkBenchmarks/tree/postgrejdbc For other details consult the logs or ask me. About https://github.com/pgjdbc/pgjdbc/issues/793 - it should be fairly easy to have a servlet with Log4j logger and some servlet with some other logger also. Even if the test tables are very small there are quite a lot of resultset processing. If there is performance degradation maybe it will show up as a difference. Cheers, zloster