JDK-8259065 : Optimize MessageDigest.getInstance
  • Type: Enhancement
  • Component: security-libs
  • Sub-Component: java.security
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-01-04
  • Updated: 2025-01-13
  • Resolved: 2021-01-08
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 17
17 b05Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
By caching default constructors used in java.security.Provider::newInstanceUtil in a ClassValue, we can reduce the overhead of allocating instances in a variety of places, e.g., MessageDigest::getInstance, without compromising thread-safety or security.

See: https://cl4es.github.io/2021/01/04/Investigating-MD5-Overheads.html#reflection-overheads for context. Doing this reduces memory allocations made by repeated calls to MessageDigest.getInstance("MD5") by 120 bytes/op, and I expect similar improvements would show up in more places.

Comments
Changeset: fc1d2a1e Author: Claes Redestad <redestad@openjdk.org> Date: 2021-01-08 09:20:42 +0000 URL: https://git.openjdk.java.net/jdk/commit/fc1d2a1e
08-01-2021