RFR: 8299962: Speed up compiler/intrinsics/unsafe/DirectByteBufferTest.java and HeapByteBufferTest.java

Emanuel Peter epeter at openjdk.org
Thu Jan 12 08:32:14 UTC 2023


On Wed, 11 Jan 2023 18:27:18 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> The test used a blanket `100_000` iterations to ensure C2 triggers for the relevant intrinsics of `jdk.internal.misc.Unsafe`.
>> 
>> I experimented lowering the number of iterations, and got the following results:
>> `100_000` (overkill, 8.5 sec) `5000`(very safe, 3 sec), `2000`(decent, 2.6 sec) and even `200` (ok, 2.5 sec).
>> I measured the time per `@run` statement (there are 6 over the two test files).
>> 
>> For `5000` I got the same count of intrinsifications per intrinsic.
>> For `2000` it dropped slightly, rarely an intrinsic was not intrinsified.
>> For `200` it dropped a bit more, and sometimes multiple intrinsics are not intrinsified.
>> 
>> If one uses `-Xbatch -X:-TieredCompilation`, then the cound does not change at all, even for `200`.
>> 
>> Since the marginal speedup from `5000` to `200` is very small, I decided to be on the **safe side**.
>> This is still a **speedup of 2.7x**.
>
> Default C2 compilation threshold is around 10000. So 5000 is not safe.
> Instead I suggest to use `-XX:CompileThresholdScaling=` together with small `iterations` numbers which guarantees C2 compilation.

@vnkozlov Something I failed to mention in the description:
In [ByteBufferTest.java](https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/compiler/intrinsics/unsafe/ByteBufferTest.java) (which is the implementation of both tests) we have lots of inner loops, which all have at least `100` iterations. The buffer has a length of `1024`, the element size is maximally `8` bytes. In those inner loops, we do all the buffer-operations, which lead to the `Unsafe` intrinsics.
So then if we take even the OSR C2 threshold of `Tier4BackEdgeThreshold=40000`, I would assume that an outer iteration count of `40_000 / 100 = 400` would have to suffice.
I analyzed the `PrintInlining` statements, and it seems to really be ok for `5000`, also for `2000` in most cases.

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

PR: https://git.openjdk.org/jdk/pull/11944


More information about the hotspot-compiler-dev mailing list