Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8259065

Optimize MessageDigest.getInstance

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • None
    • security-libs
    • None

      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.

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: