On Wed, 18 Mar 2026 02:25:31 GMT, Xiaohong Gong <[email protected]> wrote:
>> test/micro/org/openjdk/bench/jdk/incubator/vector/MaskLogicOperationsBenchmark.java
>> line 67:
>>
>>> 65: @Benchmark
>>> 66: public void byteMaskAndNot() {
>>> 67: VectorMask<Byte> vm1 = VectorMask.fromArray(B_SPECIES, ma, 0);
>>
>> If what is being benchmarked is the loop, would it make sense to move this
>> to `@Setup`? Same thing for the other benchmarks below.
>
> Thanks so much for looking at this PR!
>
>> If what is being benchmarked is the loop, would it make sense to move this
>> to @Setup?
>
> Yeah, moving this mask generation to `@Setup` might be fine, but it doesn’t
> really change much compared to the current version. My concerns are:
>
> 1. In `@Setup`, we would have to generate different vector masks for each
> element type (`byte, short, int, long`), and then only use the compatible one
> in each benchmark. The code wouldn’t significantly simplify things for me.
>
> 2. This brings no performance benefit. If `vm1` is created in `@Setup
> init()`, the vector mask still has to be unboxed in the benchmark method
> before it is used. Vector unboxing is heavier than using the `fromArray()`
> API directly, since it requires two memory loads (loading the vector mask
> object, then loading its payload) while only one for the latter. Even though
> all of this happens outside the loop, it doesn’t help with performance
> measurement, right?
I think @XiaohongGong is right. We need to load the mask from memory anyway -
might as well load it from an array.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/30013#discussion_r2999546464