On Wed, 6 Nov 2024 14:15:42 GMT, jengebr <d...@openjdk.org> wrote: > This change optimizes the runtime of `Class.getMethod(String, Class<?>[])` by > reducing the cost of the existing search logic. Specifically, while > iterating across each Method to find a match (existing logic) it now compares > parameter count before checking method name. This check is substantially > faster. > > A benchmark and unit tests are included; benchmark results (below) show an > improvement in all cases, and an especially large gain when the immediate > class contains the no-arg target. > > Base: > > Benchmark Mode Cnt Score Error Units > ClassGetMethod.getConcreteFiveArg avgt 6 94.586 ± 0.733 ns/op > ClassGetMethod.getConcreteNoArg avgt 6 75.587 ± 11.300 ns/op > ClassGetMethod.getIntfFiveArg avgt 6 215.794 ± 7.713 ns/op > ClassGetMethod.getIntfNoArg avgt 6 200.418 ± 4.352 ns/op > ClassGetMethod.getNoSuchMethod avgt 10 2207.928 ± 49.767 ns/op > ClassGetMethod.getSuperFiveArg avgt 6 190.142 ± 1.995 ns/op > ClassGetMethod.getSuperNoArg avgt 6 153.943 ± 7.491 ns/op > > > Modified: > > Benchmark Mode Cnt Score Error Units > ClassGetMethod.getConcreteFiveArg avgt 6 94.409 ± 1.642 ns/op > ClassGetMethod.getConcreteNoArg avgt 6 77.748 ± 11.618 ns/op > ClassGetMethod.getIntfFiveArg avgt 6 193.816 ± 4.250 ns/op > ClassGetMethod.getIntfNoArg avgt 6 205.565 ± 9.140 ns/op > ClassGetMethod.getNoSuchMethod avgt 10 2231.248 ± 67.711 ns/op > ClassGetMethod.getSuperFiveArg avgt 6 169.971 ± 0.883 ns/op > ClassGetMethod.getSuperNoArg avgt 6 129.188 ± 8.421 ns/op
This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.org/jdk/pull/21929