RFR: 8331264: Reduce java.lang.constant initialization overhead [v3]

Claes Redestad redestad at openjdk.org
Mon Apr 29 19:01:05 UTC 2024


On Mon, 29 Apr 2024 17:45:55 GMT, Mandy Chung <mchung at 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


More information about the core-libs-dev mailing list