GitHub user logarithm opened a pull request: https://github.com/apache/kafka/pull/580
KAFKA-2882: Add constructor cache for Snappy and LZ4 Output/Input streams in Compressor.java 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. In our production deployments, this has reduced producer CPU usage by about 20% You can merge this pull request into a Git repository by running: $ git pull https://github.com/metamx/kafka compressor-getclass-cache Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/580.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #580 ---- commit 6c05fbd265cd595e1878d12eb2c1cdc838c80b09 Author: Maksim Logvinenko <mlogvine...@gmail.com> Date: 2015-11-24T13:21:09Z Add cache for constructors in Compressor.java ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---