You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Elasticsearch we have recently introduced lz4 as a compression option. We run with the SecurityManger enabled and generally disallow unsafe usage. So our usage of lz4-java is the safe variety. After exploring, we have determined that adding the usage of Arrays#mismatch and VarHandles significantly improve the performance of compression and decompression. I introduced a temporarily forked version lz4-java which uses these methods here.
My JMH benchmarks of compressing and decompressing highly compressible JSON data on m5d.4xlarge;
I did not benchmark checksumming as it is not relevant to our use case, but using VarHandles will also improve performance presumably. As an FYI, I think the unsafe decompression is currently hurt by this issue here.
Obviously lz4-java must support Java8 (and currently supports Java7). I explored MethodHandles as a way to access the Java9 methods. I have opened a POC PR against a version of Elasticsearch which still supports Java8. If you look at the forked SafeUtils and LZ4SafeUtils classes you can see how MethodHandles can be used to call VarHandles when they are available. I benchmarked these changes and they have similar performance as direct Java9 usage.
The fallback benchmarks are the performance with the MethodHandle approach when the VarHandles are not available in the JDK. The decompress fallback version had a minor performance degradation, but I think that can be resolved with a slightly different approach (which I would use in a PR to lz4-java).
I am raising this issue to see if there is an interest in me contributing the MethodHandle variant back. In order to support Java9 lz4-java could also use multi version release JARs. I prototyped this, but the bnd library that lz4-java uses to produce OSGI compatible bundles does not support the multi release format.
Based on that (and my limited knowledge of OSGI) it seems like MethodHandles are the best way forward. Let me know if you are interested. I can contribute the changes I have put together in Elasticsearch. Additionally, I will expand them to make sure they apply to all components (compression, decompression, and checksumming).
In Elasticsearch we have recently introduced lz4 as a compression option. We run with the
SecurityManger
enabled and generally disallow unsafe usage. So our usage of lz4-java is the safe variety. After exploring, we have determined that adding the usage ofArrays#mismatch
andVarHandles
significantly improve the performance of compression and decompression. I introduced a temporarily forked version lz4-java which uses these methods here.My JMH benchmarks of compressing and decompressing highly compressible JSON data on m5d.4xlarge;
I did not benchmark checksumming as it is not relevant to our use case, but using
VarHandles
will also improve performance presumably. As an FYI, I think the unsafe decompression is currently hurt by this issue here.Obviously lz4-java must support Java8 (and currently supports Java7). I explored MethodHandles as a way to access the Java9 methods. I have opened a POC PR against a version of Elasticsearch which still supports Java8. If you look at the forked
SafeUtils
andLZ4SafeUtils
classes you can see howMethodHandles
can be used to callVarHandles
when they are available. I benchmarked these changes and they have similar performance as direct Java9 usage.The fallback benchmarks are the performance with the
MethodHandle
approach when theVarHandles
are not available in the JDK. The decompress fallback version had a minor performance degradation, but I think that can be resolved with a slightly different approach (which I would use in a PR to lz4-java).I am raising this issue to see if there is an interest in me contributing the
MethodHandle
variant back. In order to support Java9 lz4-java could also use multi version release JARs. I prototyped this, but the bnd library that lz4-java uses to produce OSGI compatible bundles does not support the multi release format.Based on that (and my limited knowledge of OSGI) it seems like
MethodHandles
are the best way forward. Let me know if you are interested. I can contribute the changes I have put together in Elasticsearch. Additionally, I will expand them to make sure they apply to all components (compression, decompression, and checksumming).This is related to #151.
The text was updated successfully, but these errors were encountered: