Fast zlib compression on the jvm
Currently the JVM provides a bundled version of zlib. Intel and Cloudflare have both provided customised tuned codebases for the x86 platforms. Unfortunately, you cannot easily override this, which will hopefully be fixed in jdk9. Nonetheless, for anyone not on jdk9, you cannot take advantage of faster compression options which are available.
So, this project makes that possible.
This requires some extra work over and above a normal JAR import to get it all working.
- Compile zlib for your platform, https://github.com/cloudflare/zlib
- Compile the native Java bindings for this zlib (code assumes zlib 1.2.8) - use
./compile-native.sh
. You will need a C compiler, the JAVA_HOME environment variable set up, and a - Use gradle to compile the code into a JAR
- Run the target code, providing LD_LIBRARY_PATH environment variable on the java command line to allow java to find the zlib implementation.
Results in a doubling of compression throughput using Cloudflare libraries vs standard JVM libraries.
Benchmark Mode Cnt Score Error Units
BenchmarkCompressors.compressFastJvm thrpt 5 43.760 ± 5.566 ops/s
BenchmarkCompressors.compressJvm thrpt 5 19.533 ± 2.931 ops/s