Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg [v3]

2024-11-07 Thread jengebr
> 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 substa

Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg [v3]

2024-11-07 Thread jengebr
On Wed, 6 Nov 2024 17:35:36 GMT, Chen Liang wrote: >> I don't like the style of a custom loop rather than `Arrays.equals()` but >> there is a perf benefit to it. Curious what you think? > > Sure, moving param count ahead is fine. Note that `Arrays.equals` is subject > to profile pollution at

Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg [v2]

2024-11-06 Thread jengebr
On Wed, 6 Nov 2024 17:35:36 GMT, Chen Liang wrote: > Note that Arrays.equals is subject to profile pollution at runtime, so the > benchmark results might not be applicable in practice. Good point, thank you. Should I stick with `Arrays.equals()` on the basis that it's more intuitive, and the

Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg [v2]

2024-11-06 Thread Chen Liang
On Wed, 6 Nov 2024 17:28:54 GMT, jengebr wrote: >> I benchmarked variations on this and got some surprises. The noArg change >> was removed prior to any experiments, so this is strictly the `matches()` >> optimization. >> >> Base case (no PR): >> >> Benchmark Mode C

Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg [v2]

2024-11-06 Thread jengebr
On Wed, 6 Nov 2024 17:28:08 GMT, jengebr wrote: >> src/java.base/share/classes/java/lang/PublicMethods.java line 108: >> >>> 106:Class[] ptypes) { >>> 107: // check for matching param types length, then name, then >>> param type equality >>> 108:

Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg [v2]

2024-11-06 Thread jengebr
On Wed, 6 Nov 2024 15:19:31 GMT, Chen Liang wrote: >> jengebr has updated the pull request incrementally with three additional >> commits since the last revision: >> >> - Optimizing filter logic by internalizing loop >> - Enhancing benchmark + tests with additional 5-arg cases >> - Removing

Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg [v2]

2024-11-06 Thread jengebr
> This change optimizes the runtime of `Class.getMethod(String, Class[])` in > two ways: > > 1. 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. > 2. While iterating (existin

Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg

2024-11-06 Thread jengebr
On Wed, 6 Nov 2024 15:20:42 GMT, Chen Liang wrote: >> This change optimizes the runtime of `Class.getMethod(String, Class[])` >> in two ways: >> >> 1. While iterating across each Method to find a match (existing logic) it >> now compares parameter count before checking method name. This check

Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg

2024-11-06 Thread jengebr
On Wed, 6 Nov 2024 14:15:42 GMT, jengebr wrote: > This change optimizes the runtime of `Class.getMethod(String, Class[])` in > two ways: > > 1. While iterating across each Method to find a match (existing logic) it now > compares parameter count before checking method name. This check is > s

Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg

2024-11-06 Thread Chen Liang
On Wed, 6 Nov 2024 14:15:42 GMT, jengebr wrote: > This change optimizes the runtime of `Class.getMethod(String, Class[])` in > two ways: > > 1. While iterating across each Method to find a match (existing logic) it now > compares parameter count before checking method name. This check is > s

Re: RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg

2024-11-06 Thread Chen Liang
On Wed, 6 Nov 2024 14:15:42 GMT, jengebr wrote: > This change optimizes the runtime of `Class.getMethod(String, Class[])` in > two ways: > > 1. While iterating across each Method to find a match (existing logic) it now > compares parameter count before checking method name. This check is > s

RFR: 8343559: Optimize Class.getMethod(String, Class...) for methods with no-arg

2024-11-06 Thread jengebr
This change optimizes the runtime of `Class.getMethod(String, Class[])` in two ways: 1. 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. 2. While iterating (existing logic) if th