Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8253877: gc/g1/TestGCLogMessages.java fails - missing "Evacuation fai…
…lure" message

Backport-of: cd66e0f
  • Loading branch information
GoeLin committed Oct 10, 2022
1 parent 4b2941d commit c9d5eb3
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions test/hotspot/jtreg/gc/g1/TestGCLogMessages.java
Expand Up @@ -39,6 +39,7 @@
*/

import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.Platform;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.Platform;

Expand Down Expand Up @@ -162,7 +163,9 @@ void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[],

public static void main(String[] args) throws Exception {
new TestGCLogMessages().testNormalLogs();
new TestGCLogMessages().testWithToSpaceExhaustionLogs();
if (Platform.isDebugBuild()) {
new TestGCLogMessages().testWithEvacuationFailureLogs();
}
new TestGCLogMessages().testWithInitialMark();
new TestGCLogMessages().testExpandHeap();
}
Expand Down Expand Up @@ -203,12 +206,15 @@ private void testNormalLogs() throws Exception {
new LogMessageWithLevel("Remove Self Forwards", Level.TRACE),
};

private void testWithToSpaceExhaustionLogs() throws Exception {
private void testWithEvacuationFailureLogs() throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
"-Xmx32M",
"-Xmn16M",
"-XX:+G1EvacuationFailureALot",
"-XX:G1EvacuationFailureALotCount=100",
"-XX:G1EvacuationFailureALotInterval=1",
"-Xlog:gc+phases=debug",
GCTestWithToSpaceExhaustion.class.getName());
GCTestWithEvacuationFailure.class.getName());

OutputAnalyzer output = new OutputAnalyzer(pb.start());
checkMessagesAtLevel(output, exhFailureMessages, Level.DEBUG);
Expand All @@ -218,7 +224,7 @@ private void testWithToSpaceExhaustionLogs() throws Exception {
"-Xmx32M",
"-Xmn16M",
"-Xlog:gc+phases=trace",
GCTestWithToSpaceExhaustion.class.getName());
GCTestWithEvacuationFailure.class.getName());

output = new OutputAnalyzer(pb.start());
checkMessagesAtLevel(output, exhFailureMessages, Level.TRACE);
Expand Down Expand Up @@ -267,16 +273,19 @@ public static void main(String [] args) {
}
}

static class GCTestWithToSpaceExhaustion {
static class GCTestWithEvacuationFailure {
private static byte[] garbage;
private static byte[] largeObject;
private static Object[] holder = new Object[200]; // Must be larger than G1EvacuationFailureALotCount

public static void main(String [] args) {
largeObject = new byte[16*1024*1024];
System.out.println("Creating garbage");
// create 128MB of garbage. This should result in at least one GC,
// some of them with to-space exhaustion.
for (int i = 0; i < 1024; i++) {
garbage = new byte[128 * 1024];
// Create 16 MB of garbage. This should result in at least one GC,
// (Heap size is 32M, we use 17MB for the large object above)
// which is larger than G1EvacuationFailureALotInterval.
for (int i = 0; i < 16 * 1024; i++) {
holder[i % holder.length] = new byte[1024];
}
System.out.println("Done");
}
Expand Down

1 comment on commit c9d5eb3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.