Mercurial > hg > graal-jvmci-8
comparison test/gc/g1/TestGCLogMessages.java @ 22910:3ca53859c3c7
8027962: Per-phase timing measurements for strong roots processing
Reviewed-by: tschatzl, ecaspole
author | brutisso |
---|---|
date | Thu, 19 Mar 2015 15:25:54 +0100 |
parents | a3953c777565 |
children | cbc7c4c9e11c |
comparison
equal
deleted
inserted
replaced
22909:38d6febe66af | 22910:3ca53859c3c7 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 | 23 |
24 /* | 24 /* |
25 * @test TestGCLogMessages | 25 * @test TestGCLogMessages |
26 * @bug 8035406 8027295 8035398 8019342 8027959 | 26 * @bug 8035406 8027295 8035398 8019342 8027959 8027962 |
27 * @summary Ensure that the PrintGCDetails output for a minor GC with G1 | 27 * @summary Ensure that the PrintGCDetails output for a minor GC with G1 |
28 * includes the expected necessary messages. | 28 * includes the expected necessary messages. |
29 * @key gc | 29 * @key gc |
30 * @library /testlibrary | 30 * @library /testlibrary |
31 */ | 31 */ |
32 | 32 |
33 import com.oracle.java.testlibrary.ProcessTools; | 33 import com.oracle.java.testlibrary.ProcessTools; |
34 import com.oracle.java.testlibrary.OutputAnalyzer; | 34 import com.oracle.java.testlibrary.OutputAnalyzer; |
35 | 35 |
36 public class TestGCLogMessages { | 36 public class TestGCLogMessages { |
37 public static void main(String[] args) throws Exception { | |
38 testNormalLogs(); | |
39 testWithToSpaceExhaustionLogs(); | |
40 } | |
41 | 37 |
42 private static void testNormalLogs() throws Exception { | 38 private enum Level { |
39 OFF, FINER, FINEST; | |
40 public boolean lessOrEqualTo(Level other) { | |
41 return this.compareTo(other) < 0; | |
42 } | |
43 } | |
43 | 44 |
44 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", | 45 private class LogMessageWithLevel { |
45 "-Xmx10M", | 46 String message; |
46 GCTest.class.getName()); | 47 Level level; |
47 | 48 |
48 OutputAnalyzer output = new OutputAnalyzer(pb.start()); | 49 public LogMessageWithLevel(String message, Level level) { |
50 this.message = message; | |
51 this.level = level; | |
52 } | |
53 }; | |
49 | 54 |
50 output.shouldNotContain("[Redirty Cards"); | 55 private LogMessageWithLevel allLogMessages[] = new LogMessageWithLevel[] { |
51 output.shouldNotContain("[Parallel Redirty"); | 56 // Ext Root Scan |
52 output.shouldNotContain("[Redirtied Cards"); | 57 new LogMessageWithLevel("Thread Roots (ms)", Level.FINEST), |
53 output.shouldNotContain("[Code Root Purge"); | 58 new LogMessageWithLevel("StringTable Roots (ms)", Level.FINEST), |
54 output.shouldNotContain("[String Dedup Fixup"); | 59 new LogMessageWithLevel("Universe Roots (ms)", Level.FINEST), |
55 output.shouldNotContain("[Young Free CSet"); | 60 new LogMessageWithLevel("JNI Handles Roots (ms)", Level.FINEST), |
56 output.shouldNotContain("[Non-Young Free CSet"); | 61 new LogMessageWithLevel("ObjectSynchronizer Roots (ms)", Level.FINEST), |
57 output.shouldNotContain("[Humongous Reclaim"); | 62 new LogMessageWithLevel("FlatProfiler Roots", Level.FINEST), |
58 output.shouldHaveExitValue(0); | 63 new LogMessageWithLevel("Management Roots", Level.FINEST), |
64 new LogMessageWithLevel("SystemDictionary Roots", Level.FINEST), | |
65 new LogMessageWithLevel("CLDG Roots", Level.FINEST), | |
66 new LogMessageWithLevel("JVMTI Roots", Level.FINEST), | |
67 new LogMessageWithLevel("CodeCache Roots", Level.FINEST), | |
68 new LogMessageWithLevel("SATB Filtering", Level.FINEST), | |
69 new LogMessageWithLevel("CM RefProcessor Roots", Level.FINEST), | |
70 new LogMessageWithLevel("Wait For Strong CLD", Level.FINEST), | |
71 new LogMessageWithLevel("Weak CLD Roots", Level.FINEST), | |
72 // Redirty Cards | |
73 new LogMessageWithLevel("Redirty Cards", Level.FINER), | |
74 new LogMessageWithLevel("Parallel Redirty", Level.FINEST), | |
75 new LogMessageWithLevel("Redirtied Cards", Level.FINEST), | |
76 // Misc Top-level | |
77 new LogMessageWithLevel("Code Root Purge", Level.FINER), | |
78 new LogMessageWithLevel("String Dedup Fixup", Level.FINER), | |
79 // Free CSet | |
80 new LogMessageWithLevel("Young Free CSet", Level.FINEST), | |
81 new LogMessageWithLevel("Non-Young Free CSet", Level.FINEST), | |
82 // Humongous Eager Reclaim | |
83 new LogMessageWithLevel("Humongous Reclaim", Level.FINER), | |
84 }; | |
59 | 85 |
60 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", | 86 void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[], Level level) throws Exception { |
61 "-XX:+UseStringDeduplication", | 87 for (LogMessageWithLevel l : messages) { |
62 "-Xmx10M", | 88 if (level.lessOrEqualTo(l.level)) { |
63 "-XX:+PrintGCDetails", | 89 output.shouldNotContain(l.message); |
64 GCTest.class.getName()); | 90 } else { |
91 output.shouldContain(l.message); | |
92 } | |
93 } | |
94 } | |
65 | 95 |
66 output = new OutputAnalyzer(pb.start()); | 96 public static void main(String[] args) throws Exception { |
97 new TestGCLogMessages().testNormalLogs(); | |
98 new TestGCLogMessages().testWithToSpaceExhaustionLogs(); | |
99 } | |
67 | 100 |
68 output.shouldContain("[Redirty Cards"); | 101 private void testNormalLogs() throws Exception { |
69 output.shouldNotContain("[Parallel Redirty"); | |
70 output.shouldNotContain("[Redirtied Cards"); | |
71 output.shouldContain("[Code Root Purge"); | |
72 output.shouldContain("[String Dedup Fixup"); | |
73 output.shouldNotContain("[Young Free CSet"); | |
74 output.shouldNotContain("[Non-Young Free CSet"); | |
75 output.shouldContain("[Humongous Reclaim"); | |
76 output.shouldNotContain("[Humongous Total"); | |
77 output.shouldNotContain("[Humongous Candidate"); | |
78 output.shouldNotContain("[Humongous Reclaimed"); | |
79 output.shouldHaveExitValue(0); | |
80 | 102 |
81 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", | 103 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", |
82 "-XX:+UseStringDeduplication", | 104 "-Xmx10M", |
83 "-Xmx10M", | 105 GCTest.class.getName()); |
84 "-XX:+PrintGCDetails", | |
85 "-XX:+UnlockExperimentalVMOptions", | |
86 "-XX:G1LogLevel=finest", | |
87 GCTest.class.getName()); | |
88 | 106 |
89 output = new OutputAnalyzer(pb.start()); | 107 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
108 checkMessagesAtLevel(output, allLogMessages, Level.OFF); | |
109 output.shouldHaveExitValue(0); | |
90 | 110 |
91 output.shouldContain("[Redirty Cards"); | 111 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", |
92 output.shouldContain("[Parallel Redirty"); | 112 "-XX:+UseStringDeduplication", |
93 output.shouldContain("[Redirtied Cards"); | 113 "-Xmx10M", |
94 output.shouldContain("[Code Root Purge"); | 114 "-XX:+PrintGCDetails", |
95 output.shouldContain("[String Dedup Fixup"); | 115 GCTest.class.getName()); |
96 output.shouldContain("[Young Free CSet"); | |
97 output.shouldContain("[Non-Young Free CSet"); | |
98 output.shouldContain("[Humongous Reclaim"); | |
99 output.shouldContain("[Humongous Total"); | |
100 output.shouldContain("[Humongous Candidate"); | |
101 output.shouldContain("[Humongous Reclaimed"); | |
102 output.shouldHaveExitValue(0); | |
103 } | |
104 | 116 |
105 private static void testWithToSpaceExhaustionLogs() throws Exception { | 117 output = new OutputAnalyzer(pb.start()); |
106 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", | 118 checkMessagesAtLevel(output, allLogMessages, Level.FINER); |
107 "-Xmx10M", | |
108 "-Xmn5M", | |
109 "-XX:+PrintGCDetails", | |
110 GCTestWithToSpaceExhaustion.class.getName()); | |
111 | 119 |
112 OutputAnalyzer output = new OutputAnalyzer(pb.start()); | 120 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", |
113 output.shouldContain("[Evacuation Failure"); | 121 "-XX:+UseStringDeduplication", |
114 output.shouldNotContain("[Recalculate Used"); | 122 "-Xmx10M", |
115 output.shouldNotContain("[Remove Self Forwards"); | 123 "-XX:+PrintGCDetails", |
116 output.shouldNotContain("[Restore RemSet"); | 124 "-XX:+UnlockExperimentalVMOptions", |
117 output.shouldHaveExitValue(0); | 125 "-XX:G1LogLevel=finest", |
126 GCTest.class.getName()); | |
118 | 127 |
119 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", | 128 output = new OutputAnalyzer(pb.start()); |
120 "-Xmx10M", | 129 checkMessagesAtLevel(output, allLogMessages, Level.FINEST); |
121 "-Xmn5M", | 130 output.shouldHaveExitValue(0); |
122 "-XX:+PrintGCDetails", | 131 } |
123 "-XX:+UnlockExperimentalVMOptions", | |
124 "-XX:G1LogLevel=finest", | |
125 GCTestWithToSpaceExhaustion.class.getName()); | |
126 | 132 |
127 output = new OutputAnalyzer(pb.start()); | 133 LogMessageWithLevel exhFailureMessages[] = new LogMessageWithLevel[] { |
128 output.shouldContain("[Evacuation Failure"); | 134 new LogMessageWithLevel("Evacuation Failure", Level.FINER), |
129 output.shouldContain("[Recalculate Used"); | 135 new LogMessageWithLevel("Recalculate Used", Level.FINEST), |
130 output.shouldContain("[Remove Self Forwards"); | 136 new LogMessageWithLevel("Remove Self Forwards", Level.FINEST), |
131 output.shouldContain("[Restore RemSet"); | 137 new LogMessageWithLevel("Restore RemSet", Level.FINEST), |
132 output.shouldHaveExitValue(0); | 138 }; |
133 } | |
134 | 139 |
135 static class GCTest { | 140 private void testWithToSpaceExhaustionLogs() throws Exception { |
136 private static byte[] garbage; | 141 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", |
137 public static void main(String [] args) { | 142 "-Xmx32M", |
138 System.out.println("Creating garbage"); | 143 "-Xmn16M", |
139 // create 128MB of garbage. This should result in at least one GC | 144 "-XX:+PrintGCDetails", |
140 for (int i = 0; i < 1024; i++) { | 145 GCTestWithToSpaceExhaustion.class.getName()); |
141 garbage = new byte[128 * 1024]; | 146 |
142 } | 147 OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
143 System.out.println("Done"); | 148 checkMessagesAtLevel(output, exhFailureMessages, Level.FINER); |
149 output.shouldHaveExitValue(0); | |
150 | |
151 pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC", | |
152 "-Xmx32M", | |
153 "-Xmn16M", | |
154 "-XX:+PrintGCDetails", | |
155 "-XX:+UnlockExperimentalVMOptions", | |
156 "-XX:G1LogLevel=finest", | |
157 GCTestWithToSpaceExhaustion.class.getName()); | |
158 | |
159 output = new OutputAnalyzer(pb.start()); | |
160 checkMessagesAtLevel(output, exhFailureMessages, Level.FINEST); | |
161 output.shouldHaveExitValue(0); | |
144 } | 162 } |
145 } | |
146 | 163 |
147 static class GCTestWithToSpaceExhaustion { | 164 static class GCTest { |
148 private static byte[] garbage; | 165 private static byte[] garbage; |
149 private static byte[] largeObject; | 166 public static void main(String [] args) { |
150 public static void main(String [] args) { | 167 System.out.println("Creating garbage"); |
151 largeObject = new byte[5*1024*1024]; | 168 // create 128MB of garbage. This should result in at least one GC |
152 System.out.println("Creating garbage"); | 169 for (int i = 0; i < 1024; i++) { |
153 // create 128MB of garbage. This should result in at least one GC, | 170 garbage = new byte[128 * 1024]; |
154 // some of them with to-space exhaustion. | 171 } |
155 for (int i = 0; i < 1024; i++) { | 172 System.out.println("Done"); |
156 garbage = new byte[128 * 1024]; | 173 } |
157 } | |
158 System.out.println("Done"); | |
159 } | 174 } |
160 } | 175 |
176 static class GCTestWithToSpaceExhaustion { | |
177 private static byte[] garbage; | |
178 private static byte[] largeObject; | |
179 public static void main(String [] args) { | |
180 largeObject = new byte[16*1024*1024]; | |
181 System.out.println("Creating garbage"); | |
182 // create 128MB of garbage. This should result in at least one GC, | |
183 // some of them with to-space exhaustion. | |
184 for (int i = 0; i < 1024; i++) { | |
185 garbage = new byte[128 * 1024]; | |
186 } | |
187 System.out.println("Done"); | |
188 } | |
189 } | |
161 } | 190 } |
191 |