On Fri, 18 Dec 2020 15:24:21 GMT, Claes Redestad <redes...@openjdk.org> wrote:
> Might be fun to try, but it looks like rewriting to have MD5 to only use > transient state will be a significant effort, and might just end up shuffling > over allocations from `getInstance` to `digest`, which could regress code > that reuse a digest instance (in a thread safe manner). I've thought about using `ThreadLocal` at holder level and my naive benchmark shows significant improvement in speed compared to current implementation: https://gist.github.com/JarvisCraft/61cd45f83aea7f33cba9510e523a5c4e As of the state from single thread's perspective, it seems to be safe to reuse `MessageDigest` in this case: > The `digest` method can be called once for a given number of updates. After > `digest` has been called, the MessageDigest object is reset to its > initialized state. ------------- PR: https://git.openjdk.java.net/jdk/pull/1821