Wednesday, 16 August 2017

Faster GZIP compression on the JVM

JVM compression benchmarks abound. Snappy and other compression libraries are often tagged as the go-to as they are quite a lot faster.

However, GZIP and the deflate algorithm is a very widely supported format with reasonably good performance. What if I told you you could get double the speed from gzip on Java?

Cloudflare have in fact done some excellent work tuning the open source zlib implementation, however this code is not available on the JVM, as it is a C library. The zlib implementation provided by Java is an older version, and overriding with LD_LIBRARY_PATH etc is not possible as the library is bundled.

Until now ..

I have packaged together some of the existing C and Java JNI code along with a few modifications, which allows you to call directly to an imported zlib library of your choosing! Include Cloudflare library for example and you will get more than 2x performance.

Benchmark results are excellent:

Benchmark                                Mode  Cnt   Score   Error  Units
BenchmarkCompressors.compressCloudflare  thrpt    5  43.760 ± 5.566  ops/s
BenchmarkCompressors.compressJvm         thrpt    5  19.533 ± 2.931  ops/s


  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.

  2. Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information speciall development I care for such info a lot.
    wordpress development Sydney

  3. I appreciate your efforts because it conveys the message of what you are trying to say. It's a great skill to make even the person who doesn't know about the subject could able to understand the subject . Your blogs are understandable and also elaborately described. I hope to read more and more interesting articles from your blog. All the best.

    rpa training in bangalore
    best rpa training in bangalore
    RPA training in bangalore
    rpa course in bangalore
    rpa training in chennai
    rpa online training