On Wed, 24 Jan 2024 15:25:28 GMT, Oli Gillespie <ogilles...@openjdk.org> wrote:
> Avoid expensive `Class.forName` call when constructing Providers such as > `SecureRandom` which take constructor parameters. This can easily be cached > in EngineDescription (this cache already existed before, it was removed in > [JDK-8280970](https://bugs.openjdk.org/browse/JDK-8280970) as unused, I'm > bringing it back unchanged to support this new usage). > > Benchmark results on my Linux x86 host show around a 20% reduction in time to > create a new `SecureRandom` instance. Most of the remaining overhead is due > to a failing constructor lookup - see > [JDK-8324648](https://bugs.openjdk.org/browse/JDK-8324648). > > > Before > newSecureRandom avgt 2930 ± 50 ns/op > > After > newSecureRandom avgt 2400 ± 33 ns/op > > > I have seen multiple real-world applications which call `new SecureRandom()` > on the hot path, so I believe efficiency here is important. This pull request has now been integrated. Changeset: 8ef918d6 Author: Oli Gillespie <ogilles...@openjdk.org> Committer: Weijun Wang <wei...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/8ef918d6678437a5b351b172bb4cf144eeaa975f Stats: 61 lines in 2 files changed: 47 ins; 1 del; 13 mod 8324646: Avoid Class.forName in SecureRandom constructor Reviewed-by: shade, weijun ------------- PR: https://git.openjdk.org/jdk/pull/17559