RFR: 8285633: Take better advantage of generic MethodType cache [v2]

Claes Redestad redestad at openjdk.java.net
Tue Apr 26 21:00:54 UTC 2022


On Tue, 26 Apr 2022 19:30:31 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Right.. I did a quick experiment and there's a large speed-up in the trivial `methodType(obj, obj)` case:
>> 
>> Benchmark                                      Mode  Cnt   Score   Error  Units
>> MethodTypeAcquire.testObjectObjectNonConstant  avgt    5  30.052 ? 3.440  ns/op # baseline
>> MethodTypeAcquire.testObjectObjectNonConstant  avgt    5  1.171  ? 0.001  ns/op # patch
>> 
>> 
>> I'll add a non-constant variant for the multi-arg Object variants, too. It should scale linearly and see a gain in the same ballpark. I think we need to keep the number of microbenchmarks here somewhat under control, though.
>
> That sounds good, thanks

Added 3 micros I think carry their own weight as they assess some different major pathways through the caching fast-path.

Baseline:

Benchmark                                             Mode  Cnt   Score   Error  Units
MethodTypeAcquire.testMultiPType_ObjectAndA_NonConst  avgt   15  63.523 ? 2.452  ns/op
MethodTypeAcquire.testMultiPType_ObjectOnly_NonConst  avgt   15  57.770 ? 0.501  ns/op
MethodTypeAcquire.testObjectObject_NonConst           avgt   15  30.090 ? 0.251  ns/op

Patched:

Benchmark                                             Mode  Cnt   Score    Error  Units
MethodTypeAcquire.testMultiPType_ObjectAndA_NonConst  avgt   15  64.570 ?  0.410  ns/op
MethodTypeAcquire.testMultiPType_ObjectOnly_NonConst  avgt   15   4.735 ?  0.063  ns/op
MethodTypeAcquire.testObjectObject_NonConst           avgt   15   1.171 ?  0.001  ns/op

The relative speed-up diminishes a bit for the loopy 6-arg `methodType` calls, but is still a healthy 12x. Overhead on the negative test might be there but is very much in the noise on my tests (tried doubling warmup time to no avail)

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

PR: https://git.openjdk.java.net/jdk/pull/8398


More information about the core-libs-dev mailing list