On Mon, 19 Aug 2024 23:14:06 GMT, Shaojin Wen <d...@openjdk.org> wrote:

>> The current implementation of ofDescriptor puts return type and parameter 
>> types together in an ArrayList, and then splits them into return type and 
>> array of parameter types. This ArrayList creation is unnecessary, 
>> considering most descriptors only have few parameter types.
>> 
>> By splitting return type and parameter types separately and scanning the 
>> descriptor first to get the number of parameters, we can just allocate an 
>> exact, trusted array for the resulting MethodTypeDesc without copy.
>
> Shaojin Wen has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   less changes with suggestions from @liach

It would seem the specialization for `Ljava/lang/Object;` (via 
`String::regionMatches`) hurts interpreted performance, putting into doubt 
whether that optimization is fruitful for startup performance. `-Xint` numbers:

Name                                                        (descString) Cnt    
   Base      Error        Test       Error  Unit  Change
ofDescriptor                     (Ljava/lang/Object;Ljava/lang/String;)I   6   
7734,757 ±  154,894   10463,211 ±    61,369 ns/op   0,74x (p = 0,000*)
ofDescriptor                                                         ()V   6   
1346,374 ±   56,956     527,418 ±    54,952 ns/op   2,55x (p = 0,000*)
ofDescriptor    (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;   6   
9873,260 ±  118,592   13512,378 ±    44,295 ns/op   0,73x (p = 0,000*)
ofDescriptor    (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;   6   
9790,973 ±  196,979   15078,814 ±   154,289 ns/op   0,65x (p = 0,000*)
ofDescriptor (Ljava/lang/Integer;Ljava/lang/Integer;)Ljava/lang/Integer;   6   
9963,069 ±  126,510    9610,144 ±  1952,719 ns/op   1,04x (p = 0,270 )
ofDescriptor                                        ()Ljava/lang/Object;   6   
3730,028 ±  757,223    4314,956 ±   460,108 ns/op   0,86x (p = 0,002*)
ofDescriptor                    ([IJLjava/lang/String;Z)Ljava/util/List;   6   
8909,754 ±   93,260    9004,239 ±   917,012 ns/op   0,99x (p = 0,512 )
ofDescriptor                                       ()[Ljava/lang/String;   6   
3710,475 ±  171,494    3159,694 ±    67,448 ns/op   1,17x (p = 0,000*)
ofDescriptor                                                    (..IIJ)V   6  
18670,031 ±  257,048   17178,329 ±   544,327 ns/op   1,09x (p = 0,000*)
ofDescriptor                                           ([III.Z[B..[.[B).   6  
45623,579 ± 8342,076   46138,662 ± 13494,653 ns/op   0,99x (p = 0,829 )
ofDescriptor                                    (.....................).   6 
166686,442 ± 3550,565  167529,385 ± 11210,813 ns/op   0,99x (p = 0,640 )
  * = significant

-------------

PR Comment: https://git.openjdk.org/jdk/pull/20611#issuecomment-2298473472

Reply via email to