RFR: 8367158: C2: create better fill and copy benchmarks, taking alignment into account [v2]

Emanuel Peter epeter at openjdk.org
Thu Dec 11 07:37:38 UTC 2025


On Thu, 11 Dec 2025 05:37:48 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> Emanuel Peter has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 16 additional commits since the last revision:
>> 
>>  - small modulo fix from review suggestion
>>  - Merge branch 'master' into JDK-8367158-fill-and-copy-benchmarks
>>  - more MS types
>>  - fix MS fill
>>  - more backing types
>>  - object array benchmarks
>>  - fix bm
>>  - ms bm update
>>  - clean up benchmark
>>  - more types
>>  - ... and 6 more: https://git.openjdk.org/jdk/compare/f0212361...80378aea
>
> test/micro/org/openjdk/bench/vm/compiler/VectorBulkOperationsArray.java line 61:
> 
>> 59: @Fork(value = 1)
>> 60: public class VectorBulkOperationsArray {
>> 61:     @Param({  "0",  "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",
> 
> How about larger values?

I am currently more interested in small iteration counts. That's where we see very interesting patterns. But you can always set the parameter from the outside when you run the JMH. These are just some reasonable defaults ;)

> test/micro/org/openjdk/bench/vm/compiler/VectorBulkOperationsArray.java line 114:
> 
>> 112:     public static final int REGION_2_OBJECT_OFFSET = REGION_2_BYTE_OFFSET / 8;
>> 113: 
>> 114:     // The arrays with the two regions each
> 
> Is there a reason you don't want to have 2 arrays, one as `dst` and one as `src`?

Maybe I need to add some extra comments. The issue is that if you have 2 arrays, you don't know their relative alignment. You also don't have control over their distance modulo 4k. And I would like to avoid 4k aliasing effects that you get on x86 machines because of the store-to-load-forwarding only checking 12bits of the address.

> test/micro/org/openjdk/bench/vm/compiler/VectorBulkOperationsArray.java line 202:
> 
>> 200: 
>> 201:     @Benchmark
>> 202:     public void fill_zero_byte_loop() {
> 
> Should these benchmarks be annotated with `@OperationsPerInvocation`?

Ah, I did not know about this. Neat idea!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/27315#discussion_r2609499810
PR Review Comment: https://git.openjdk.org/jdk/pull/27315#discussion_r2609497670
PR Review Comment: https://git.openjdk.org/jdk/pull/27315#discussion_r2609494361


More information about the hotspot-compiler-dev mailing list