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

Optimize MessageDigest.getInstance

    XMLWordPrintable

Details

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

    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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: