RFR: 8331724: Refactor j.l.constant implementation to internal package [v9]
Claes Redestad
redestad at openjdk.org
Tue May 14 17:34:12 UTC 2024
On Tue, 14 May 2024 17:25:37 GMT, Claes Redestad <redestad at openjdk.org> wrote:
>> This PR suggests refactoring the implementation classes of java.lang.constant into a new package jdk.internal.constant to enable sharing some trusted static factory methods with users elsewhere in java.base, such as java.lang.invoke and java.lang.classfile. The refactoring also adds some "trusted" methods for use when input is pre-validated, and makes use of them where applicable in the current implementation. There are more changes in the pipeline which will be folded into #17108 or PR'ed once that is integrated.
>>
>> There are two optimizations mixed up here. One in `MethodTypeDesc.ofDescriptor`:
>>
>> Name (descString) Cnt Base Error Test Error Unit Change
>> MethodTypeDescFactories.ofDescriptor (Ljava/lang/Object;Ljava/lang/String;)I 6 138,371 ± 0,767 136,939 ± 1,126 ns/op 1,01x (p = 0,000*)
>> MethodTypeDescFactories.ofDescriptor ()V 6 10,528 ± 2,495 4,110 ± 0,047 ns/op 2,56x (p = 0,000*)
>> MethodTypeDescFactories.ofDescriptor ([IJLjava/lang/String;Z)Ljava/util/List; 6 209,390 ± 4,583 196,175 ± 3,211 ns/op 1,07x (p = 0,000*)
>> MethodTypeDescFactories.ofDescriptor ()[Ljava/lang/String; 6 36,039 ± 8,684 20,794 ± 1,110 ns/op 1,73x (p = 0,000*)
>> MethodTypeDescFactories.ofDescriptor (..IIJ)V 6 279,139 ± 6,248 187,934 ± 0,857 ns/op 1,49x (p = 0,000*)
>> MethodTypeDescFactories.ofDescriptor (.....................). 6 2174,387 ± 132,879 1150,652 ± 3,158 ns/op 1,89x (p = 0,000*)
>> * = significant
>>
>>
>> The other in `ClassDesc::nested`, where to get rid of a simple static method in `ConstantUtils` I ended up speeding up and simplifying the public factory method:
>>
>> Name Cnt Base Error Test Error Unit Change
>> ClassDescFactories.ReferenceOnly.ofNested 6 209,853 ± 132,525 22,017 ± 0,573 ns/op 9,53x (p = 0,000*)
>> * = significant
>>
>>
>> The optimizations could be split out and PRd independently, but I think they are simple enough to include in this refactoring.
>
> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>
> Add microbenchmark for ClassDesc methods + a few optimizations
Added a few microbenchmarks, and a couple of optimizations:
Name Cnt Base Error Test Error Unit Change
ClassDescMethods.arrayType 15 49,922 ± 0,616 14,546 ± 0,524 ns/op 3,43x (p = 0,000*)
:gc.alloc.rate.norm 312,000 ± 0,000 144,000 ± 0,000 B/op 0,46x (p = 0,000*)
ClassDescMethods.arrayType1 15 37,764 ± 0,625 14,441 ± 0,272 ns/op 2,62x (p = 0,000*)
:gc.alloc.rate.norm 312,000 ± 0,000 144,000 ± 0,000 B/op 0,46x (p = 0,000*)
ClassDescMethods.arrayType2 15 48,663 ± 0,168 35,223 ± 6,517 ns/op 1,38x (p = 0,000*)
:gc.alloc.rate.norm 360,000 ± 0,000 256,000 ± 0,000 B/op 0,71x (p = 0,000*)
ClassDescMethods.displayName 15 9,663 ± 0,326 9,285 ± 0,334 ns/op 1,04x (p = 0,002*)
:gc.alloc.rate.norm 48,000 ± 0,000 48,000 ± 0,000 B/op 1,00x (p = 0,002 )
ClassDescMethods.packageName 15 39,387 ± 1,134 31,242 ± 5,554 ns/op 1,26x (p = 0,000*)
:gc.alloc.rate.norm 168,000 ± 0,000 96,000 ± 0,000 B/op 0,57x (p = 0,000*)
* = significant
This can be broken out to a follow-up PR, naturally.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19105#issuecomment-2110768382
More information about the core-libs-dev
mailing list