JDK-8242848 : Improve performance of InflaterOutputStream.write()
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.util.jar
  • Affected Version: 8,11,15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-15
  • Updated: 2022-03-13
  • Resolved: 2020-04-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b21Fixed
Related Reports
Duplicate :  
Relates :  
Sub Tasks
JDK-8251360 :  
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 a size of ~(512 * compression-ratio) bytes.

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).
The Release Note subtask is needed.

URL: https://hg.openjdk.java.net/jdk/jdk/rev/0a45e02c7b77 User: simonis Date: 2020-04-23 12:25:16 +0000