Re: RFR: 8306075: Micro-optimize Enum.hashCode [v2]

2023-04-18 Thread Aleksey Shipilev
On Tue, 18 Apr 2023 19:23:59 GMT, Viktor Klang wrote: > In such a case, would it not be "better" to base the HC on > getClass().getName().hashCode() which is specced and stable mixed with the > ordinal to improve distribution over the 32-bit space? Maybe, even though it still raises lots of co

Re: RFR: 8306075: Micro-optimize Enum.hashCode [v2]

2023-04-18 Thread Viktor Klang
On Tue, 18 Apr 2023 09:02:34 GMT, Aleksey Shipilev wrote: >>> > > Why isn't `Enum::hashCode` simply doing `return ordinal;`? >>> > >>> > >>> > See https://bugs.openjdk.org/browse/JDK-8050217 >>> >>> Thanks! If there are apps where `Enum::hashCode` is performance sensitive >>> then run-to-run

Re: RFR: 8306075: Micro-optimize Enum.hashCode [v2]

2023-04-18 Thread Aleksey Shipilev
On Mon, 17 Apr 2023 21:12:58 GMT, Jorn Vernee wrote: > (if anything, using the ordinal would be _more_ stable, since it is only > affected by the order of the constants, rather than by other code that runs > before the identity hash code is generated). Here lies the major original concern -- t

Re: RFR: 8306075: Micro-optimize Enum.hashCode [v2]

2023-04-17 Thread Jorn Vernee
On Mon, 17 Apr 2023 13:40:02 GMT, Claes Redestad wrote: > > > Why isn't `Enum::hashCode` simply doing `return ordinal;`? > > > > > > See https://bugs.openjdk.org/browse/JDK-8050217 > > Thanks! If there are apps where `Enum::hashCode` is performance sensitive > then run-to-run stability may be

Re: RFR: 8306075: Micro-optimize Enum.hashCode [v2]

2023-04-17 Thread Claes Redestad
On Mon, 17 Apr 2023 13:27:43 GMT, olivergillespie wrote: > > Why isn't `Enum::hashCode` simply doing `return ordinal;`? > > See https://bugs.openjdk.org/browse/JDK-8050217 Thanks! If there are apps where `Enum::hashCode` is performance sensitive then run-to-run stability may be a stronger argu

Re: RFR: 8306075: Micro-optimize Enum.hashCode [v2]

2023-04-17 Thread olivergillespie
On Mon, 17 Apr 2023 13:26:49 GMT, Claes Redestad wrote: > Why isn't `Enum::hashCode` simply doing `return ordinal;`? See https://bugs.openjdk.org/browse/JDK-8050217 - PR Comment: https://git.openjdk.org/jdk/pull/13491#issuecomment-1511350037

Re: RFR: 8306075: Micro-optimize Enum.hashCode [v2]

2023-04-17 Thread Claes Redestad
On Mon, 17 Apr 2023 13:23:35 GMT, olivergillespie wrote: >> Improve the speed of Enum.hashCode by caching the identity hashcode on first >> use. I've seen an application where Enum.hashCode is a hot path, and this is >> fairly simple speedup. The memory overhead is low; in enums with no extra

Re: RFR: 8306075: Micro-optimize Enum.hashCode [v2]

2023-04-17 Thread olivergillespie
> Improve the speed of Enum.hashCode by caching the identity hashcode on first > use. I've seen an application where Enum.hashCode is a hot path, and this is > fairly simple speedup. The memory overhead is low; in enums with no extra > fields there is already a 4-byte space due to alignment so t