RFR: 8322292: Rearrange comparison of fields in Record.equals()

2023-12-18 Thread Sergey Tsypanov
Currently if we create a record it's fields are compared in their declaration order. This might be ineffective in cases when two objects have "heavy" fields equals to each other, but different "lightweight" fields (heavy and lightweight in terms of comparison) e.g. primitives, enums, nullable/no

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals()

2023-12-18 Thread Hannes Greule
On Mon, 18 Dec 2023 13:42:35 GMT, Sergey Tsypanov wrote: > Currently if we create a record it's fields are compared in their declaration > order. This might be ineffective in cases when two objects have "heavy" > fields equals to each other, but different "lightweight" fields (heavy and > ligh

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals()

2023-12-19 Thread Sergey Tsypanov
On Tue, 19 Dec 2023 06:07:31 GMT, Hannes Greule wrote: > Arrays are compared by reference Isn't `Arrays.equals()` used under the hood? > You are sorting the array passed to the bootstrap method Good point, fixed. - PR Comment: https://git.openjdk.org/jdk/pull/17143#issuecomment-1

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals()

2023-12-19 Thread Hannes Greule
On Tue, 19 Dec 2023 09:41:45 GMT, Sergey Tsypanov wrote: > Isn't `Arrays.equals()` used under the hood? The JLS and the API spec don't mention any special-casing of arrays, and the code seems to use `Objects.equals` for all non-primitive types: https://github.com/openjdk/jdk/blob/988601b324c97

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals()

2023-12-19 Thread RĂ©mi Forax
On Tue, 19 Dec 2023 11:01:12 GMT, Hannes Greule wrote: > Isn't Arrays.equals() used under the hood? No, for arrays == is used - PR Comment: https://git.openjdk.org/jdk/pull/17143#issuecomment-1863374656

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v2]

2023-12-19 Thread Sergey Tsypanov
> Currently if we create a record it's fields are compared in their declaration > order. This might be ineffective in cases when two objects have "heavy" > fields equals to each other, but different "lightweight" fields (heavy and > lightweight in terms of comparison) e.g. primitives, enums, >

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v3]

2023-12-19 Thread Sergey Tsypanov
> Currently if we create a record it's fields are compared in their declaration > order. This might be ineffective in cases when two objects have "heavy" > fields equals to each other, but different "lightweight" fields (heavy and > lightweight in terms of comparison) e.g. primitives, enums, >

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v4]

2023-12-20 Thread Sergey Tsypanov
> Currently if we create a record it's fields are compared in their declaration > order. This might be ineffective in cases when two objects have "heavy" > fields equals to each other, but different "lightweight" fields (heavy and > lightweight in terms of comparison) e.g. primitives, enums, >

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v4]

2023-12-21 Thread ExE Boss
On Wed, 20 Dec 2023 10:11:58 GMT, Sergey Tsypanov wrote: >> Currently if we create a record it's fields are compared in their >> declaration order. This might be ineffective in cases when two objects have >> "heavy" fields equals to each other, but different "lightweight" fields >> (heavy and

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v4]

2023-12-21 Thread ExE Boss
On Thu, 21 Dec 2023 14:47:43 GMT, ExE Boss wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> 8322292: Tiny improvement > > src/java.base/share/classes/java/lang/runtime/ObjectMethods.java line 227: > >> 225:

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v5]

2023-12-21 Thread Sergey Tsypanov
> Currently if we create a record it's fields are compared in their declaration > order. This might be ineffective in cases when two objects have "heavy" > fields equals to each other, but different "lightweight" fields (heavy and > lightweight in terms of comparison) e.g. primitives, enums, >

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v5]

2023-12-21 Thread Rob Spoor
On Thu, 21 Dec 2023 16:58:00 GMT, Sergey Tsypanov wrote: >> Currently if we create a record it's fields are compared in their >> declaration order. This might be ineffective in cases when two objects have >> "heavy" fields equals to each other, but different "lightweight" fields >> (heavy and

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v5]

2023-12-21 Thread ExE Boss
On Thu, 21 Dec 2023 18:30:40 GMT, Rob Spoor wrote: >> Sergey Tsypanov has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Update src/java.base/share/classes/java/lang/runtime/ObjectMethods.java >> >> Co-authored-by: ExE Boss <3889017+ex

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v6]

2023-12-22 Thread Sergey Tsypanov
> Currently if we create a record it's fields are compared in their declaration > order. This might be ineffective in cases when two objects have "heavy" > fields equals to each other, but different "lightweight" fields (heavy and > lightweight in terms of comparison) e.g. primitives, enums, >

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v5]

2023-12-22 Thread Sergey Tsypanov
On Thu, 21 Dec 2023 19:43:50 GMT, ExE Boss wrote: >> src/java.base/share/classes/java/lang/runtime/ObjectMethods.java line 224: >> >>> 222: var rt2 = mh2.type().returnType(); >>> 223: return Integer.compare( >>> 224: rt1.isPrimitive() || rt1.isEnum() || rt

Re: RFR: 8322292: Rearrange comparison of fields in Record.equals() [v6]

2024-01-20 Thread Sergey Tsypanov
On Fri, 22 Dec 2023 13:00:11 GMT, Sergey Tsypanov wrote: >> Currently if we create a record it's fields are compared in their >> declaration order. This might be ineffective in cases when two objects have >> "heavy" fields equals to each other, but different "lightweight" fields >> (heavy and