-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Reflow computeCommonPrefixLengthAndBuildHistogram to avoid crash #12905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eaad2fa
Add test that tickles a JVM JIT crash on JDK's less than 21.0.1
ChrisHegarty e0464fe
reflow computeCommonPrefixLengthAndBuildHistogram
ChrisHegarty 2edbbf6
Update test
ChrisHegarty 8291965
Add comment about the nature of this change
ChrisHegarty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,8 +17,14 @@ | |
| package org.apache.lucene.util.bkd; | ||
|
|
||
| import java.io.IOException; | ||
| import java.security.AccessController; | ||
| import java.security.PrivilegedAction; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import org.apache.lucene.document.IntPoint; | ||
| import org.apache.lucene.document.SortedNumericDocValuesField; | ||
| import org.apache.lucene.index.IndexWriter; | ||
| import org.apache.lucene.index.PointValues.IntersectVisitor; | ||
| import org.apache.lucene.index.PointValues.Relation; | ||
| import org.apache.lucene.store.Directory; | ||
|
|
@@ -28,6 +34,7 @@ | |
| import org.apache.lucene.tests.util.LuceneTestCase; | ||
| import org.apache.lucene.tests.util.TestUtil; | ||
| import org.apache.lucene.util.CollectionUtil; | ||
| import org.apache.lucene.util.SuppressForbidden; | ||
|
|
||
| public class TestDocIdsWriter extends LuceneTestCase { | ||
|
|
||
|
|
@@ -150,4 +157,28 @@ public Relation compare(byte[] minPackedValue, byte[] maxPackedValue) { | |
| } | ||
| dir.deleteFile("tmp"); | ||
| } | ||
|
|
||
| // This simple test tickles a JVM C2 JIT crash on JDK's less than 21.0.1 | ||
| // Crashes only when run with C2, so with the environment variable `CI` set | ||
| // Regardless of whether C2 is enabled or not, the test should never fail. | ||
| public void testCrash() throws IOException { | ||
| assumeTrue("Requires C2, which is only enabled when CI env is set", getCIEnv() != null); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a much easier way to detect if CI is enabled. Use |
||
| int itrs = atLeast(100); | ||
| for (int i = 0; i < itrs; i++) { | ||
| try (Directory dir = newDirectory(); | ||
| IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(null))) { | ||
| for (int d = 0; d < 20_000; d++) { | ||
| iw.addDocument( | ||
| List.of(new IntPoint("foo", 0), new SortedNumericDocValuesField("bar", 0))); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @SuppressForbidden(reason = "needed to check if C2 is enabled") | ||
| @SuppressWarnings("removal") | ||
| private static String getCIEnv() { | ||
| PrivilegedAction<String> pa = () -> System.getenv("CI"); | ||
| return AccessController.doPrivileged(pa); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hi Chris,
this env var isn't too useful as Jenkins does not set it. The logic to detect the CI availability is harder, but actually please remove the permission again, see below!
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.
Didn't know about it either. Will this work?
#12953
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.
Yes this works. Gradle enables Tiered compiler if Jenkins or GitHub is detected.
lucene/gradle/testing/defaults-tests.gradle
Line 54 in f6582ce