JDK-8330108 : Increase CipherInputStream buffer size
  • Type: Enhancement
  • Component: security-libs
  • Sub-Component: javax.crypto
  • Affected Version: 17,21,22,23
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-04-11
  • Updated: 2024-04-29
  • Resolved: 2024-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 23
23 b20Fixed
Related Reports
Relates :  
Sub Tasks
JDK-8330632 :  
Description
CipherInputStream has a buffer size of 512 bytes. This is very small, and we see better performance from a larger buffer size in our applications. We sometimes see folks even hacking into CIS internals and allocating 8192-sized buffers with reflective hacks to avoid performance penalties.

As per the comment on the current buffer:

> the size 512 bytes is somewhat randomly chosen

Other examples use larger buffers, like 8192 for ChannelInputStream and FileInputStream, or 16384 for InputStream itself.
Comments
Changeset: 6158da5e Author: Oli Gillespie <ogillespie@openjdk.org> Committer: Aleksey Shipilev <shade@openjdk.org> Date: 2024-04-23 12:37:36 +0000 URL: https://git.openjdk.org/jdk/commit/6158da5e9569f4260bd6d968c940c9979583118a
23-04-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/18763 Date: 2024-04-12 15:34:01 +0000
12-04-2024

This also might help to mitigate JDK-8298249 in JDKs prior 21.
11-04-2024