Weird performance behavior involving VarHandles

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Wed Apr 24 22:28:09 UTC 2024


Cool benchmark/test case!

I don't know off-hand where the difference could be coming from - but 
just curious: did you try accessing in a loop (e.g. to see if checks are 
hoisted as expected) ?

I seem to recall that the lambda forms for guards-with-test are rather 
complex, as they need to profile the various branches. I wonder if some 
"leftover" from the profiling code stays there and pollutes the benchmark?

Maurizio

On 24/04/2024 07:37, Remi Forax wrote:
> I get
>
> Benchmark                               Mode  Cnt  Score   Error  Units
> ReproducerBenchmarks.control            avgt    5  1.250 ± 0.024  ns/op
> ReproducerBenchmarks.gwt2_methodhandle  avgt    5  1.852 ± 0.024  ns/op
>
> and I don't understand why there is a difference in performance because
> for c2, the strings "x" and "y" are constant so the corresponding
> VarHandles should be constant thus optimized the same way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-compiler-dev/attachments/20240424/ae976e98/attachment.htm>


More information about the hotspot-compiler-dev mailing list