[jdk16] RFR: 8260473: [vector] ZGC: VectorReshape test produces incorrect results with ZGC enabled
Vladimir Ivanov
vlivanov at openjdk.java.net
Mon Feb 1 12:47:46 UTC 2021
On Mon, 1 Feb 2021 12:15:38 GMT, 王超 <github.com+25214855+casparcwang at openjdk.org> wrote:
>>> > compileonly and compilercount=1 will let the VM run slow enough to wait for a gc to be finished.
>>>
>>> That's a strange way to provoke the bug. You could just increase the number of iterations instead.
>>>
>>> But the right way to fix it is to stress ZGC to continuously run in the background while the test case aggressively unboxes vectors in compiled code. `-Xmx256m` helps with that while `-XX:CICompilerCount=1` is irrelevant.
>>
>> Yes, it's very weird to provoke the bug like this. If CICompilerCount=1 is removed, the test failed 60% roughly on my machine.
>> And the iteration has already changed from 100 to 1000, the run time of the test is nearly 30s on release version of jvm.
>>
>> If I add the following patch, the test always fails on my machine,
>>
>> diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java b/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java
>> index 1843ec0..959b29a 100644
>> --- a/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java
>> +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java
>> @@ -44,7 +44,7 @@ import jdk.internal.vm.annotation.ForceInline;
>> * @modules jdk.incubator.vector
>> * @modules java.base/jdk.internal.vm.annotation
>> * @run testng/othervm -XX:CompileCommand=compileonly,jdk/incubator/vector/ByteVector.fromByteBuffer
>> - * -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+UseZGC -Xbatch -Xmx256m VectorRebracket128Test
>> + * -XX:-TieredCompilation -XX:+UseZGC -Xmx256m VectorRebracket128Test
>> */
>>
>> @Test
>> @@ -125,6 +125,14 @@ public class VectorRebracket128Test {
>> @ForceInline
>> static <E,F>
>> void testVectorRebracket(VectorSpecies<E> a, VectorSpecies<F> b, byte[] input, byte[] output) {
>> + new Thread(() -> {
>> + while (true) {
>> + try {
>> + System.gc();
>> + Thread.sleep(100);
>> + } catch (Exception e) {}
>> + }
>> + }).start();
>> Vector<E> av = a.fromByteArray(input, 0, ByteOrder.nativeOrder());
>> int block;
>> assert(input.length == output.length);
>
> sorry for the wrong patch above, the failed reason of the patch above is due to stack creation failure (create 1000 threads). The following is the right stress gc patch.
>
> diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java b/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java
> index 6b266db..a761ea2 100644
> --- a/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java
> +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java
> @@ -44,7 +44,7 @@ import jdk.internal.vm.annotation.ForceInline;
> * @modules jdk.incubator.vector
> * @modules java.base/jdk.internal.vm.annotation
> * @run testng/othervm -XX:CompileCommand=compileonly,jdk/incubator/vector/ByteVector.fromByteBuffer
> - * -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+UseZGC -Xbatch -Xmx256m VectorRebracket128Test
> + * -XX:-TieredCompilation -XX:+UseZGC -Xmx256m VectorRebracket128Test
> */
>
> @Test
> @@ -59,6 +59,19 @@ public class VectorRebracket128Test {
> static final VectorSpecies<Byte> bspec128 = ByteVector.SPECIES_128;
> static final VectorSpecies<Short> sspec128 = ShortVector.SPECIES_128;
>
> + static {
> + Thread t = new Thread(() -> {
> + while (true) {
> + try {
> + System.gc();
> + Thread.sleep(100);
> + } catch (Exception e) {}
> + }
> + });
> + t.setDaemon(true);
> + t.start();
> + }
> +
> static <T> IntFunction<T> withToString(String s, IntFunction<T> f) {
> return new IntFunction<T>() {
> @Override
Good. Please, file a follow-up RFE to improve the test.
-------------
PR: https://git.openjdk.java.net/jdk16/pull/139
More information about the hotspot-gc-dev
mailing list