JDK-8242853 : Improve performance of InflaterOutputStream.write()
  • Type: Enhancement
  • Component: performance
  • Affected Version: 8,11,15
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2020-04-15
  • Updated: 2020-04-15
  • Resolved: 2020-04-15
Related Reports
Duplicate :  
Description
InflaterOutputStream has an internal buffer which is used for the inflated data. This buffer can be configured to a custom size (the default is 512 bytes) by using the specialized "InflaterOutputStream(OutputStream out, Inflater infl, int bufLen)" constructor. A bigger buffer, results in fewer native calls to "write()" on the associated OutputStream and better overall performance.

Unfortunately "InflaterOutputStream.write(byte[] b, int off, int len)" unnecessarily chunks its byte input buffer "b" into pieces of maximum 512 bytes before feeding them to the underlying Inflater. This unnecessarily increases the number of native calls to Inflater.inflate() and limits the benefit of the configurable internal buffer to ~(512 * compression-ratio).

Instead, we could easily pass the complete input buffer "b" as input to the underlying Inflater. This simplifies the code and results in up to ~25% performance improvements for bigger internal buffers (see attached JMH benchmark).

Comments
Duplicate of JDK-8242848 because of JIRA authentication problems.
15-04-2020