Vector::rearrange(Shuffle) allocations

Tomasz Kowalczewski tomasz.kowalczewski at gmail.com
Mon Jan 14 17:56:04 UTC 2019


I have a question about vector rearranges. My recent observation is
that using IntVector.rearrange causes a lot of allocations (in a JMH
microbenchmark). Is this expected? I wrote a few simple (but not
trivial) algorithms and they all did not box vectors into objects and
all tests were able to run using EpsilonGC. The intrinsic works and
vpermd instruction is emitted.

There are 64 bytes allocated per benchmark iteration in the following
code (the addAll is used so that vector does not escape the method):

@Benchmark
public int rearrange() {
    IntVector input = SPECIES_I256.fromArray(inputArray, 0);
    IntVector rearrangedVector = input.rearrange(SHUFFLE_1);

    return rearrangedVector.addAll();
}

There is no allocation in following code:

@Benchmark
public int noRearrange() {
    IntVector input = SPECIES_I256.fromArray(inputArray, 0);

    return input.addAll();
}

Output from jmap -histo for first case:

 num     #instances         #bytes  class name (module)
-------------------------------------------------------
   1:       4122313      198969024  [I (java.base@)
   2:       4119794       65916704  jdk.incubator.vector.Int256Vector
(jdk.incubator.vector@)
   3:          8913         808512  [B (java.base@)
   4:          1982         222408  java.lang.Class (java.base@)
   5:          8638         207312  java.lang.String (java.base@)

Any hints will be much appreciated.
-- 
Thanks,
Tomasz Kowalczewski


More information about the panama-dev mailing list