8260473: [vector] ZGC: VectorReshape test produces incorrect results with ZGC enabled #139
Conversation
|
@casparcwang The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
/cc hotspot-gc /contributor add Wang Chao casparcwang@tencent.com |
@casparcwang |
@casparcwang Could not parse
|
@casparcwang |
/contributor add @casparcwang |
@casparcwang Could not parse
|
/contributor add Wang Chao casparcwang@tencent.com |
@DamonFool Only the author (@casparcwang) is allowed to issue the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, looks good.
* @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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why -XX:CICompilerCount=1
and -Xmx256m
are needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
-XX:CICompilerCount=1
and-Xmx256m
are needed?
Thanks @iwanowww for your review.
I discussed the same question with @casparcwang offline.
The reason is:
- Small heap (-Xmx256m) will help to trigger a gc.
- compileonly and compilercount=1 will let the VM run slow enough to wait for a gc to be finished.
And @casparcwang told me that this bug seems not to be reproduced every time without these JVM args.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. Please, file a follow-up RFE to improve the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. Please, file a follow-up RFE to improve the test.
OK.
I will help to file a JBS bug once the fix has been merged into the jdk mainline.
It will be only fixed in the jdk17, right?
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. Please, file a follow-up RFE to improve the test.
The RFE has been filed here: https://bugs.openjdk.java.net/browse/JDK-8261152
Thanks.
|
@casparcwang This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been no new commits pushed to the As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@iwanowww, @neliasso) but any other Committer may sponsor as well.
|
/contributor add Wang Chao casparcwang@tencent.com |
@casparcwang Could not parse
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
Now awaiting release team approval.
@neliasso Only the author (@casparcwang) is allowed to issue the |
/contributor add Wang Chao casparcwang@tencent.com |
@casparcwang |
/integrate |
/sponsor |
@casparcwang |
@DamonFool @casparcwang Pushed as commit 0fdf9cd. |
Yes, I'm OK with that. |
https://bugs.openjdk.java.net/browse/JDK-8260473
Function "PhaseVector::expand_vunbox_node" creates a LoadNode, but forgets to make the LoadNode to pass gc barriers.
Testing: all Vector API related tests have passed.
Original pr: openjdk/jdk#2253
Progress
Issue
Reviewers
Contributors
<smonteith@openjdk.org>
<casparcwang@tencent.com>
Download
$ git fetch https://git.openjdk.java.net/jdk16 pull/139/head:pull/139
$ git checkout pull/139