On Mon, 29 Apr 2024 17:45:55 GMT, Mandy Chung <mch...@openjdk.org> wrote:

> The changes look good to me but I wonder if the non-zero length check before 
> calling `arraycopy` really needed? That seems to add some noise to the code.

I recall benchmarking similar code in `MethodType` extensively, and found that 
it had a small but significant impact, especially when adding or dropping 
parameters at the end or beginning of an argument list (which is the most 
common case). Adhoc JMH:


    @Benchmark
    public MethodTypeDesc dropFirstParameter() {
        return desc.dropParameterTypes(0, 1);
    }

Name                                                                   
(descString) Cnt   Base   Error    Test   Error  Unit  Change
MethodTypeDescFactories.dropFirstParameter  
(Ljava/lang/Object;Ljava/lang/String;)I   6 20,382 ± 0,635  16,116 ± 0,737 
ns/op   1,26x (p = 0,000*)
MethodTypeDescFactories.dropFirstParameter 
([IJLjava/lang/String;Z)Ljava/util/List;   6 26,875 ± 0,652  19,863 ± 0,749 
ns/op   1,35x (p = 0,000*)
MethodTypeDescFactories.dropFirstParameter                                 
(..IIJ)V   6 29,774 ± 0,983  20,747 ± 1,181 ns/op   1,44x (p = 0,000*)
MethodTypeDescFactories.dropFirstParameter                 
(.....................).   6 33,224 ± 0,939  30,350 ± 1,739 ns/op   1,09x (p = 
0,000*)
  * = significant

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

PR Comment: https://git.openjdk.org/jdk/pull/18991#issuecomment-2083446959

Reply via email to