{"action":"created","issue":{"url":"https://api.github.com/repos/apache/kafka/issues/580","labels_url":"https://api.github.com/repos/apache/kafka/issues/580/labels{/name}","comments_url":"https://api.github.com/repos/apache/kafka/issues/580/comments","events_url":"https://api.github.com/repos/apache/kafka/issues/580/events","html_url":"https://github.com/apache/kafka/pull/580","id":118608131,"number":580,"title":"KAFKA-2882: Add constructor cache for Snappy and LZ4 Output/Input streams in Compressor.java","user":{"login":"logarithm","id":427623,"avatar_url":"https://avatars.githubusercontent.com/u/427623?v=3","gravatar_id":"","url":"https://api.github.com/users/logarithm","html_url":"https://github.com/logarithm","followers_url":"https://api.github.com/users/logarithm/followers","following_url":"https://api.github.com/users/logarithm/following{/other_user}","gists_url":"https://api.github.com/users/logarithm/gists{/gist_id}","starred_url":"https://api.github.com/users/logarithm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/logarithm/subscriptions","organizations_url":"https://api.github.com/users/logarithm/orgs","repos_url":"https://api.github.com/users/logarithm/repos","events_url":"https://api.github.com/users/logarithm/events{/privacy}","received_events_url":"https://api.github.com/users/logarithm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-24T13:26:26Z","updated_at":"2015-11-24T16:09:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/kafka/pulls/580","html_url":"https://github.com/apache/kafka/pull/580","diff_url":"https://github.com/apache/kafka/pull/580.diff","patch_url":"https://github.com/apache/kafka/pull/580.patch"},"body":"In `wrapForOutput` and `wrapForInput` methods of `org.apache.kafka.common.record.Compressor`,  `Class.forName(\"[compression codec]\")` and `getConstructor` methods are invoked for each `wrapForOutput` / `wrapForInput` call. Reflection calls are expensive and impact performance at high volumes. This patch adds a cache for `Constructor` to reduce the reflection overhead.\r\n\r\nIn our production deployments, this has reduced producer CPU usage by about 20%"},"comment":{"url":"https://api.github.com/repos/apache/kafka/issues/comments/159316547","html_url":"https://github.com/apache/kafka/pull/580#issuecomment-159316547","issue_url":"https://api.github.com/repos/apache/kafka/issues/580","id":159316547,"user":{"login":"ijuma","id":24747,"avatar_url":"https://avatars.githubusercontent.com/u/24747?v=3","gravatar_id":"","url":"https://api.github.com/users/ijuma","html_url":"https://github.com/ijuma","followers_url":"https://api.github.com/users/ijuma/followers","following_url":"https://api.github.com/users/ijuma/following{/other_user}","gists_url":"https://api.github.com/users/ijuma/gists{/gist_id}","starred_url":"https://api.github.com/users/ijuma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ijuma/subscriptions","organizations_url":"https://api.github.com/users/ijuma/orgs","repos_url":"https://api.github.com/users/ijuma/repos","events_url":"https://api.github.com/users/ijuma/events{/privacy}","received_events_url":"https://api.github.com/users/ijuma/received_events","type":"User","site_admin":false},"created_at":"2015-11-24T16:09:03Z","updated_at":"2015-11-24T16:09:03Z","body":"Thanks for the PR, the way it's done at the moment is certainly problematic. I am not sure why we are loading these libraries via reflection though given that we specify the dependencies in our build for the clients library:\r\n\r\n```groovy\r\ncompile 'org.xerial.snappy:snappy-java:1.1.2'\r\ncompile 'net.jpountz.lz4:lz4:1.2.0'\r\n```\r\n\r\nIt seems like this would only benefit people who exclude the transitive dependency on their builds. @guozhangwang, @junrao what are your thoughts?"}}