-
Enhancement
-
Resolution: Fixed
-
P4
-
8, 11, 15
-
b21
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).
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).
- duplicates
-
JDK-8242853 Improve performance of InflaterOutputStream.write()
- Closed
- relates to
-
JDK-8242864 Increase the default, internal buffer size of the Streams in java.util.zip
- Open