{"action":"created","issue":{"url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/290","labels_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/290/labels{/name}","comments_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/290/comments","events_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/290/events","html_url":"https://github.com/pgjdbc/pgjdbc/pull/290","id":82490172,"number":290,"title":"perf: Remove expensive finalize methods from Statement and Connection","user":{"login":"Gordiychuk","id":10699594,"avatar_url":"https://avatars.githubusercontent.com/u/10699594?v=3","gravatar_id":"","url":"https://api.github.com/users/Gordiychuk","html_url":"https://github.com/Gordiychuk","followers_url":"https://api.github.com/users/Gordiychuk/followers","following_url":"https://api.github.com/users/Gordiychuk/following{/other_user}","gists_url":"https://api.github.com/users/Gordiychuk/gists{/gist_id}","starred_url":"https://api.github.com/users/Gordiychuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gordiychuk/subscriptions","organizations_url":"https://api.github.com/users/Gordiychuk/orgs","repos_url":"https://api.github.com/users/Gordiychuk/repos","events_url":"https://api.github.com/users/Gordiychuk/events{/privacy}","received_events_url":"https://api.github.com/users/Gordiychuk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-29T16:15:20Z","updated_at":"2015-05-29T18:38:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/pgjdbc/pgjdbc/pulls/290","html_url":"https://github.com/pgjdbc/pgjdbc/pull/290","diff_url":"https://github.com/pgjdbc/pgjdbc/pull/290.diff","patch_url":"https://github.com/pgjdbc/pgjdbc/pull/290.patch"},"body":"Finalize method on Statement was move to a saparete class that is lazily created if user sets \"autoCloseUnclosedStatements\"=\"true\".\r\n\r\nParameters in state \"autoCloseUnclosedStatements\"=\"false\" dramatically improves the performance of statement instantiation and reduces garbage collection overhead on several wildly used JMVs.\r\n\r\nFor demonstrate finalize overhed was add jmh benchmark like disscussed in issue  #289\r\nThe added jmh benchmark validates the performance of statement creation.\r\n\r\n```java\r\n    @Benchmark\r\n    public Statement createStatement() throws SQLException\r\n    {\r\n        Statement statement = connection.createStatement();\r\n        statement.close();\r\n        return statement;\r\n    }\r\n```\r\n\r\nI get next result on my mashin(full report: https://gist.github.com/Gordiychuk/72791b7ff5677d11117e)\r\n```\r\nBenchmark                                                           (autoCloseStatements)  Mode  Cnt     Score     Error   Units\r\nFinalizeStatement.createStatement                                                    true  avgt   10  1736,304 ? 635,108   ns/op\r\nFinalizeStatement.createStatement:ъgc.alloc.rate                                     true  avgt   10   189,397 ?  66,900  MB/sec\r\nFinalizeStatement.createStatement:ъgc.alloc.rate.norm                                true  avgt   10   328,004 ?   0,014    B/op\r\nFinalizeStatement.createStatement:ъgc.churn.PS_Eden_Space                            true  avgt   10   179,187 ? 288,014  MB/sec\r\nFinalizeStatement.createStatement:ъgc.churn.PS_Eden_Space.norm                       true  avgt   10   395,423 ? 650,689    B/op\r\nFinalizeStatement.createStatement:ъgc.count                                          true  avgt   10     6,000            counts\r\nFinalizeStatement.createStatement:ъgc.time                                           true  avgt   10  1716,000                ms\r\nFinalizeStatement.createStatement                                                   false  avgt   10    65,483 ?   3,334   ns/op\r\nFinalizeStatement.createStatement:ъgc.alloc.rate                                    false  avgt   10  1981,967 ?  99,278  MB/sec\r\nFinalizeStatement.createStatement:ъgc.alloc.rate.norm                               false  avgt   10   136,000 ?   0,001    B/op\r\nFinalizeStatement.createStatement:ъgc.churn.PS_Eden_Space                           false  avgt   10  1983,006 ? 217,843  MB/sec\r\nFinalizeStatement.createStatement:ъgc.churn.PS_Eden_Space.norm                      false  avgt   10   136,111 ?  14,225    B/op\r\nFinalizeStatement.createStatement:ъgc.churn.PS_Survivor_Space                       false  avgt   10     0,044 ?   0,033  MB/sec\r\nFinalizeStatement.createStatement:ъgc.churn.PS_Survivor_Space.norm                  false  avgt   10     0,003 ?   0,002    B/op\r\nFinalizeStatement.createStatement:ъgc.count                                         false  avgt   10    97,000            counts\r\nFinalizeStatement.createStatement:ъgc.time                                          false  avgt   10    86,000                ms\r\n```\r\n\r\nAs you can see, in that simple benchmark  we spend 20 times less GC time(86ms/1716ms) use less memory(136,111b/189,397b) and also improve in 20 times for create instance"},"comment":{"url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/comments/106899334","html_url":"https://github.com/pgjdbc/pgjdbc/pull/290#issuecomment-106899334","issue_url":"https://api.github.com/repos/pgjdbc/pgjdbc/issues/290","id":106899334,"user":{"login":"Gordiychuk","id":10699594,"avatar_url":"https://avatars.githubusercontent.com/u/10699594?v=3","gravatar_id":"","url":"https://api.github.com/users/Gordiychuk","html_url":"https://github.com/Gordiychuk","followers_url":"https://api.github.com/users/Gordiychuk/followers","following_url":"https://api.github.com/users/Gordiychuk/following{/other_user}","gists_url":"https://api.github.com/users/Gordiychuk/gists{/gist_id}","starred_url":"https://api.github.com/users/Gordiychuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gordiychuk/subscriptions","organizations_url":"https://api.github.com/users/Gordiychuk/orgs","repos_url":"https://api.github.com/users/Gordiychuk/repos","events_url":"https://api.github.com/users/Gordiychuk/events{/privacy}","received_events_url":"https://api.github.com/users/Gordiychuk/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T18:38:12Z","updated_at":"2015-05-29T18:38:12Z","body":"> Secondly and this is my fault, the docs are in a separate repo. https://github.com/pgjdbc/www\r\n\r\nDone, https://github.com/pgjdbc/www/pull/7"}}