.250 ns/op
> ClassGetMethod.getIntfNoArgavgt6 205.565 ± 9.140 ns/op
> ClassGetMethod.getNoSuchMethod avgt 10 2231.248 ± 67.711 ns/op
> ClassGetMethod.getSuperFiveArg avgt6 169.971 ± 0.883 ns/op
> ClassGetMethod.getSuperNoArg avgt6 129.18
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
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
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
&
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 additio
lassGetMethod.getNoSuchMethod avgt 10 2158.844 ± 43.716 ns/op
> ClassGetMethod.getSuperFiveArg avgt 6 129.047 ± 4.414 ns/op
> ClassGetMethod.getSuperNoArg avgt6 123.728 ± 6.182 ns/op
jengebr has updated the pull request incrementally with three additional
commi
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
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 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
On Mon, 3 Jun 2024 16:47:20 GMT, jengebr wrote:
> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless
> cloning of Object[0] instances. This cloning is intended to prevent callers
> from changing array contents, but many `CopyOnWriteArrayList`s are allocated
On Thu, 20 Jun 2024 19:17:25 GMT, jengebr wrote:
>> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless
>> cloning of Object[0] instances. This cloning is intended to prevent callers
>> from changing array contents, but many `CopyOnWriteArrayList`s ar
On Wed, 19 Jun 2024 12:52:46 GMT, Alan Bateman wrote:
>> @AlanBateman -- could you please take a look? Thanks.
>
>> @AlanBateman -- could you please take a look? Thanks.
>
> There was a lot of heap analysis done a few years ago that shined a light on
> the number of empty collections in a typic
On Thu, 20 Jun 2024 19:17:25 GMT, jengebr wrote:
>> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless
>> cloning of Object[0] instances. This cloning is intended to prevent callers
>> from changing array contents, but many `CopyOnWriteArrayList`s ar
On Wed, 19 Jun 2024 12:52:46 GMT, Alan Bateman wrote:
>> @AlanBateman -- could you please take a look? Thanks.
>
>> @AlanBateman -- could you please take a look? Thanks.
>
> There was a lot of heap analysis done a few years ago that shined a light on
> the number of empty collections in a typic
On Thu, 6 Jun 2024 12:46:36 GMT, jengebr wrote:
>> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless
>> cloning of Object[0] instances. This cloning is intended to prevent callers
>> from changing array contents, but many `CopyOnWriteArrayList`s ar
5
> 21.627 ± 0.173 ns/op
> CopyOnWriteArrayListBenchmark.createInstanceCollectionEmpty avgt5
> 12.864 ± 0.408 ns/op
> CopyOnWriteArrayListBenchmark.createInstanceDefault avgt5
> 12.931 ± 0.255 ns/op
> CopyOnWriteArrayListBenchmark.readInstance avgt
± 0.418 ns/op
> CopyOnWriteArrayListBenchmark.createInstanceCollection avgt5
> 21.627 ± 0.173 ns/op
> CopyOnWriteArrayListBenchmark.createInstanceCollectionEmpty avgt5
> 12.864 ± 0.408 ns/op
> CopyOnWriteArrayListBenchmark.createInstanceDefault avgt5
> 12.9
On Tue, 4 Jun 2024 19:58:41 GMT, jengebr wrote:
>> Agreed. You might as well be consistent with this so that no one will need
>> to re-address if some application does zillions of clones of empty lists.
>
> Sorry, I crossed wires with @DougLea 's comment, will add `clone`
On Tue, 4 Jun 2024 19:41:15 GMT, Doug Lea wrote:
>> src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java
>> line 103:
>>
>>> 101: private static final long serialVersionUID = 8673264195747942595L;
>>> 102:
>>> 103: private static final Object[] EMPTY_ELEMENTDATA =
± 0.418 ns/op
> CopyOnWriteArrayListBenchmark.createInstanceCollection avgt5
> 21.627 ± 0.173 ns/op
> CopyOnWriteArrayListBenchmark.createInstanceCollectionEmpty avgt5
> 12.864 ± 0.408 ns/op
> CopyOnWriteArrayListBenchmark.createInstanceDefault avgt5
> 12.9
On Mon, 3 Jun 2024 18:48:48 GMT, Doug Lea wrote:
> The jmh benchmark checks only the empty case, you need to also show lack of
> impact on non-empty cases.
After removing `toArray`, I think this is covered. Can you please confirm?
> Assuming you demonstrate this, it seems basically OK, (Deja
On Mon, 3 Jun 2024 17:07:28 GMT, Aleksey Shipilev wrote:
>> Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless
>> cloning of Object[0] instances. This cloning is intended to prevent callers
>> from changing array contents, but many `CopyOnWriteArrayList`s are allocated
Improve `java/util/concurrent/CopyOnWriteArrayList` by eliminating needless
cloning of Object[0] instances. This cloning is intended to prevent callers
from changing array contents, but many `CopyOnWriteArrayList`s are allocated to
size zero, or are otherwise maintained empty, so cloning is unne
On Tue, 21 May 2024 13:49:18 GMT, jengebr wrote:
> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of
> Class[0] instances. This cloning is intended to prevent callers from
> changing array contents, but many Methods have zero exceptions or zero
> par
On Fri, 31 May 2024 17:59:18 GMT, jengebr wrote:
>> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of
>> Class[0] instances. This cloning is intended to prevent callers from
>> changing array contents, but many Methods have zero exceptions or zero
2 ns/op
> MethodBenchmark.getParameterTypesEmpty avgt5 1.273 ± 0.169 ns/op
jengebr has updated the pull request incrementally with one additional commit
since the last revision:
Fixing nits in benchmark
-
Changes:
- all: https://git.openjdk.org/jdk/pull/19327/files
2 ns/op
> MethodBenchmark.getParameterTypesEmpty avgt5 1.273 ± 0.169 ns/op
jengebr has updated the pull request incrementally with one additional commit
since the last revision:
Fixing copyright message, returning values from benchmark
-
Changes:
- all: https://
2 ns/op
> MethodBenchmark.getParameterTypesEmpty avgt5 1.273 ± 0.169 ns/op
jengebr has updated the pull request incrementally with one additional commit
since the last revision:
rewriting JMH per comments
-
Changes:
- all: https://git.openjdk.org/jdk/pull/19327/files
On Fri, 31 May 2024 16:53:36 GMT, jengebr wrote:
>> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of
>> Class[0] instances. This cloning is intended to prevent callers from
>> changing array contents, but many Methods have zero exceptions or zero
s sufficient.
jengebr has updated the pull request incrementally with one additional commit
since the last revision:
Correcting and renaming benchmark
-
Changes:
- all: https://git.openjdk.org/jdk/pull/19327/files
- new: https://git.openjdk.org/jdk/pull/19327/files/4865dede..31b64
exceptions or zero
>> parameters, and returning the original `Class[0]` is sufficient.
>
> Please also enable GHA testing: https://github.com/jengebr/jdk/actions. You
> may need to trigger the test run manually after this, since the PR hook have
> already missed it. Go to "OpenJD
s sufficient.
jengebr has updated the pull request incrementally with one additional commit
since the last revision:
Adding JMH benchmark
-
Changes:
- all: https://git.openjdk.org/jdk/pull/19327/files
- new: https://git.openjdk.org/jdk/pull/19327/files/3202c8cb..4865dede
Webr
On Wed, 22 May 2024 13:44:59 GMT, Chen Liang wrote:
>> @liach I see such an opportunity in `Proxy.getProxyConstructor`, is that
>> what you have in mind?
>
> No, I mean here:
> https://github.com/openjdk/jdk/blob/4f1a10f84bcfadef263a0890b6834ccd3d5bb52f/src/java.base/share/classes/java/lang/Cla
On Thu, 23 May 2024 09:05:09 GMT, Aleksey Shipilev wrote:
>> Alternatively, if a utility method is overkill, we can inline these to
>> `Executable`:
>>
>> public Class[] getParameterTypes() {
>> var shared = getSharedParameterTypes();
>> return shared.length == 0 ? shared : shared.clone
On Wed, 22 May 2024 10:27:16 GMT, Chen Liang wrote:
>> src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java line
>> 249:
>>
>>> 247: * the original can safely be reused.
>>> 248: */
>>> 249: public Class[] copyClasses(Class[] classes) {
>>
>> There is no need t
On Fri, 24 May 2024 21:59:58 GMT, Chen Liang wrote:
> Can you update the ending copyright years from 2023 to 2024 on the 2nd line
> of the 2 modified files?
Done, thank you.
-
PR Comment: https://git.openjdk.org/jdk/pull/19327#issuecomment-2135215681
On Wed, 22 May 2024 09:44:18 GMT, Aleksey Shipilev wrote:
> Please also enable GHA testing: https://github.com/jengebr/jdk/actions. You
> may need to trigger the test run manually after this, since the PR hook have
> already missed it. Go to "OpenJDK Sanity Checks" on th
Improve `java/lang/reflect/Method.java` by eliminating needless cloning of
Class[0] instances. This cloning is intended to prevent callers from changing
array contents, but smany Methods have zero exceptions or zero parameters, and
returning the original `Class[0]` is sufficient.
On Tue, 21 May 2024 13:49:18 GMT, jengebr wrote:
> Improve `java/lang/reflect/Method.java` by eliminating needless cloning of
> Class[0] instances. This cloning is intended to prevent callers from
> changing array contents, but smany Methods have zero exceptions or zero
> par
39 matches
Mail list logo